Is there a way to pass a function to workers? e.g.
using Distributed
addprocs(4)
function my_func(x)
return x ^ 2
end
[send my function to everyone]
pmap(my_func, 1:100)
I recognize I can do something like:
@everywhere begin
function my_func(x)
return x ^ 2
end
end
But since functions are first class objects (right?) seems like I should just be able to pass them around like data.
I tried using ParallelDataTransfer.jl
, as suggested here, but like @gdkrmr I can’t figure it out and the package has no docs.
For example, I tried:
@passobj 1 workers() my_func
But that didn’t seem to work…