On 4/2/13 5:06 AM, Danny Munera wrote:
Hello all,
I'm trying to implement an algorithm in parallel. The idea is using
each place as an algorithm independent instance, then, finishing the
program when the first place reaches the solution. So far, I have
something like this:
finish for (p in Place.places()) at(p)async{
sol = parallel_function();
//kill other places
}
Currently, I don't have any idea about how to kill the other place, I
have searched in x10 tutorials, language specification and the API,
and I have not found anything.
Do you have any idea to how to do that?
You don't "kill" a place, you kill the activities running at a place.
Have them periodically check for a variable being set. e.g.
class C {
var killed:Boolean=false;
static def compute() {
val roots= PlaceLocalHandle.make[C](Dist.makeUnique(), ()=> new C());
finish for (p in Place.places()) at(p)async{
sol = roots().parallel_function();
val home =here;
for (p in Place.places() if (home.id != p.id) at(p) async
root().killed=true;
}
}
def parallel_function() {
while (! killed) continueComputing();
// store the result of computing in state on C, now retrieve it
return result();
}
}
------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users