Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All localparts of DArray are updated when only one is specified #238

Open
jsbryaniv opened this issue Apr 8, 2022 · 1 comment
Open

Comments

@jsbryaniv
Copy link

I ran into an issue when running this block of code:

using Distributed
if nprocs() == 1
    addprocs()
end
@everywhere using DistributedArrays

a = dfill([], 20)
@sync @distributed for i in 1:20
  b = (i, myid())
  push!(localpart(a)[1], b)
end

a

I would expect a to be

[(1,2), (2,2), (3,2)]
[]
[]
[(4, 3), (5, 3), (6, 3)]
[]
⋮

because I am only pushing to the first local part of a. But what I get is this:

[(1, 2), (2, 2), (3, 2)]
 [(1, 2), (2, 2), (3, 2)]
 [(1, 2), (2, 2), (3, 2)]
 [(4, 3), (5, 3), (6, 3)]
 [(4, 3), (5, 3), (6, 3)]
 ⋮
 [(17, 8), (18, 8)]
 [(17, 8), (18, 8)]
 [(19, 9), (20, 9)]
 [(19, 9), (20, 9)]

It seems that i am pushing to all local parts of a, not just the first one.

@jsbryaniv
Copy link
Author

A simpler minimal working example is this:

using Distributed
addprocs(4)
@everywhere using DistributedArrays

a = dfill([], 10)

s = @spawnat 2 push!(localpart(a)[1], 999)

a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant