I am writing a package where at some point a big loop appears.
What is the proper way to allow using the Distributed.jl
package to replace map
by pmap
?
- Should we do like that:
module MyPackage
using Distributed
### code
fit_function() = pmap(long function)
### code
export fit_function
end
and then
using MyPackage
fit_function()
when we are using personal laptop with no multiprocessor.
On a cluster
using Distributed
@everywhere using MyPackage
addproc!(10)
fit_function()
- is there another preferable architecture like two different packages with/without
Distributed
pmap
/map
? - maybe always do
using Distributed
but defining two functionsfit_function()
withpmap
and another onepfit_function()
withpmap
.
What is the best way to go in terms of
- “code”
- Julia spirtit,
- Dependency,
- Performances (from what I recall
pmap
was slightly longer thanmap
when used on one proc).