MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: results from Array and ParallelArray differ

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117068] Re: results from Array and ParallelArray differ
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Wed, 9 Mar 2011 06:57:30 -0500 (EST)

It looks like ParallelArray uses Join to combine the results from the 
individual kernels instead of Plus. I guess it assumes that the partial 
results coming from the separate kernels are expressions with head 
Plus, so the final result would be Join[Plus[...],Plus[...]]=Plus[...,...] 
as you would expect, but in this case the result from each kernel is a 
number, so Join[result1,result2] goes wrong. 

Replacing Join with Plus as you did looks like the easiest way to 
solve this, but I would have expected that the ParallelArray would 
check for a situation like this (as ParallelCombine  does for example).

Heike.

On 7 Mar 2011, at 10:49, Peter Pein wrote:

> Dear group,
> 
> I did a search using tags "ParallelArray" and "Join" and did not find 
> any posting in this group; apologies, if this has already been asked.
> 
> The documentation tells:
> 
> "ParallelArray will give the same results as Array, except for side 
> effects during the computation."
> 
> I use an anonymous function and no variables; DistributeDefinitions, 
> SetSharedVariable etc. can not be the cause for the trouble in the 
> following toy example:
> 
> In[1]:= arrsum = Array[1/Plus[##]&, {3, 3}, {1, 0}, Plus]
> Out[1]= 37/10
> :-)
> 
> In[2]:= parrsum = ParallelArray[1/Plus[##]&, {3, 3}, {1, 0}, Plus]
> Out[2]= Join[35/12, 47/60]
> :-(
> 
> In[3]:= parrsum /. Join->Plus
> Out[3]= 37/10
> 
> Is this a bug, a feature or my thick-wittedness? What can be done?
> 
> Well, I could use Total[ParallelTable[...],2] but I don't want to.
> 
> Thanks in advance,
> Peter
> 
> P.S.: I came across this problem while coding
> http://dl.dropbox.com/u/3030567/Mathematica/springer.nb
> 



  • Prev by Date: Re: Please add me to this group
  • Next by Date: Re: Please add me to this group
  • Previous by thread: results from Array and ParallelArray differ
  • Next by thread: CUDALink with Mathematica 8, Visual C++ 2008 Express and Windows 7 x64