MathGroup Archive 2010

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

Search the Archive

Any answer for this ParallelDo error

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108877] Any answer for this ParallelDo error
  • From: pratip <pratip.chakraborty at gmail.com>
  • Date: Mon, 5 Apr 2010 08:01:53 -0400 (EDT)

Hallo Group,

Here is a harmless piece of code.

Clear[a];
t=AbsoluteTime[];
a=ParallelTable[0,{i,1,20},{j,1,50}];
DistributeDefinitions[a];
mat=ParallelDo[a[[i,j]]=If[PrimeQ[(i^3+j^5)]==True,1,0],{i,1,20},{j,
1,50}];
AbsoluteTime[]-t

The error is something like

Set::noval: Symbol a in part assignment does not have an immediate value.
Set::noval: Symbol a in part assignment does not have an immediate value.

I know there is a way of using SetSharedVariable but that version of
the code is very slow.

Clear[a];
t=AbsoluteTime[];
a=ParallelTable[0,{i,1,20},{j,1,50}];
SetSharedVariable[a];
mat=ParallelDo[a[[i,j]]=If[PrimeQ[(i^3+j^5)]==True,1,0],{i,1,20},{j,
1,50}];
Print[a//ArrayPlot];
AbsoluteTime[]-t

Time taken: 6.1443514

The single processor version is much faster

Clear[a];
t=AbsoluteTime[];
a=Table[0,{i,1,20},{j,1,50}];
mat=Do[a[[i,j]]=If[PrimeQ[(i^3+j^5)]==True,1,0],{i,1,20},{j,1,50}];
Print[a//ArrayPlot];
AbsoluteTime[]-t

Time taken: 0.0360021

My question is why I cant distribute the definition of a array to my
processor kernels.
Hope someone can give me an answer. I need to make this Do loop
parallel.

Yours,

Pratip


  • Prev by Date: Epic Epic HeavisideTheta problem
  • Next by Date: Show[] on 3D graphics, rotation by mouse, how to improve performance
  • Previous by thread: Epic Epic HeavisideTheta problem
  • Next by thread: Re: Any answer for this ParallelDo error