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
Distributedpmap/map? - maybe always do
using Distributedbut defining two functionsfit_function()withpmapand another onepfit_function()withpmap.
What is the best way to go in terms of
- “code”
- Julia spirtit,
- Dependency,
- Performances (from what I recall
pmapwas slightly longer thanmapwhen used on one proc).