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

make shared array constructor consistent to array constructor #29930

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Roger-luo
Copy link
Contributor

@Roger-luo Roger-luo commented Nov 4, 2018

I'm not sure if this init is still needed? can we just provide it with fill interface?

Why do we need a init function in the constructor?

  • use undef for uninitialized SharedArray, but preserve the init keyword (you need it for files)
  • similar should return SharedArray

@Roger-luo Roger-luo changed the title WIP: make shared array constructor consistent to array constructor RFC: make shared array constructor consistent to array constructor Nov 5, 2018
@Roger-luo Roger-luo changed the title RFC: make shared array constructor consistent to array constructor WIP: make shared array constructor consistent to array constructor Nov 5, 2018
@Roger-luo Roger-luo changed the title WIP: make shared array constructor consistent to array constructor make shared array constructor consistent to array constructor Nov 5, 2018
@StefanKarpinski
Copy link
Sponsor Member

Not sure who the best person to review SharedArray code is. @mbauman do you know? This looks fairly straightforward to me but I'm not certain.

@fredrikekre fredrikekre added the kind:deprecation This change introduces or involves a deprecation label Nov 5, 2018
@mbauman
Copy link
Sponsor Member

mbauman commented Nov 5, 2018

Unfortunately the similar part here was tried before (#12560) but it ran into many difficulties in practice and ended up getting reverted (#12964).

@Roger-luo
Copy link
Contributor Author

Roger-luo commented Nov 5, 2018

@mbauman What about return SharedArray for similar and have a new method that return a similar data?

So in my case, I tried to implement something with generic array type, which allows me to run either on multiprocess with SharedArray shares the data, or on a single process with simple Array, CuArray, etc. And then I'll need some consistent method to construct the array.

I currently have to work around this like:

_similar(xs...; kwargs...) = similar(xs...; kwargs...)

_similar(S::SharedArray, T::Type, dims::Dims{N}; pids=S.pids) where N = SharedArray{T, N}(dims; pids=pids)
_similar(S::SharedArray{ST, N}, T::Type; pids=S.pids) where {ST, N} = _similar(S, T, size(S); pids=pids)
_similar(S::SharedArray, dims::Dims; pids=S.pids) = _similar(S, eltype(S), dims; pids=pids)
_similar(S::SharedArray; pids=S.pids) = _similar(S, eltype(S), size(S); pids=pids)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:deprecation This change introduces or involves a deprecation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants