I'm completely new to the X10 language and I tried the following code and I get a segmentation fault when using more than one Place. I get the same error when running X10's Monte Carlo sample with more than one Place. I am using X10 version 2.3 on a 64bit Debian Linux on a Core i7 2Ghz processor.
import x10.util.Timer;
public class placetest{
public static def main(args: Array[String](1)){
finish for(var i:Int=1;i<=4;i++){
val ii = i;
val pk = Place.place(ii);
val k = 1;
async at(pk) count(k);
}
Console.OUT.println("Finished");
}
public static def count(i:Int){
Console.OUT.println("Test" + i);
}
}
This only happens when I send a parameter to the count function.
Any help is greatly appreciated.
Places in X10 are numbered from 0 to Place.MAX_PLACES, so the for loop should be indexed as
However, it's usually a bad idea to write code that depends on a particular number of places. Much better would be:
This will work for any number of places.
Notice I also switched the order of
async at
- it's more efficient to useat(p) async
as this does not create a separate activity at the current place.Are you sure it is the same error on the Monte Carlo integration sample? Seg faults have many causes...