Jim LaGrone <jlagr...@cs.uh.edu> wrote on 08/31/2009 11:28:31 AM:

> On 31 Aug 2009, at 9:44 AM, Igor Peshansky wrote:
> 
> > Jim LaGrone <jlagr...@cs.uh.edu> wrote on 08/31/2009 10:20:29 AM:
> >
> >> I spoke too soon. It compiled but didn't run. Still have the
> >> BadPlaceExeption. This is the code:
> >>
> >>   //declared as Class members
> >>   var regionS: Region{rank==2};
> >>   var distS: Dist{rank==2};
> >>   var S: Array[Complex](distS);
> >>
> >>   //code from member method
> >>   regionS = [0..N-1, 0..Mc-1];
> >>   distS = Dist.makeBlock(regionS,0);
> >>
> >>   S = Array.make[Complex](distS,
> >>      (val (i,j):Point) => new Complex ( real(i*Mc+j), image(i*Mc+j) )
> > );
> >
> > Jim,
> >
> > See my comments regarding fields vs. local variables, and static vs.
> > instance methods. If real() and image() are instance methods, they
> > will be invoked via "this", which lives in place 0.  Also, if Mc is
> > an instance field, it will also live in place 0.  The initializer
> > essentially runs in an ateach loop, so the same restrictions apply.
> 
> tmp_fs_real and tmp_fs_image are Rails[Double].
> 
>    val real = tmp_fs_real;
>    val image = tmp_fs_image;
> 
>    val Mc_tmp = Mc;  //just made this change
>    val N_tmp = N;     // and this one
>    regionS = [0..N_tmp-1, 0..Mc_tmp-1];
>    distS = Dist.makeBlock(regionS,0);
>    S = Array.make[Complex](distS,
>        (val (i,j):Point) => new Complex ( real(i*Mc_tmp+j), image 
> (i*Mc_tmp+j) ) ); 

Ah.  I kept thinking of real() and image() as functions, but they
are, in fact, Rails...  That would explain it: Rails are objects,
and thus live in the place they were created.  So, accessing them
from another place will give you a BadPlaceException.

One possible solution is to make them ValRails (if the algorithm
allows this).  Another is to send the relevant bits using ValRails
into other Rails that live in the appropriate places.

> >> I'm still confused about the number of places. It shows 4 places
> >> printing NativeRuntime.MAX_PLACES on my dual core machine. I'll 
> >> attach
> >> output from execution.
> >>
> >> Jim
> >
> > X10 will not automatically compute the optimal number of places --
> > you have to tell it how many places to use.  For the Java backend
> > the default is 4 places, regardless of the number of actual cores.
> > For the C++ backend it's however many processes you spawn (runx10
> > will only spawn one).
> 
> How do I change the number of places? This seems to execute with C++ 
> backend.

The reason this executes with the C++ backend is because you are
only running with one place by default in C++, but with 4 in Java.
Were you to spawn more than 1 process with C++, it wouldn't have
worked either.

With the Java backend, you can pass the -NUMBER_OF_LOCAL_PLACES=<N>
option to the runtime (e.g., the x10 script).  With the C++ backend,
you'll need to use "mpiexec -np <N>" to spawn N processes.

> > Hope this helps,
> >        Igor
> >
> >> [attachment "exec.out" deleted by Igor Peshansky/Watson/IBM]
> >>
> >> On 28 Aug 2009, at 8:29 PM, Josh Milthorpe wrote:
> >>
> >>> 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)));
> >>
> >> This is what I was looking for but couldn't make it work. I don't 
> >> know
> >> what I had before, but this works. Thanks!
> >>
> >>>
> >>> BTW is the use of "image" rather than "imaginary" an American vs.
> >>> British thing?  I haven't heard this term used before.
> >>
> >> I'm porting a benchmark someone else wrote in C. I'm just using the
> >> same identifiers. Personally, I would have used "imag".
> >>
> >> Jim
-- 
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/)


------------------------------------------------------------------------------
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

Reply via email to