I'm seeing inconsistent results when multiple workers write values to a
SharedArray at the same time, presumably because += isn't atomic. Is this
intended behavior, and is there a workaround? Behavior is reproducible in
0.3.8-pre+22 and 0.3.9.
Sample code:
function doStuff()
result_shared = SharedArray(Int64, (2,), init = S -> S[localindexes(S)] =
0)
@sync for i=1:3
@spawn begin
result_shared[:] += [i, i]
end
end
return sdata(result_shared)
end
> julia -p 3
julia> dump(doStuff())
Array(Int64,(2,)) [3,3]
julia> dump(doStuff())
Array(Int64,(2,)) [6,6]