X10 - Segmentation fault with multi-Places

115 views Asked by At

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.

1

There are 1 answers

0
Josh Milthorpe On

Places in X10 are numbered from 0 to Place.MAX_PLACES, so the for loop should be indexed as

finish for(var i:Int=0;i<4;i++){

However, it's usually a bad idea to write code that depends on a particular number of places. Much better would be:

finish for (place in Place.places()) {
    val k = 1;
    at(place) async count(k);
}

This will work for any number of places.

Notice I also switched the order of async at - it's more efficient to use at(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...