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

Manual: Multi-processing and Distributed Computing #58075

Open
leespen1 opened this issue Apr 10, 2025 · 0 comments
Open

Manual: Multi-processing and Distributed Computing #58075

leespen1 opened this issue Apr 10, 2025 · 0 comments
Labels
docs This change adds or pertains to documentation

Comments

@leespen1
Copy link

In the Manual page on Multi-Processing and Distributed Computing (https://docs.julialang.org/en/v1/manual/distributed-computing/#Multi-processing-and-Distributed-Computing), the following code block appears

julia> r = @spawnat :any rand(2,2)
Future(2, 1, 4, nothing)

julia> s = @spawnat :any 1 .+ fetch(r)
Future(3, 1, 5, nothing)

julia> fetch(s)
2×2 Array{Float64,2}:
 1.38854  1.9098
 1.20939  1.57158

Followed by the paragraph

Note that we used 1 .+ fetch(r) instead of 1 .+ r. This is because we do not know where the code will run, so in general a fetch might be required to move r to the process doing the addition. In this case, @spawnat is smart enough to perform the computation on the process that owns r, so the fetch will be a no-op (no work is done).

Is it really true that the computation is done on the process that owns r? Based on the two Futures returned, it looks to me like the random matrix is created by process 2 (so that process 2 owns r), and the addition is done by process 3.

@nsajko nsajko added the docs This change adds or pertains to documentation label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

2 participants