Tuesday 15 May 2012

r - Allow foreach workers to register and distribute sub-tasks to other workers -


I have an R code in which many pre-term workers have been included to do some work in parallel. I am using Forkha and Dummim for this purpose. I want every pre-worker worker to recruit some new workers and distribute parts of their code, which is parallel to them.

The current code looks like this:

  Required (DOMC) requirement (Corruption) Register DOMC (Core = 8) Agram (I = (1: 8))% Dopper% {& lt; & Lt; Some code here & gt; & Gt; (C in J (1: 4)) {& lt; & Lt; Here are some other code & gt; & Gt; }}   

I am looking for an ideal code that will look like this:

  is required (DOMC) requirement (foreach) registerDoMC (core) = 8) foreach (I = (1: 8))% dopar% {& lt; & Lt; Some code here & gt; & Gt; Aggression (j = (1: 4))% dopper% {& lt; & Lt; Here are some other code & gt; & Gt; }}   

I have seen an example of multi-parallel parallel using the use of ISNO and DOCM. However, I do not know if he does what I want or not.

Also, it seems that this is not applicable because it needs to merge the two ends, while in my case it is not liked; The second loop only helps in the first one for a part of the code. Please correct me if I am wrong.

Thank you.

There is no special problem inside a foreach loop, with a foreach loop being inside here DOSNOW loop Inside is an example of a DMC loop:

  Library (Dusse) Host & lt; - c ('host-1', 'host-2') cl < - makeSOCKcluster (Host) Register Dosnov (CL) R & LT; - foreach (i = 1: 4, .packages = 'doMC')% dopar% {registerDoMC (2) foreach (j = 1: 8, .combine = 'c')% dopar% I {j}} Stopcluster (CL) )   

I think it is natural to use DOMC for internal loop, but you can do whatever you want. You can also use DSNO for both ends, but then you will need to create and stop the ice cluster inside the external Fortune loop.

Here is an example of using DOMM inside a DPM loop:

  Library (DOMC) Register Dummy (2) R & LT; - foreach (i = 1: 2, .packages = 'doMC')% dopar% {ppid & lt; - Sys.getpid () Register DOMC (2) Foreign Currency (J = 1: 2)% dopar% {c (ppid, Sys.getpid ())}}   

The total six processes are forked by the DOMC package, although only four internal loops execute the body:

  & gt; [[1]] [[1]] [1]] [1] 14 9 46 14 9 4 [[1]] [2]] [1] 14 946 14 9 51 [2]] [2]] [1] [1] 14 9 47 14 9 48 [2]] [2]] [1] 14 9 47 14 9 50   

Of course, you have a lot of nodes Caution is required to not initiate procedures. I found this kind of nestling a bit awkward, which gave birth to the development of the nesting operator.

No comments:

Post a Comment