You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case the `init` function only needs to call `fill` with the
@@ -268,7 +268,7 @@ SPMD, i.e., a Single Program Multiple Data mode is implemented by submodule `Dis
268
268
269
269
The same block of code is executed concurrently on all workers using the `spmd` function.
270
270
271
-
```julia
271
+
```
272
272
# define foo() on all workers
273
273
@everywhere function foo(arg1, arg2)
274
274
....
@@ -314,7 +314,7 @@ Example
314
314
315
315
This toy example exchanges data with each of its neighbors `n` times.
316
316
317
-
```julia
317
+
```
318
318
using Distributed
319
319
using DistributedArrays
320
320
addprocs(8)
@@ -383,7 +383,7 @@ Nested `spmd` calls
383
383
As `spmd` executes the the specified function on all participating nodes, we need to be careful with nesting `spmd` calls.
384
384
385
385
An example of an unsafe(wrong) way:
386
-
```julia
386
+
```
387
387
function foo(.....)
388
388
......
389
389
spmd(bar, ......)
@@ -401,7 +401,7 @@ spmd(foo,....)
401
401
In the above example, `foo`, `bar` and `baz` are all functions wishing to leverage distributed computation. However, they themselves may be currenty part of a `spmd` call. A safe way to handle such a scenario is to only drive parallel computation from the master process.
402
402
403
403
The correct way (only have the driver process initiate `spmd` calls):
404
-
```julia
404
+
```
405
405
function foo()
406
406
......
407
407
myid()==1 && spmd(bar, ......)
@@ -418,7 +418,7 @@ spmd(foo,....)
418
418
```
419
419
420
420
This is also true of functions which automatically distribute computation on DArrays.
0 commit comments