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

Setting remote values #182

Closed
r-barnes opened this issue Oct 1, 2018 · 4 comments
Closed

Setting remote values #182

r-barnes opened this issue Oct 1, 2018 · 4 comments

Comments

@r-barnes
Copy link
Contributor

r-barnes commented Oct 1, 2018

Based on the following tests:

@everywhere using DistributedArrays
ras    = [@spawnat p rand(30,30) for p in workers()[1:4]]
ras    = reshape(ras,(2,2))
D      = DArray(ras)
D[1,1] = 5
m1     = @spawnat 2 D[:L][2,2] = 5 #Works
m2     = @spawnat 2 D[2,2] = 5     #Doesn't work
fetch(m1)
fetch(m2)

It looks as though DArrays offers view-only access to non-local portions of the array and write access only to local portions. Is that correct?

Any thoughts on how to set remote values?

@vchuravy
Copy link
Member

vchuravy commented Oct 1, 2018

Yes see #155 for the reasoning behind it.

I = (2,2)
chidx = locate(D, I...)
idxs = d.indices[chidx...]
localidx = ntuple(i -> (I[i] - first(idxs[i]) + 1), ndims(d))
pid = d.pids[chidx...]

remote_call(pid, D, localidx, data) do D, I, data
     localpart(D)[localidx...] = data
end

Which if your data is not a scalar should be reasonable efficient.
This is based of

function getindex_tuple(d::DArray{T}, I::Tuple{Vararg{Int}}) where T
and might need some adjustment to deal with slices.
function makelocal(A::DArray{<:Any, <:Any, AT}, I::Vararg{Any, N}) where {N, AT}
does that and so we should probably factor those parts out.

@r-barnes
Copy link
Contributor Author

r-barnes commented Oct 1, 2018

Got it. I'm planning to use DArray with SparseArrays to form a large binary matrix representing the frontier of a breadth-first search, so I can send the index updates en masse after each round provided I know where to send them. I can figure that out based on the snippet you provided.

@r-barnes r-barnes closed this as completed Oct 1, 2018
@vchuravy
Copy link
Member

vchuravy commented Oct 1, 2018

We now have DistributedArrays.allowscalar(false) so I think we could add setindex! in general and optimise the batch case.

@r-barnes
Copy link
Contributor Author

Per my other post, I'm worried about communication delays, so I'm thinking about bulk exchange of halos now.

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

2 participants