Hi there,

I got non-deterministic behaviour with the code appended. Compiling the program with the c++ backend and starting it with 2 as parameter results almost always in the expected output:

$ ./DPEExample 2
Place(0): Sending to Place(1).
Place(0): waiting.
Place(0): Place(1) has answered. Ending.
Place(1): received message from Place(0).
Place(1): Sending to Place(2).
Place(1): waiting.
Place(1): Place(2) has answered. Ending.
Place(1): resetting Place(0).
Place(2): received message from Place(1).
Place(2): Sending to Place(3).
Place(2): waiting.
Place(2): Place(3) has answered. Ending.
Place(2): resetting Place(1).
Place(3): received message from Place(2).
Place(3): resetting Place(2).
Place 1 exited unexpectedly with exit code: 1
Place(0): caught multiple exceptions, size = 2
Place(0): Place(1) died. Resetting Place(0).
Place(0): Place(1) died. Resetting Place(0).
END.
$

Starting the same program with 3 as parameter, however, freezes the program most of the time:

$ ./DPEExample 3
Place(0): Sending to Place(1).
Place(0): waiting.
Place(0): Place(1) has answered. Ending.
Place(1): received message from Place(0).
Place(1): Sending to Place(2).
Place(1): waiting.
Place(1): Place(2) has answered. Ending.
Place(1): resetting Place(0).
Place(2): received message from Place(1).
Place(2): Sending to Place(3).
Place(2): waiting.
Place(2): Place(3) has answered. Ending.
Place(2): resetting Place(1).
Place(3): received message from Place(2).
Place(3): resetting Place(2).

[program freezes here]

Compiling the program with the java backend changes the behaviour:
- Starting with 2 as parameter: ~50% of all runs show the "correct" (first) behaviour, rest freezes - Starting with 3 as parameter resulted for me always in a freeze (second behaviour)

Environment-variables used:
export X10_NPLACES=4
export X10_NTHREADS=1
export X10_STATIC_THREADS=true
export X10_RESILIENT_MODE=1
export X10_RESILENT_NODE_ZERO=1

gcc used: 4.8.2
java used: openJDK 1.7.0_55

Unsetting X10_STATIC_THREADS seems to fix the problem.
Am I doing something fundamentally wrong or is this a bug? Might it be related to Bug #3368 (http://jira.codehaus.org/browse/XTENLANG-3368)?

Cheers and thanks in advance,

Marco
import x10.util.GrowableRail;
import x10.compiler.*;

public class DPEExample {

   @x10.compiler.Volatile transient var waiting:Boolean = false;
   
   def this() {}
   
   def send(to:Place, crash:Long, plh:PlaceLocalHandle[DPEExample]):void
   {
       if (here.isLast()) { return; }
       waiting = true;
       val me:Place = here;
       Console.OUT.println(here + ": Sending to " + to + ".");
       at (to) async plh().receive(me, crash, plh);
       Console.OUT.println(here + ": waiting.");
       Console.OUT.println(here + ": " + to + " has answered. Ending.");
   }
   
   def processException(val e:Exception, val 
plh:PlaceLocalHandle[DPEExample]):void
   {
       if (e instanceof DeadPlaceException)
       {
           val died:Place = (e as DeadPlaceException).place;
           val toReset:Place = died.prev();
           Console.OUT.println(here + ": " + died + " died. Resetting " + 
toReset + ".");
           at (toReset) async plh().waiting = false;
       }
       else if (e instanceof MultipleExceptions)
       {
           val exceptions:Rail[Exception]
               = (e as MultipleExceptions).exceptions();
           Console.OUT.println(here + ": caught multiple exceptions, size = " + 
exceptions.size);
           for (val ex:Exception in exceptions) 
           { this.processException(ex, plh); }
       }
       else { Console.OUT.println(here + ": " + e); }
   }
   
   def receive(from:Place, crash:Long, plh:PlaceLocalHandle[DPEExample]):void
   {
       if (Runtime.hereLong() == crash)
       { at (here.prev()) async System.killHere(); }
       Console.OUT.println(here + ": received message from " + from + ".");
       send(here.next(), crash, plh);
       Console.OUT.println(here + ": resetting " + from + ".");
       at (from) { plh().waiting = false; }
   }
   
   public static def main(args:Rail[String]):void
   {
       plh:PlaceLocalHandle[DPEExample]
           = PlaceLocalHandle.makeFlat[DPEExample](PlaceGroup.WORLD
                                                   , () => new DPEExample());
       try
       {
           finish { async plh().send(here.next(), Long.parse(args(0)), plh); }
       }
       catch (e:Exception) { plh().processException(e, plh); }
       Console.OUT.println("END.");
   }

}
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to