JuliaLang / JuliaLang/Distributed.jl
global constant not automatically transferred along with function call
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 55
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
After creating a shared array available to all processees, the array is unavailable unless a fetchfrom is called first. Here is a simple example demonstrating it. (Note, I run it with julia -p 4 test.jl which is why Distributed isn't loaded)
@everywhere using SharedArrays
const arr = SharedArray{Int64, 2}((5,5))
for i in 1:5
arr[i, :] = fill(i, 5)
end
@everywhere function test()
arr[myid(), myid()] = 10
return arr[myid(), :]
end
println(remotecall_fetch(test, 2)) # doesn't work, throws err arr is undefined
@fetchfrom 2 arr
println(remotecall_fetch(test, 2)) # works now
println(remotecall_fetch(test, 3)) # still doesn't work on this worker unless a fetchfrom is called for this processor too
println(arr)
The arrays I'm using are quite big and so running a fetchfrom for each running worker is not very efficient
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the example in test.jl with julia -p 4 and trace how @everywhere, SharedArray, remotecall_fetch, and @fetchfrom handle the global constant on each worker. Done means test() works on workers 2 and 3 without calling fetchfrom separately for each worker, while preserving the reported shared-array behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100