I have a module , my_module.jl, which includes functions that I would like to use with pmap. Currently, I have tried to execute this like:
addprocs(4)
include("my_module.jl")
@everywhere function pmap_f(x)
return my_module.g(x)^2
end
xvals = [[x] for x in linspace(0,1)];
gvals = pmap(pmap_f, xvals)
rmprocs(workers())
But this just ends up generating an error that my_module not found in the current path. Can someone offer some guidance about the correct way to set up such a script?
I make all of my projects into a custom module, and softlink (ln -s in linux) the development directory into ~/.julia/v0.6 so it shows up as a directory alongside the packages that I’ve loaded from the official sources. Then for parallel I just need to @everywhere using MyModule .
There are subtle differences between using and include, and usually my needs are met with using. The other big benefit with using is that Revise.jl will keep it up to date, at least in the main worker.