Oops. Josh is correct -- the code won't work as written, even if real() and image() are static. I didn't notice that the code executes in a single place -- I read it as an "ateach" instead of a nested "for". If the code were changed to use an "ateach" (or an initializer -- see below), my comments would still apply.
Josh, I think you meant changing Array.makeVar[Complex](regionS, ((p):Point) => new Complex ()) to Array.makeVar[Complex](distS, ((p):Point) => new Complex ()) rather than the Dist.makeBlock() call. Using the initializer is a good idea, but again, if real() and image() are not static calls, they'll be interpreted as this.real() and this.image(), and thus result in a BadPlaceException from places other than 0. Come to think of it, the same will happen if Mc is an instance field. Finally, "imaginary" in complex numbers is usually abbreviated to "imag" (without the trailing "e"). I think "image" is just a homophone. Igor -- Igor Peshansky (note the spelling change!) IBM T.J. Watson Research Center XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/) X10: Parallel Productivity and Performance (http://x10.sf.net/) Josh Milthorpe <josh.miltho...@anu.edu.au> 08/28/2009 09:29 PM To Jim LaGrone <jlagr...@cs.uh.edu> cc Igor Peshansky/Watson/i...@ibmus, x10-users@lists.sourceforge.net Subject Re: [X10-users] Distributions and arrays Igor Peshansky wrote: This is slightly different code, but I realized later that this is executed first. But this throws a similar x10.lang.BadPlaceException. And yes, S is a member of State class. I have not yet attempted this with C++ backend but will do so. /* class members */ var regionS: Region{rank==2}; var distS: Dist{rank==2}; var S: Array[Complex](distS); /* code from method */ val real = tmp_fs_real;//Rail val image = tmp_fs_image;//Rail regionS = [0..N-1, 0..Mc-1]; distS = Dist.makeBlock(regionS,0); S = Array.makeVar[Complex](regionS, ((p):Point) => new Complex ()); val S = this.S; finish{ for ( p in distS.places()) async (p){ for( (i1,j1) in regionS ){ S(i1,j1).real = real(i1*Mc+j1); S(i1,j1).image = image(i1*Mc+j1); } } } this.S = S; Let me guess: real() and image() are instance methods of the State class... Again, you're attempting to invoke methods on an object that lives in place 0 from other places, which won't work. Basically, the rule of thumb is: you cannot access state or invoke instance methods via a remote reference. If real() and image() could be made static, the above code should work. Igor Hi Jim, if I correctly understand the intent, you're trying to initialize each element of S : Array[Complex] based on some values in the real and image rails. However I don't think that's what the above code achieves. The outer loop iterates over all places included in distS. The inner loop iterates over every point in the region of S. Because distS is a block distribution over all places, this means that an activity will be started at each place, and each activity will attempt to assign to every element of S - including those elements that reside at other places. I suspect that this is the cause of the BPE. (As an aside, S is not distributed, because distS is not used in the initializer. To make it distributed, use distS = Dist.makeBlock(distS,0); rather than distS = Dist.makeBlock(regionS,0); ) You could initialize S in a single statement using an Array initializer function, something like: S = Array.make[Complex](distS, (val (i,j): Point) => new Complex (real(i*Mc+j), image(i*Mc+j))); BTW is the use of "image" rather than "imaginary" an American vs. British thing? I haven't heard this term used before. Cheers, Josh ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users