Dear Virjay and Krishna,

    Thanks a lot for your replies, but my basic question was how to divide
my region (the one in the for loop) into "P" Equal regions ? as Virjay
showed us, we divided them into "P" async activities, but how divide the
regions to work upon them?

Thank you all.

On Mon, Jul 5, 2010 at 7:45 AM, Vijay Saraswat <vi...@saraswat.org> wrote:

> mohammed elsaeedy wrote:
> > Dear Krishna,
> >
> >
> >       Thank you very much for your reply, and yes it seems very
> convincing,
> > but do you know how to modify my code
> > to be divided to two phases? I mean how to divide the loop part into two
> > parts (which are the 2 threads)
> >
> >
> >
> Suppose you have the program::
>
> finish for ((i) in 0..N-1)
>   async doComputation(i);
>
> where N is very large.  This will spawn N asyncs. Now you only have P
> cores. So you can write this as:
>
> val step = N/P;
> finish for ((p) in 0..P-1)
>   async
>      for ((i) in step*p..step*(p+1)-1)
>           doComputation(i);
>
> This will spawn only P asyncs, but all the original work will get done.
>
> This will give you the same result as the first (but better performance)
> provided that doComputation(i) does not throw any exceptions.
>
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>



-- 
Thank you for your concern.
Regards,
Mohammed El Sayed
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to