I am using Distributed.jl
and DistributedArrays.jl
to write code that runs in parallel and I want to make a certain struct available to all processes, because they all need to (only) read from it several times every time I call a function remotely.
I.e. I have
using DistributedArrays
struct A
[...]
end
struct B
[...]
end
struct MyType
a::A
Db::DArray{B,1,Array{B,1}}
end
function f(a::A, Db::DArray{B,1,Array{B,1}})
do_something_to_b(a, Db[:L])
end
a = A([...]); b1 = B([...]); b2 = B([...])
M = MyType(a, distribute([b1,b2]))
for i in 1:N
SPMD.spmd(f, M.a, M.Db, pids=workers())
end
This way it works, however, I suppose that a
is copied to all the workers N
times, instead of just once.
How can I make it more efficient?