Jim LaGrone <[email protected]> wrote on 05/18/2010 08:53:12 AM:

>
> I'm still looking for an answer to parallelizing a loop with common
> data for each iteration.

Sorry, things have been a little hectic and this must have slipped through
the cracks.

> It is my understanding that the value vC
> would be private to each iteration of the ateach loop. This doesn't
> seem to be the case. Output is below. I'm using version 1.7.7.

vC is private, but the object it is pointing to is not.

I believe in 1.7.7 Complex is an object, so although each iteration has its
own private pointer to C, they are still pointing to the same object.
Therefore the updates from one iteration are visible in others because
there is a single object that is being accessed by all the iterations.

Does that make sense?

--dave

>
>
> public class TestVal{
>    public static def main(args:Rail[String]){
>       var c: Complex = new Complex();
>       var reg: Region{rank==1} = [1..8];
>       var dist: Dist{rank==1} = Dist.make(reg);
>
>       val vC = c;
>       finish ateach((i) in dist)
>       {
>          vC.imag = i as Double;
>          for ( var n: Int = 0; n < 100; n++ );
>          Console.OUT.println(vC);
>       }
>    }
> }
>
>
> Output: Notice the absence of (0,8) and the replication of (0,2). It
> seems there is a data race on the vC, but my understanding is that
> vC would be local to each thread.
>
> $ x10 TestVal
> (0.0, 1.0)
> (0.0, 7.0)
> (0.0, 6.0)
> (0.0, 5.0)
> (0.0, 4.0)
> (0.0, 3.0)
> (0.0, 2.0)
> (0.0, 2.0)
>
>
> If I am misunderstanding this, can anyone offer a correction? In
> this example, I want vC to be private (local) to each iteration.
> I.e., each iteration gets its own copy.
>
> Thanks,
>
> Jim
------------------------------------------------------------------------------

_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to