I use doMC
with foreach
and % dopar%
. Function:
doTheMath_MC & lt; - function (st, end, nd) {print (getDoParWorkers ()) if (st & gt; end) stop ("end st") #helper function stackoverflow.com/a/23158178/633251 tr & lt; - Function (x, prec = 0) trunc (x * 10 ^ prec) / 10 ^ Exact #ForicafFIFF & lt; - Function to use with function (I, j, num, trpi) {if (num [j]> gt; = num [i]) return (zero) val & lt; - num [i] / num [j] if (! Tr (val, nd) == trpi) return (null) returns (c (i, j, tr (wal, nd))}} # we go here ... ND & LT; - ND - 1 TRPI & lt; - TR (PI, ND) No. - St: end ni & lt; - Length (num) ans & lt; - foreach (i = 1: Ni, .combine = rbind)%:% foreach (j = 1: ny, .combine = rbind)% dopar% (If.null) (feet (i, j, num, trpi)} cat ("full computing ", Paste (" EST ", St, End, ND + 1, Sep =" _ ")," \ n "(Ans) Returns (NULL) ans - as.matrix (na.omit (ans) ) # Maybe not necessary in MC version I have set the first core and second one The function calls upwards function (answer) # c ("num", "den", "est", "eff")}
(This information has been posted below , I do not think this is a problem). getDoParWorkers ()
reports that 7 cores are assigned. cat
statement confirms that the output While moving 2 'loops' are working properly, however, only 1 core is used, why does anyone see? Mac OSX 10.10.2 and R 3.2 (2015-03-15 R67992) Finally, Do everything Rit to using doParallel
to get the same results.
Steps to set up all things:
mn & lt; - 1 mx & lt; - 10000 JMP & LT; - 1000 mc & amp; nbsp; Lt; - TRUE If (MC) {Requirement ("DOMC") register DOMC (7)} ST & lt; - CEC (MN-1, MX-JMP, JMP) + 1and Lieutenant; - CEC (MN - 1 + JMP, MX, JMP) ND & amp; Lt; - Representative (1:15, each = MX / JMP) # Recycling DF & lt; - Data for frames (st = cents, and = end, see id) = nd) (1 in i: no (df)) {aests (df $ cents [ii], df $ and [ii], DF $ nd [ii], mc = mc}}
Sorry to answer! I have changed the Dopaar
handling, from which the external loop is made parallel:
ans & lt; - foreach (i = 1: ni, .combine = rbind)% for dopark% (j in 1: ni) {fef (i, j, num, trpi)}
and , I was just not asking for enough iterations. For testing, I was using mx = 10000
and jmp = 1000
(see original question). This was probably not enough to trigger parallel processing. It was necessary to increase every 10x to go parallel processing. Thanks for the commentators!
Note: While activating the above code parallel processing, it does not respond properly. This will be the subject of another question.
No comments:
Post a Comment