Discussion:
Errors when running x10 code (separate compilation steps, C++ backend)
(too old to reply)
TAJCHMAN Marc
2009-09-10 22:46:36 UTC
Permalink
Hi,

Can you tell me how to compile my x10 code (C++ backend) using separate generation/compile/link steps ?

If I type :

x10c++ my_test.x10

a binary code (a.out) is produced and can be succesfully run (using manager/launcher)

If I use the following commands :

1> x10c++ -commandlineonly -c my_test.x10
2> g++ -c -I. -I/opt/x10/include my_test.cc
3> g++ my_test.o -L/opt/x10/lib -lx10 -lgc -lupcrts_sockets -lpthread -lrt -ldl -o my_test

compilation/link phases succeed, but when running the my_test code, there is a runtime error (segmentation fault error).

I used X10 v 1.7.6 on a 32bits Ubuntu 9.04 (pgas-1.7.6_linux_x86.tgz, x10-1.7.6_linux_x86.tgz downloaded from the web site)

I guess that I wrongly selected some of the libraries in the linking command (line 3 above) ?

Thanks in advance,
Marc

------------------------------------------------------------------------------------
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:***@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.
Igor Peshansky
2009-09-11 04:08:56 UTC
Permalink
Post by TAJCHMAN Marc
Hi,
Can you tell me how to compile my x10 code (C++ backend) using
separate generation/compile/link steps ?
x10c++ my_test.x10
a binary code (a.out) is produced and can be succesfully run (using
manager/launcher)
1> x10c++ -commandlineonly -c my_test.x10
2> g++ -c -I. -I/opt/x10/include my_test.cc
3> g++ my_test.o -L/opt/x10/lib -lx10 -lgc -lupcrts_sockets -lpthread
-lrt -ldl -o my_test
compilation/link phases succeed, but when running the my_test code,
there is a runtime error (segmentation fault error).
I used X10 v 1.7.6 on a 32bits Ubuntu 9.04 (pgas-1.7.6_linux_x86.tgz,
x10-1.7.6_linux_x86.tgz downloaded from the web site)
I guess that I wrongly selected some of the libraries in the linking
command (line 3 above) ?
Marc,

You can give the option "-report postcompile=1" to x10c++, and it will
print out the exact g++ command it uses to build a.out on your system.
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/)
Marc Tajchman
2009-09-11 13:17:17 UTC
Permalink
Post by Igor Peshansky
Post by TAJCHMAN Marc
Hi,
Can you tell me how to compile my x10 code (C++ backend) using
separate generation/compile/link steps ?
x10c++ my_test.x10
a binary code (a.out) is produced and can be succesfully run (using
manager/launcher)
1> x10c++ -commandlineonly -c my_test.x10
2> g++ -c -I. -I/opt/x10/include my_test.cc
3> g++ my_test.o -L/opt/x10/lib -lx10 -lgc -lupcrts_sockets -lpthread
-lrt -ldl -o my_test
compilation/link phases succeed, but when running the my_test code,
there is a runtime error (segmentation fault error).
I used X10 v 1.7.6 on a 32bits Ubuntu 9.04 (pgas-1.7.6_linux_x86.tgz,
x10-1.7.6_linux_x86.tgz downloaded from the web site)
I guess that I wrongly selected some of the libraries in the linking
command (line 3 above) ?
Marc,
You can give the option "-report postcompile=1" to x10c++, and it will
print out the exact g++ command it uses to build a.out on your system.
Igor
It works !! I used correct libraries, but forgot several compilation and
linking options

Thanks a lot
--
Marc Tajchman
E-mail : ***@cea.fr
Tel. : 01 69 08 73 27
Fax. : 01 69 08 10 87
DEN/DM2S/SFME/LGLS
CEA Saclay, 91191 Gif/Yvette


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.
TAJCHMAN Marc
2009-09-20 10:30:15 UTC
Permalink
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();
}
}
TAJCHMAN Marc
2009-09-21 22:35:01 UTC
Permalink
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:***@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-***@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();
}
}
TAJCHMAN Marc
2009-09-22 22:16:14 UTC
Permalink
Hi,

As I'm doing several tests in X10 and many wrong data placement errors ;-), execution frequently produces output like this :

0.err: Uncaught exception at place 0: x10.lang.BadPlaceException: bad place exception
0.err: x10.lang.BadPlaceException: bad place exception
0.err: at No stacktrace recorded.

Is there a way (compiler option, runtime option, exception catching, other ?) to have more information about the source line were exception occurs, wrong access to which variable, call stack trace, etc ?

Is there a function, macro, ... that can inform where a variable (scalar or component of an array) is located ? UPC for example, has such a function (upc_threadof).



Also, the c++ compiler frequently issue the following warnings :
.../include/x10aux/bootstrap.h:104: warning : format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘x10_int’
.../include/x10aux/bootstrap.h:113: warning : format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘x10_int’
.../include/x10aux/bootstrap.h:126: warning : format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘x10_int’

Normally warnings like these ones are harmless, but one never knows.

For info :
x10c++ version 1.7.6
Polyglot compiler toolkit version 3.1.0 (2009-06-11 14:44:14)
(binary version downloaded from the web site)

gcc/g++ :
Target: i486-linux-gnu
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)

Thanks in advance
Marc

------------------------------------------------------------------------------------
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:***@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: mar. 22/09/2009 00:35
À: x10-***@lists.sourceforge.net
Objet : Transfert between places

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:***@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-***@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();
}
}
Josh Milthorpe
2009-09-23 01:48:16 UTC
Permalink
Hi Marc,

the "No stacktrace" BadPlaceException also caused me trouble and I have
raised as http://jira.codehaus.org/browse/XTENLANG-540

Debugging with GDB should allow you to see where the exception is
thrown. You will need to compile for debugging and then debug each place
as a separate process. There are some instructions at
http://docs.codehaus.org/display/XTENLANG/X10+Application+Development
(right at the end).

In X10 1.7, an object of reference type (any class that inherits from
x10.lang.Ref) has a field "location" which is the Place at which the
object is located.

For distributed arrays, Array.dist(pt: Point) or Array.dist(i0 : Int, i1
: Int, ...) give the Place to which the given Point/index is mapped. For
example
myArray.dist(1,2)

I have also observed the x10c++ warnings, they seem benign but I agree
they should probably be cleaned up at some stage.

Cheers,

Josh
Post by TAJCHMAN Marc
Hi,
0.err: Uncaught exception at place 0: x10.lang.BadPlaceException: bad place exception
0.err: x10.lang.BadPlaceException: bad place exception
0.err: at No stacktrace recorded.
Is there a way (compiler option, runtime option, exception catching, other ?) to have more information about the source line were exception occurs, wrong access to which variable, call stack trace, etc ?
Is there a function, macro, ... that can inform where a variable (scalar or component of an array) is located ? UPC for example, has such a function (upc_threadof).
.../include/x10aux/bootstrap.h:104: warning : format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘x10_int’
.../include/x10aux/bootstrap.h:113: warning : format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘x10_int’
.../include/x10aux/bootstrap.h:126: warning : format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘x10_int’
Normally warnings like these ones are harmless, but one never knows.
x10c++ version 1.7.6
Polyglot compiler toolkit version 3.1.0 (2009-06-11 14:44:14)
(binary version downloaded from the web site)
Target: i486-linux-gnu
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
Thanks in advance
Marc
------------------------------------------------------------------------------------
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
------------------------------------------------------------------------------------
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: mar. 22/09/2009 00:35
Objet : Transfert between places
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
------------------------------------------------------------------------------------
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
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.
- 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&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
https://lists.sourceforge.net/lists/listinfo/x10-users
TAJCHMAN Marc
2009-09-29 22:09:56 UTC
Permalink
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).
Marc Tajchman
2009-09-30 09:22:02 UTC
Permalink
Hi,

I'm trying to investigate mixed X10 - MPI programming
(the aim is to define steps to port an existing MPI program to X10).

The first step could be to rewrite the main program of the MPI program
as a function.
The X10 main program will call this (native) function on each place (by
launching a single activity on each place).

Next steps would port larger parts of the original MPI code to the X10 side.

A first test involving no MPI sends/receives, worked. But execution
frozed when I tried to send messages between MPI processes (under the
carpet from X10 point of vue).

Do you have any experience how to do that ?
(mpi version needed, mixed MPI - threads functionalities, coexistence
between activities - MPI message sending)


Best Regards,
Marc
--
Marc Tajchman
E-mail : ***@cea.fr
Tel. : 01 69 08 73 27
Fax. : 01 69 08 10 87
DEN/DM2S/SFME/LGLS
CEA Saclay, 91191 Gif/Yvette


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.
Igor Peshansky
2009-09-20 13:28:54 UTC
Permalink
Post by TAJCHMAN Marc
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.
- 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
Hi, Marc,

Don't forget that in version 2, t is of a class type, and
thus lives in a particular place (where it was created,
in this case place 0). When you access "A" in the input()
and output() methods, it's really a shorthand for "this.A",
so you are reading a field of an object. Attempting to do
this in any place other than where the object lives will
give you a BPE -- that's expected behavior.

There are a couple of possible solutions. One is to
capture the field value separately from the object, namely:

def init() {
val A = this.A;
finish ateach (val (i): Point in A.dist)
A([i]).init(i);
}

def output() {
val A = this.A;
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("");
}
}
}

Another is to make test8 a value class, which would
enable replication of the object across places.

Hope this helps,
Igor
Post by TAJCHMAN 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();
}
}
--
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/)
Igor Peshansky
2009-09-22 01:06:04 UTC
Permalink
Post by TAJCHMAN Marc
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.
Post by TAJCHMAN Marc
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
Marc,

The preferred idiom in the 1.7 version of the language is to capture
the values in a ValRail and use them inside an "at" (or an "async at").
For example, your transfert() function could look like this:

def transfert() {
val v = at (Place.places(1))
Rail.makeVal[double]((a.dist | here).size(),
(j:Int)=>a(1,j));
for ((i,j) in a.dist | here)
a(i,j) = v(j);
}

This will cause only one round of communication (one message to
place 1, and one reply with the value). Note that the syntax for
array accesses and distribution restriction is somewhat simplified
from what you have below.

The 2.0 version of the language has a System.copyTo() function,
which accomplishes the above a bit more efficiently.
Igor
P.S. X10 also has a no-arg println(), which does the same as
println("").
Post by TAJCHMAN 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");
}
}
--
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/)
Igor Peshansky
2009-09-23 11:53:54 UTC
Permalink
Post by TAJCHMAN Marc
Hi,
As I'm doing several tests in X10 and many wrong data placement errors
bad place exception
0.err: x10.lang.BadPlaceException: bad place exception
0.err: at No stacktrace recorded.
Is there a way (compiler option, runtime option, exception catching,
other ?) to have more information about the source line were exception
occurs, wrong access to which variable, call stack trace, etc ?
The stack trace *is* recorded, but isn't propagated properly across
places, even in SVN HEAD.
See http://jira.codehaus.org/browse/XTENLANG-540 .

One solution is to attach to the process with gdb before the
exception occurs, and set a breakpoint in x10aux::throwException().
This will let you see the stack trace for the invalid access.
You should be able to find the corresponding line of X10 code from
the comments in the generated C++ code.
Post by TAJCHMAN Marc
Is there a function, macro, ... that can inform where a variable
(scalar or component of an array) is located ? UPC for example, has
such a function (upc_threadof).
For any Ref, you can access the "location" property, which is of
type Place. You can get the place id by accessing the "id" property
of that Place value.
Post by TAJCHMAN Marc
.../include/x10aux/bootstrap.h:104: warning : format ‘%ld’ expects
type ‘long int’, but argument 3 has type ‘x10_int’
.../include/x10aux/bootstrap.h:113: warning : format ‘%ld’ expects
type ‘long int’, but argument 3 has type ‘x10_int’
.../include/x10aux/bootstrap.h:126: warning : format ‘%ld’ expects
type ‘long int’, but argument 3 has type ‘x10_int’
Normally warnings like these ones are harmless, but one never knows.
Fixed on the 1.7 branch, and will appear in the next 1.7 series
release.
Post by TAJCHMAN Marc
x10c++ version 1.7.6
Polyglot compiler toolkit version 3.1.0 (2009-06-11 14:44:14)
(binary version downloaded from the web site)
Target: i486-linux-gnu
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
Thanks in advance
Marc
HTH,
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 Product
Loading...