Hi, I have a array distributed on 2 places and I want to copy a line of array coefficients to another line (i.e. a(0, j) <- a(1, j) for j=0 to 9). Both lines are on different places.
What is the preffered way to do that ? Below there is a small example (each value is transfered separately). It works, but I find my solution neither elegant neither efficient. Suggestions are welcome. Thanks in advance. Marc //========================================================= // example import x10.io.Console; import x10.util.Timer; public value test10 { public static def println(s:String) = Console.OUT.println(s); public static def print(s:String) = Console.OUT.print(s); public static def now():double = Timer.nanoTime() * 1e-9; val a:Array[double]; def this() { R : Region = Region.makeRectangular([0,0], [1,9]); D : Dist = Dist.makeCyclic(R, 0); a = Array.make[double](D, ((i,j):Point) => 10*i+j as Double) ; } def output(val s : String) { println("\n" + s); for (p in a.dist.places()) at (p) { println("place : " + here); for ((i,j): Point in a.dist.get(p)) print(" " + a([i,j])); println(""); } } def transfert() { for ((i,j): Point in a.dist.get(Place.places(0))) a([i,j]) = at (Place.places(1)) a([1-i,j]); } static public def main(args : Rail[String]) { t:test10 = new test10(); t.output("before copy"); t.transfert(); t.output("after copy"); } } ------------------------------------------------------------------------------------ Marc Tajchman Laboratoire de Génie Logiciel et de Simulation Software Engineering and Computer Simulation Laboratory CEA-DEN/DANS/DM2S/SFME/LGLS Tél : +33/1 69 08 73 27 Fax : +33/1 69 08 52 42 mailto:marc.tajch...@cea.fr ------------------------------------------------------------------------------------ Ce message électronique et tous les fichiers attachés qu'il contient sont confidentiels et destinés exclusivement à l'usage de la personne à laquelle ils sont adressés. Si vous avez reçu ce message par erreur, merci d'en avertir immédiatement son émetteur et de ne pas en conserver de copie. This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual to whom they are addressed. If you have received this e-mail in error please inform the sender immediately, without keeping any copy thereof. -------- Message d'origine-------- De: TAJCHMAN Marc Date: dim. 20/09/2009 12:30 À: x10-users@lists.sourceforge.net Objet : Help for distributed arrays Hi everyone, Thanks for helping me on previous messages (especially Igor). Below are 2 versions of a test (defining and accessing a distributed array on several places). This is a variation of an example code from X10 distribution (EncapsulatedArray2D). The first version is (apparently) working well but the second one launches several x10.lang.BadPlaceException. The differences are : - first version : the distributed array is created and accessed only from the static main function - second version : the array is now a member of the class containing the main function. It's created inside the class constructor and accessed from other class method. Thanks a lot for any suggestion. Marc // ===================================================== // working code public class test8 { static def println(s:String) = Console.OUT.println(s); static def print(s:String) = Console.OUT.print(s); static value bloc{ val m_array: Array[double]; def this(val a_array: Array[double]): bloc = { m_array=a_array; } def init(val i:int) : Void = { for (val (j): Point(1) in m_array) m_array([j])= 10*j + i; } def output() : Void = { for (val (j): Point(1) in m_array) { println(" "+j+" : " + m_array([j])); } } } public static def main(a: Rail[String]) : void { val R : Region = [1..5]; val r : Region = [1..3]; val D = Dist.makeCyclic(R, 0); val A = Array.make[bloc] (D, (p:Point) => new bloc(Array.make[double](r->here,(Point)=>0.0D))); finish ateach (val (i): Point in D) A([i]).init(i); for (val p in A.dist.places()) at(p) { val r : Region = A.dist.get(here); for ((i): Point in r) { println("subdomain "+i+" place = "+ here); A([i]).output(); println(""); } } } } // ======================================================== // non working version public class test8c { val A : Array[bloc]; static def println(s:String) = Console.OUT.println(s); static def print(s:String) = Console.OUT.print(s); static value bloc{ val m_array: Array[double]; def this(val a_array: Array[double]): bloc = { m_array=a_array; } def init(val i:int) : Void = { for (val (j): Point(1) in m_array) m_array([j])= 10*j + i; } def output() : Void = { for (val (j): Point(1) in m_array) { println(" "+j+" : " + m_array([j])); } } } def init() { finish ateach (val (i): Point in A.dist) A([i]).init(i); } def output() { for (val p in A.dist.places()) at(p) { val r : Region = A.dist.get(here); for ((i): Point in r) { println("subdomain "+i+" place = "+ here); A([i]).output(); println(""); } } } def this() { val R : Region = [1..5]; val r : Region = [1..3]; val D = Dist.makeCyclic(R, 0); A = Array.make[bloc] (D, (p:Point) => new bloc(Array.make[double](r->here,(Point)=>0.0D))); } public static def main(a: Rail[String]) : void { val t : test8c = new test8c(); t.init(); t.output(); } } ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users