File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 71
71
```
72
72
73
73
In this code we have job interdependence. Firstly, we are calculating the
74
- standard deviation ` σ ` and than we are using that value in the function ` f ` .
75
- Since ` Dagger.@spawn ` yields an ` DTask ` rather than actual values, we need
74
+ standard deviation ` σ ` , and then we are using that value in the function ` f ` .
75
+ Since ` Dagger.@spawn ` yields a ` DTask ` rather than actual values, we need
76
76
to use the ` fetch ` function to obtain those values. In this example, the value
77
77
fetching is performed once all computations are completed (note that ` @sync `
78
78
preceding the loop forces the loop to wait for all jobs to complete). Also,
@@ -84,3 +84,9 @@ The above use case scenario has been tested by running `julia -t 8` (or with
84
84
` JULIA_NUM_THREADS=8 ` as environment variable). The ` Threads.@threads ` code
85
85
takes 1.8 seconds to run, while the Dagger code, which is also one line
86
86
shorter, runs around 0.9 seconds, resulting in a 2x speedup.
87
+
88
+ !!! warning
89
+ Annotating an inner loop with ` @sync ` will block the outer loop from
90
+ iterating until the inner ` @sync ` loop is fully completed, negating some
91
+ potential parallelism. ` @sync ` should only be applied to the outermost loop
92
+ before a ` fetch ` .
You can’t perform that action at this time.
0 commit comments