Skip to content

Manual: Multi-processing and Distributed Computing #58075

Open
@leespen1

Description

@leespen1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions