Hello again,
I’m doing some test examples in x10 using Thread level parallelism
(one-place implementation). I need some simple synchronization between the
activities, but using clocks I had terrible times.
I’m looking in the concurrent package to test some simpler tools than
clocks, and the only tool that works for me is SPMDBarrier. I’m using this
tool because I don’t know how use the others tools like monitors or
latches, I didn't find good examples of this package.
Does anyone has used this package before? Could someone show me how to use
it?
Regarding SPMDBarrier I have some strange behavior. For example in this
code:
import x10.util.concurrent.SPMDBarrier;
public class Hello {
public static def main(Array[String]) {
var nthreads:Int=3;
val startSignal: SPMDBarrier = new SPMDBarrier(nthreads);
val doneSignal: SPMDBarrier = new SPMDBarrier(nthreads);
var ready: Boolean = false;
var work: Int=0;
finish for (activity in 1..nthreads) async{
startSignal.register();
doneSignal.register();
if(activity == 1){
//Master
for(i in 1..3){
Console.OUT.println("M: let's work...");
work = i;
startSignal.advance();
doneSignal.advance();//waiting workers
Console.OUT.println("M: processing work...");
}
}else{ //Worker(s)
var exit: Boolean = false;
while(!exit){
Console.OUT.println("W "+activity+": Ready");
startSignal.advance();
switch(work){
case 0:
Console.OUT.println("W "+activity+": Nothing to do...");
break;
case 1:
Console.OUT.println("W "+activity+": work 1");
break;
case 2:
Console.OUT.println("W "+activity+": work 2");
break;
case 3:
Console.OUT.println("W "+activity+": Finishing activity");
exit = true;
break;
}
doneSignal.advance();
}
}
}
}
}
When I run this code ($ X10_NTHREADS=3 ./hello), I have sometimes execution
errors (Deadlocks I think). Furthermore when I want to compile with the
optimization flags I get this error:
$ x10c++ -O -NO_CHECKS -o hello Hello.x10
x10c++: Hello.cc: In static member function ‘static void
Hello::main(x10::array::Array<x10::lang::String*>*)’:
Hello.cc:243:73: error: ‘class x10::util::concurrent::SPMDBarrier’ has
no member named ‘__fieldInitializers637’
Hello.cc:263:72: error: ‘class x10::util::concurrent::SPMDBarrier’ has
no member named ‘__fieldInitializers637’
x10c++: Non-zero return code: 1
2 errors.
Could you help me with this?
Regards,
Danny Múnera
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users