Skip to content

Commit b6d8562

Browse files
docs: Define Datadeps example functions with @everywhere
The functions `add!`, `inc!`, `inc_upper!`, `inc_ulower!`, and `inc_diag!` in `docs/src/datadeps.md` are example functions. To ensure they work correctly in distributed environments when used with Dagger.jl, they need to be defined everywhere. This change prepends `@everywhere` to their definitions in the documentation.
1 parent 481f093 commit b6d8562

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/src/datadeps.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concrete:
1515
A = rand(1000)
1616
B = rand(1000)
1717
C = zeros(1000)
18-
add!(X, Y) = X .+= Y
18+
@everywhere add!(X, Y) = X .+= Y
1919
Dagger.spawn_datadeps() do
2020
Dagger.@spawn add!(InOut(B), In(A))
2121
Dagger.@spawn copyto!(Out(C), In(B))
@@ -118,7 +118,7 @@ A_l = view(A, 1:500)
118118
A_r = view(A, 501:1000)
119119

120120
# inc! supports views, so we can pass A_l and A_r directly
121-
inc!(X) = X .+= 1
121+
@everywhere inc!(X) = X .+= 1
122122

123123
Dagger.spawn_datadeps() do
124124
# These two tasks don't alias, so they can run in parallel
@@ -137,9 +137,9 @@ from how that argument is accessed within the function. This is done with the
137137
```julia
138138
A = rand(1000, 1000)
139139

140-
inc_upper!(X) = UpperTriangular(X) .+= 1
141-
inc_ulower!(X) = UnitLowerTriangular(X) .+= 1
142-
inc_diag!(X) = X[diagind(X)] .+= 1
140+
@everywhere inc_upper!(X) = UpperTriangular(X) .+= 1
141+
@everywhere inc_ulower!(X) = UnitLowerTriangular(X) .+= 1
142+
@everywhere inc_diag!(X) = X[diagind(X)] .+= 1
143143

144144
Dagger.spawn_datadeps() do
145145
# These two tasks don't alias, so they can run in parallel

0 commit comments

Comments
 (0)