Hi Jim, what is the purpose of the "large data structure"? Is it a sort of scratchpad, which is not directly used in the final result? In which case I'd expect something like:
public class TestVal { var result : Double; public def someOperation() { var reg: Region{rank==1} = [1..8]; var dist: Dist{rank==1} = Dist.make(reg); val sharedData = 2.71828; finish ateach((i) in dist) { val c = new LargeObject(sharedData, ...); // complicated work on c result += c.result(); } } } Or is the large data structure used to hold a partial result for each iteration, and the partial results are accumulated to form the final result? In which case: public class TestVal { public def someOperation() { var reg: Region{rank==1} = [1..8]; var dist: Dist{rank==1} = Dist.make(reg); val sharedData = 2.71828; val partialResults = Array.make[LargeObject](dist, (Point)=> new LargeObject(sharedData, ...)); finish ateach((i) in partialResults) { val c = partialResults(i); // complicated work on c } result = partialResults.reduce((a:LargeObject,b.LargeObject) => a.add(b), LargeObject.NULL); } } The second case could be seen as a complicated analogue of an OpenMP reduction variable. There has been some discussion on x10-core about introducing a "collecting finish" which would simplify this greatly. See https://sourceforge.net/mailarchive/forum.php?thread_name=z2w7a30b9461004211429u1e6349b3u517c1c576e97d8%40mail.gmail.com&forum_name=x10-core Cheers, Josh Jim LaGrone wrote: >>> 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, >> > > I wrote my own class for this. > > >> 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? >> > > That makes sense, but obviously this is not what I want. Is there a simple > way in X10 to get a such an object to be privatized among the iterations? > This code snippet is an example of the code I'm working with. The actual code > involves a large data structure which needs to be unique to each iteration > with no loop carried dependences. Sequentially this is no problem. > Concurrently, each iteration needs a separate copy. > > Any help is appreciated. > > Jim > > >>> 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 > X10-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/x10-users > ------------------------------------------------------------------------------ _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users