Thanks Vijay,
It works great!!!
Danny Múnera
On Tue, Apr 2, 2013 at 7:28 PM, Vijay Saraswat <vi...@saraswat.org> wrote:
> On 4/2/13 1:07 PM, Danny Munera wrote:
>
> Hello Vijay,
>
> Thank you for your fast reply.
>
> I have implemented the code that you send me, but I have yet another
> problem. Because, regardless of the number of threads that I have in each
> place (X10_NTHERADS), the first async task (with the parallel function)
> ends first than the async task with the kill variable update. Then, the
> algorithm always waits for the end in all places.
>
> I guess that is how the x10 activities scheduler works, unfortunately
> with this behavior I don't have any speedup with the parallelism.
>
> You should probably call Runtime.probe() in between the computing
> calls, thus. This will give the runtime an opportunity to run and handle
> incoming asyncs, such as the one that will set killed to true.
>
> Note that in general one must be careful when calling Runtime.probe(). At
> this time any incoming activity may be scheduled. If you have written your
> code already in such a way that your data structures are safe even if there
> are other concurrent activities then you should not have a problem.
>
> 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();
>
> Runtime.probe();
> }
> // store the result of computing in state on C, now retrieve it
> return result();
> }
> }
>
>
> An example of code using Runtime.probe is in the UTS application in the
> benchmarks directory:
>
> http://x10.svn.sourceforge.net/viewvc/x10/benchmarks/trunk/PERCS/UTS/
>
> Best,
> Vijay
>
>
> Is there a way for this part of the code creates a priority async task?
>
> for (p in Place.places() if (home.id != p.id) at(p) async
> root().killed=true;
>
> Regards,
>
> Danny Múnera
>
>
> On Tue, Apr 2, 2013 at 1:04 PM, Vijay Saraswat <vi...@saraswat.org> wrote:
>
>> 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();
>> }
>> }
>>
>>
>>
>
>
> ------------------------------------------------------------------------------
> 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
>
>
------------------------------------------------------------------------------
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