r - parallel computing of a function with doSMP on Windows -
I am trying to multicore a function (in Windows), at which point, another workhorse function (function Calls within the function). Here's the least work example, you'll need a doSMP
and revoIPC
package (to get them, see the rhythm post).
func1 & lt; - Function (x) {Sqrt (x)} func2 & lt; - Function (y) {func1 (y)} Library (doSMP) wrk & lt; - startworkers (worker coat = 4) # I have 4 cores, so register your specs register dosmg (wrk) obj result and lieutenant; The above routine does not work, but if I do nest func1
func2 - foreach (i = 1: 10000)% dopar% func2 (i)
func2
- Function (y) {func1 & lt; - Function (x) {sqrt (x)} func1 (y)}
The process goes through easily (as far as I can tell).
How do I call a function from the outside with % dopar%
?
This looks like a scoping issue
Your func1
call is known in the workspace but the calculation is not on the node, there are solutions for this, e.g. A complete widget is entitled in the package.
Comments
Post a Comment