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

Transfer of distributed structs when members are accessed #203

Open
raminammour opened this issue May 7, 2019 · 1 comment
Open

Transfer of distributed structs when members are accessed #203

raminammour opened this issue May 7, 2019 · 1 comment

Comments

@raminammour
Copy link
Contributor

Hello,

Consider the following example:

@everywhere struct SS1
    v::Vector{Float64}
    m::Vector{Float64}
end
dSS=@DArray [SS1(rand(10),i*ones(10)) for i in 1:10]
dSS2=@DArray [SS1(rand(10^6),i*ones(10)) for i in 1:10];

@time dSS[2].m
@time dSS2[2].m;

  0.004819 seconds (81 allocations: 4.094 KiB)
  0.005085 seconds (210 allocations: 7.634 MiB)

As you see, the whole struct gets serialized (7 mb) and then v (small vector) can be accessed. Is there a way to implement this so that dS[2].v is sent without the whole struct.

Put in another way, is there a generic way to have dS[i].m mean something like getm(dS,i) where:

@everywhere function getm(dS,i)
    indi=DistributedArrays.locate(dS,i)
    pidi=procs(dS)[indi...]
    lindi=i-dS.cuts[1][indi...]+1
    @fetchfrom pidi dS[:L][lindi].m
end

Is this possible? Is it a reasonable feature to ask for :)?

Thanks!

@raminammour raminammour changed the title Serialization of distributed structs Transfer of distributed structs when members are accessed May 9, 2019
@jishnub
Copy link

jishnub commented Oct 5, 2020

dSS[2].m gets lowered to getproperty(dSS[2], :m), where the first argument is necessarily fetched before evaluation. Perhaps there could be a macro that could evaluate an expression on the host and return the result? Eg. @fetchfromhost dSS[2].m that would wrap the expression in something like getm.

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