That did it!  Thank you so much Dave.  That also answered a few other questions 
that I found vague in the materials.

I appreciate the help and quick response!

Paul Monday
Parallel Scientific, LLC.
paul.mon...@parsci.com




On Jun 1, 2012, at 7:59 PM, David P Grove wrote:

> Paul Monday <paul.mon...@parsci.com> wrote on 06/01/2012 06:50:36 PM:
> > 
> > I have a question on Distributed Arrays and Reductions.  I wrote a 
> > very simple program that I thought would create a local array, 
> > distribute it to a DistArray, then "reduce" to add up the elements.
> > 
> > It appears that I am not understanding the creation of the DistArray
> > in some fundamental way.  Using the below to distribute my array 
> > into the DistArray, it seems to then only operate against the first 
> > 8 elements.
> > 
> > I need to do a two step creation like this as my primary program 
> > actually builds an Array and then puts the results into the 
> > distributed array like below.
> > 
> > My guess is that the initializer is incorrect, is this a fundamental
> > misunderstanding of "Point"?
> > 
> > public class TestArrays {
> >     public static def main(args: Array[String]) {
> >      val ranks = new Array[Int](100, (i:Int) => i);
> >     Console.OUT.println("ranks="+ranks);     
> >     val initializer = (i:Point) => {
> >     return ranks(i);
> >     };
> >     val D = Dist.makeUnique();
> >     val distList = DistArray.make[Int](D, initializer);
> >     Console.OUT.println("distList numPlaces="+D.numPlaces()+", distList=" 
> > +distList);     
> >     val rResult = distList.reduce ( (x:Int, y:Int) => x + y, 0);
> >     Console.OUT.println("rResult="+rResult);
> >     }
> > }
> > 
> > And here is the result of a run:
> > ranks=[0,1,2,3,4,5,6,7,8,9...(omitted 90 elements)]
> > distList numPlaces=8, distList=DistArray(Dist([0..0]->0,[1..1]->1,
> > [2..2]->2,[3..3]->3,[4..4]->4,[5..5]->5,[6..6]->6,[7..7]->7))
> > rResult=28
> > 
> 
> Hi Paul,
> 
> You're guess is close.  I think what you are missing is what 
> Dist.makeUnique() does.  It creates a Dist object in which there is exactly 
> one Point mapped to each Place.  Place(0) gets the Point (0).  Place(1) gets 
> the Point (1), etc.   The DistArray.make then evaluates the initializer on 
> each Point in 0..MAX_PLACES.  So only the first 8 elements of the Array get 
> reduced when you run with 8 Places.   If you use a block distribution instead:
> 
>     val D = Dist.makeBlock(ranks.region);
> 
> Then all the points in ranks.region will be block distributed to all the 
> Places in the computation, and it will do what I think you were expecting:
> 
> [dgrove@wahtutca myTests]$ export X10_NPLACES=4
> [dgrove@wahtutca myTests]$ ./a.out
> ranks=[0,1,2,3,4,5,6,7,8,9...(omitted 90 elements)]
> distList numPlaces=4, 
> distList=DistArray(Dist([0..24]->0,[25..49]->1,[50..74]->2,[75..99]->3))
> rResult=4950
> 
> Note that this particular program will end up copying the entire ranks Array 
> to each Place, even though only 1/P where P is the number of Places will 
> actually be used in each Place.  For smallish ranks, this probably doesn't 
> matter.  For large arrays, you'll want to do something fancier to avoid 
> useless copying.
> 
> Hope this helps,
> 
> --dave
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. 
> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to