Bug in DistributedArrays? Pushing to first local part pushes to all local parts

This behavior is not specific to Distributed, but the way (d)fill operates. From the docstring

If x is an object reference, all elements will refer to the same object:

  julia> A = fill(zeros(2), 2);

  julia> A[1][1] = 42; # modifies both A[1][1] and A[2][1]

  julia> A
  2-element Vector{Vector{Float64}}:
   [42.0, 0.0]
   [42.0, 0.0]
end

Create the array locally first and then distribute

a = distribute([ [] for _ in 1:10 ])

There is no additional overhead since dfill allocates locally first anyway.

1 Like