Consider the following simple example, where we try to fill a view of a SharedArray on a worker (I’ve tested it on julia 1.1.0):
using Distributed
w = addprocs(1)[]
using SharedArrays
function idid!(v)
for i=1:length(v)
v[i] = i
end
end
sha = SharedArray{Float64}(10)
shav = @view sha[1:5]
@spawnat w idid!(shav)
sha
The result that we get is:
sha
10-element SharedArray{Float64,1}:
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
As we see, nothing happens, which implies that when a view of a SharedArray is passed to another worker, the underlying storage get somehow copied.
Is it an intended behaviour?
I would rather think that it is more logical to have a view of a SharedArray be also shared.