Jim LaGrone <jlagr...@cs.uh.edu> wrote on 08/27/2009 03:29:56 PM: > I have the following: > > var reg: Region{rank==2}; > var dist: Dist{rank==2}; > var array: Array[Double](dist); > reg = [0..4, 0..6]; > dist = Dist.makeBlock(reg, 0); > array = Array.makeVar[Double] (dist, > ((p):Point) => 0.0); > > Console.OUT.println("printing the i,j loop"); > for (i = 0; i < 5; i++) > for (j = 0; j < 7; j++) > Console.OUT.println( array(i,j) ); > > which produces: > > x10.lang.BadPlaceException: point (2,0) not defined at (Place 0) > at x10.array.BaseArray$23.apply(BaseArray.java:1330) > at x10.array.BaseArray$23.apply(BaseArray.java:1) > at x10.array.RectRegion.check(RectRegion.java:709) > at x10.array.BaseArray.checkPlace(BaseArray.java:715) > at x10.array.DistArray.apply(DistArray.java:126) > at ArrayReader.main(ArrayReader.java:195) > at ArrayReader$Main$1.apply(ArrayReader.java:48) > at x10.runtime.Activity.now(Activity.java:222) > at x10.runtime.Activity.run(Activity.java:127) > at x10.runtime.Worker$3.apply(Worker.java:330) > at x10.runtime.impl.java.Runtime.runAt(Runtime.java:96) > at x10.runtime.Worker.loop(Worker.java:317) > at x10.runtime.Runtime.start(Runtime.java:143) > at ArrayReader$Main.main(ArrayReader.java:35) > at x10.runtime.impl.java.Runtime.run(Runtime.java:46) > at java.lang.Thread.run(Thread.java:613) > > Can someone explain this?
See my previous message. A block distribution will partition the array's region over multiple places, and the elements will live in those places. The print loop runs in one places (place 0 in this case), and it cannot access the elements that reside in other places. > Also, if the nested loop is replaced with > > Console.OUT.println("printing the p loop"); > for (p:Point in dist) > Console.OUT.println( array(p) ); > > I get this: > > /Users/jlagrone/GradSchool/Research/workspace/X10-code/tests/ > ArrayReader.x10:28: Method array(x10.lang.Point{self==p}) not found. > > I thought I could iterate through the array with points. I thought > this had to do with a method guard, but this is a concept I still > don't understand but thought I had employed. You can iterate over the array with points, but the method guard on the apply() method requires that the rank of the point is exactly the same as the rank of the array. So, if you have an Array of undetermined rank, you can use a Point of undetermined rank to iterate over it. However, in your case the array's type is inferred to have rank 2 (since the dist has rank 2), but you've overridden the type of the point to be Point (with unknown rank). The following will do the same as your nested loop: > for (p:Point(2) in dist) > Console.OUT.println( array(p) ); and so will this: > for (p in dist) > Console.OUT.println( array(p) ); Note that both of those will fail with the same BadPlaceException, since these loops do nothing to account for the distribution of the array. Hope this helps, 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/) ------------------------------------------------------------------------------ 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