Skip to content

Commit

Permalink
Make usage of foo clearer (JuliaLang#22317)
Browse files Browse the repository at this point in the history
Replaces the placeholder `foo` with the built-in `norm` to make sure the example works when typed into a julia program.

Thanks to Avik Sengupta for the text and for all the commenters on https://discourse.julialang.org/t/what-does-foo-in-the-parallel-computing-docs-refer-to/4182 for making this happen.
  • Loading branch information
bluesmoon authored and JeffBezanson committed Jun 13, 2017
1 parent 95bf00d commit 1574aa0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions doc/src/manual/parallel-computing.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,15 @@ snippet:

```julia-repl
A = rand(10,10)
remotecall_fetch(()->foo(A), 2)
remotecall_fetch(()->norm(A), 2)
```

In this case [`norm`](@ref) is a function that takes 2D array as a parameter, and MUST be defined in
the remote process. You could use any function other than `norm` as long as it is defined in the remote
process and accepts the appropriate parameter.

Note that `A` is a global variable defined in the local workspace. Worker 2 does not have a variable called
`A` under `Main`. The act of shipping the closure `()->foo(A)` to worker 2 results in `Main.A` being defined
`A` under `Main`. The act of shipping the closure `()->norm(A)` to worker 2 results in `Main.A` being defined
on 2. `Main.A` continues to exist on worker 2 even after the call `remotecall_fetch` returns. Remote calls
with embedded global references (under `Main` module only) manage globals as follows:

Expand All @@ -276,9 +280,9 @@ with embedded global references (under `Main` module only) manage globals as fol

```julia
A = rand(10,10)
remotecall_fetch(()->foo(A), 2) # worker 2
remotecall_fetch(()->norm(A), 2) # worker 2
A = rand(10,10)
remotecall_fetch(()->foo(A), 3) # worker 3
remotecall_fetch(()->norm(A), 3) # worker 3
A = nothing
```

Expand Down

0 comments on commit 1574aa0

Please sign in to comment.