After creating a shared array available to all processees, the array is unavailable unless a fetchfrom is called first. Here is a simple example demonstrating it. (Note, I run it with julia -p 4 test.jl which is why Distributed isn't loaded)
@everywhere using SharedArrays
const arr = SharedArray{Int64, 2}((5,5))
for i in 1:5
arr[i, :] = fill(i, 5)
end
@everywhere function test()
arr[myid(), myid()] = 10
return arr[myid(), :]
end
println(remotecall_fetch(test, 2)) # doesn't work, throws err arr is undefined
@fetchfrom 2 arr
println(remotecall_fetch(test, 2)) # works now
println(remotecall_fetch(test, 3)) # still doesn't work on this worker unless a fetchfrom is called for this processor too
println(arr)
The arrays I'm using are quite big and so running a fetchfrom for each running worker is not very efficient
After creating a shared array available to all processees, the array is unavailable unless a
fetchfrom
is called first. Here is a simple example demonstrating it. (Note, I run it withjulia -p 4 test.jl
which is why Distributed isn't loaded)The arrays I'm using are quite big and so running a fetchfrom for each running worker is not very efficient