Hi,

I wrote a code to test the exchange of data between places.

An 3-by-n array is distributed on 3 places (one row on each place).
The code perform a (potentially large) number of iterations. 
At each iteration there is an exchange between row 1 (located on place 0) and 
row 3 (located on place 2). Exchange is performed from place 1.

There are 2 versions (each components in different sendings and entire rows in 
one sending).
(Igor : as you said in a previous reply, version 2 is much more efficient.)  

The code seems to leak memory at each iteration (apparently it's proportional 
to the number of exchanges rather then the lenght of the vectors, but I didn't 
perform extensive tests).

Below are :
- the source code
- instructions I used to compile at
- a command to run the executable

Possible replies may be :

- my code is poorly written,
- the garbage collector will be started when memory is almost exhausted,
- specify a more regular garbage collector trigger (by specifying additional 
compiler/running options)
- other ?

Thanks for help,
Best Regards,
Marc 


//==== test11.x10 =============================================
import x10.util.Timer;
import x10.io.Console;

public value test11 {

  public static def println(s:String) = Console.OUT.println(s);
  public static def print(s:String) = Console.OUT.print(s);
  public static def println() = Console.OUT.println();
  public static def flush() = Console.OUT.flush();
  public static def now():double = Timer.nanoTime() * 1e-9;

  val n : int;
  val A : Array[int](2);

  def output() {
    if (n <= 10) {
      for (var i:int = 0; i<3; i++) {
        for (var j:int = 0; j<n; j++) {
          val ii:int = i;
          val jj:int = j;
          print(" " + (at (A.dist(ii,jj)) A(ii,jj)));
        }
        println();
      }
      println();
    }
  }

  def exchange(c:int) {
    
    val p0 : Place = Place.places(0);
    val p2 : Place = Place.places(2);

    if (c == 1) {
        for ((j):Point(1) in [0..n-1]) {
            val temp:int = at (p0) A(0,j);
            at (p0) A([0,j]) = at (p2) A(2,j);
            at (p2) A(2,j) = temp;
        }
    }
    else if (c == 2) {
        val w1 = at (p2) 
            Rail.makeVal[int](n, (j:int) => A(2, j));
        
        val w2 = at (p0)
            Rail.makeVal[int](n, (i:int) => A(0, i));
        
        at (p0)
            for (var i:int=0; i<n; i++)
                A(0, i) = w1(i);
        
        at (p2)
            for (var i:int=0; i<n; i++)
                A(2, i) = w2(i);
    }
  }

  def compute() {
    val p0 : Place = Place.places(0);
    at (p0)
      for (var i:int=0; i<n; i++)
        A(0, i) += 1;
  }

  def this(m:int) {
    n=m;
    val R:Region{rank==2} = [0..2, 0..n-1];
    val D:Dist{rank==2} = Dist.makeBlock(R, 0);
  
    A = Array.makeVal[int](D, ((i,j):Point) => 10000*(here.id+1)+(j+1));
  }

  public static def main(var args: Rail[String]): void = {
    
    it_max:int = args.length > 0 ? int.parseInt(args(0)) : 100;
    n:int = args.length > 1 ? int.parseInt(args(1)) : 10;
    c:int = args.length > 2 ? int.parseInt(args(2)) : 2;

    println("iterations : " + it_max + " exchange length : " + n);
    println();

    var t:double = now();
    
    val test:test11 = new test11(n);
    
    test.output();
    at (Place.places(1)) 
    for (var it:int = 0; it <= it_max; it++) {
        if (it % ((it_max+1)/100) == 0) print(" " + it); flush();
        test.exchange(c);
        test.compute();
    }
    println();
    println();
    test.output();
    
    t = now() - t;
    println("time spent (exchange case " + c + ") : " + t);
    println();
    
  }
   
}
//===================================================================

To compile the code, the commands are :

x10c++ -commandlineonly -c test11.x10
g++ -c -I/opt/x10/include -I/opt/x10 -I. -g -DTRANSPORT=sockets -DX10_USE_BDWGC 
-Wno-long-long -Wno-unused-parameter -U___DUMMY___ -msse2 -mfpmath=sse  
test11.cc
g++ -g -pthread -msse2 -mfpmath=sse test11.o -L/opt/x10/lib -lgc -lx10 
-lupcrts_sockets -ldl -lm -lpthread -Wl,-export-dynamic -lrt -o test11.exe
rm test11.o

 
And, to execute it :
mpirun -n 3 ./test11.exe 10000 100

(first parameter is the number of iterations (10000), second is the length of 
rows (100).


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; 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&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to