MathGroup Archive 2009

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

Search the Archive

Re: Re: Re: ParrallelDo and set::noval

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102715] Re: [mg102704] Re: [mg102697] Re: ParrallelDo and set::noval
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Fri, 21 Aug 2009 04:42:39 -0400 (EDT)
  • References: <h63cgg$1b6$1@smc.vnet.net> <h6duf8$h1c$1@smc.vnet.net>
  • Reply-to: drmajorbob at bigfoot.com

This implies that "grid" cannot be changed inside ParallelDo in your code,  
yes? And a simple test verifies as much.

But then, surely, that should be mentioned in the documentation for  
DistributeDefinitions!

Bobby

On Thu, 20 Aug 2009 03:55:30 -0500, Patrick Scheibe  
<pscheibe at trm.uni-leipzig.de> wrote:

> Hi,
>
> why do you create the table in the first place? Just let ParallelTable
> collect your data:
>
> grid = Range[4, 50, 0.5];
> DistributeDefinitions[grid];
> testArray1 = ParallelTable[
>   {i, If[4 <= grid[[i]] <= 50, 1, 0]}, {i, 1, Length[grid]}]
>
> but if you insist to know what was wrong with your code, please have a
> look at SetSharedVariable[...]
>
> grid = Range[4, 50, 0.5];
> testArray = Array[Null, {Length[grid]}];
> DistributeDefinitions[grid];
> SetSharedVariable[testArray];
> ParallelDo[iroot = 0;
>  rr = grid[[i]];
>  Which[4 <= rr <= 50, iroot = 1];
>  testArray[[i]] = {i, iroot};, {i, 1, Length[grid]}]
>
> testArray===testArray1
>
> Out[12]= True
>
> Cheers
> Patrick
>
> On Wed, 2009-08-19 at 07:02 -0400, guerom00 wrote:
>> As requested, a minimal example which illustrate the problem.
>>
>> The following sequential code works fine :
>>
>> grid = Range[4, 50, 0.5];
>> testArray = Array[Null, {Length[grid]}];
>>
>> Do[
>>  iroot = 0;
>>  rr = grid[[i]];
>>  Which[
>>   4 <= rr <= 50, iroot = 1
>>   ];
>>  testArray[[i]] = {i, iroot};
>>  , {i, 1, Length[grid]}]
>>
>>
>> The equivalent parallel code :
>>
>> grid = Range[4, 50, 0.5];
>> testArray = Array[Null, {Length[grid]}];
>>
>> DistributeDefinitions[grid,testArray];
>>
>> ParallelDo[
>>  iroot = 0;
>>  rr = grid[[i]];
>>  Which[
>>   4 <= rr <= 50, iroot = 1
>>   ];
>>  testArray[[i]] = {i, iroot};
>>  , {i, 1, Length[grid]}]
>>
>> returns "Set::noval: Symbol testArray in part assignment does not have
>> an immediate value." Somehow the DistributeDefinitions[] is not
>> sufficient to indicate to each kernel that I have initialized the list
>> testArray.
>>
>> Thanks in advance for any help :)
>>
>
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: Incongruence? hmm...
  • Next by Date: Re: Incongruence? hmm...
  • Previous by thread: Re: Re: ParrallelDo and set::noval
  • Next by thread: Re: Re: Re: ParrallelDo and set::noval