On Aug 27, 2009, at 3:55 PM, Igor Peshansky wrote: > You can also use the place-local idiom, as follows: > > val norms = Array.make[Double](Dist.makeUnique(), (Point)=>0.0); > finish ateach ( (p) in distS.places() ) { > for ( (i, j) in distS | p ) { // at this point, p == here > norms(p.id) += Math.sqrt(S(i,j).real*S(i,j).real + > S(i,j).image*S(i,j).image); > } > } > rawNormPower2 = norms.sum(); // a distributed reduction > > Here, norms is an array with a unique distribution (which has one > point > per place). The ateach loop again spawns parallel iterations on each > place (but now there's one per place covered by the distribution). > The > body of the ateach has a sequential loop that runs over the part of > distS > that lives in that place. Each iteration of that sequential loop > updates > the local element of norms. There is no need for atomic, since all > updates happen sequentially. Once the ateach loop is done, a > (distributed) > reduction is performed over the norms array, and the sum is stored > in the > final result location.
Using this method and Java backend, I have rawNormPower2 = 0; val norms = Array.make[Double](Dist.makeUnique(), (Point)=>0.0); finish ateach( (p) in distS.places() ){ //line 327 for( (i,j) in distS | p ){ norms(p.id) += Math.sqrt(S(i1,j1).real*S(i1,j1).real + S(i1,j1).image*S(i1,j1).image); } } rawNormPower2 = norms.sum()/( N*Mc ); //line 333 but get this /Users/jlagrone/GradSchool/Research/workspace/X10-code/SSCA3-X10/src- par/State.x10:327: Could not infer type for formal parameter. /Users/jlagrone/GradSchool/Research/workspace/X10-code/SSCA3-X10/src- par/State.x10:327: Could not infer type for formal parameter. /Users/jlagrone/GradSchool/Research/workspace/X10-code/SSCA3-X10/src- par/State.x10:333: No valid method call found for sum() in x10.lang.Array[x10.lang.Double]. Also, is it safe to assume this will work with Java backend on dual- core machine? Or should I do development on cluster from here on out? How should the program be executed. We usually use slurm, but is there some special method? Jim ------------------------------------------------------------------------------ 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