I think the issue here is that you want define methods (not just the function) on the workers.
I’m not sure how robust this is but it seems to work for your simple example:
function my_func(x)
#println("Calculating my_func($x)")
return x ^ 2
end
using Distributed
addprocs(4)
@everywhere workers() @eval function my_func end
for m in methods(my_func)
@everywhere workers() @eval $m
end
pmap(my_func, 1:100)