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
When called, it creates an `EagerThunk` (also known as a "thunk" or "task")
14
-
object representing a call to function `f` with the arguments `args`. If it is
15
-
called with other thunks as inputs, such as in `Dagger.@spawn f(Dagger.@spawn
16
-
g())`, then the function `f` gets passed the results of those input thunks. If
17
-
those thunks aren't yet finished executing, then the execution of `f` waits on
18
-
all of its input thunks to complete before executing.
14
+
object representing a call to function `f` with the arguments `args` and
15
+
keyword arguments `kwargs`. If it is called with other thunks as args/kwargs,
16
+
such as in `Dagger.@spawn f(Dagger.@spawn g())`, then the function `f` gets
17
+
passed the results of those input thunks, once they're available. If those
18
+
thunks aren't yet finished executing, then the execution of `f` waits on all of
19
+
its input thunks to complete before executing.
19
20
20
21
The key point is that, for each argument to a thunk, if the argument is an
21
22
`EagerThunk`, it'll be executed before this node and its result will be passed
22
23
into the function `f`. If the argument is *not* an `EagerThunk` (instead, some
23
24
other type of Julia object), it'll be passed as-is to the function `f`.
24
25
25
-
Thunks don't accept regular keyword arguments for the function `f`. Instead,
26
-
the `options` kwargs are passed to the scheduler to control its behavior:
26
+
The `Options` struct in the second argument position is optional; if provided,
27
+
it is passed to the scheduler to control its behavior. `Options` contains a
28
+
`NamedTuple` of option key-value pairs, which can be any of:
27
29
- Any field in `Dagger.Sch.ThunkOptions` (see [Scheduler and Thunk options](@ref))
28
30
-`meta::Bool` -- Pass the input `Chunk` objects themselves to `f` and not the value contained in them
29
31
30
-
There are also some extra kwargs that can be passed, although they're considered advanced options to be used only by developers or library authors:
32
+
There are also some extra optionss that can be passed, although they're considered advanced options to be used only by developers or library authors:
31
33
-`get_result::Bool` -- return the actual result to the scheduler instead of `Chunk` objects. Used when `f` explicitly constructs a Chunk or when return value is small (e.g. in case of reduce)
32
34
-`persist::Bool` -- the result of this Thunk should not be released after it becomes unused in the DAG
33
35
-`cache::Bool` -- cache the result of this Thunk such that if the thunk is evaluated again, one can just reuse the cached value. If it’s been removed from cache, recompute the value.
@@ -133,18 +135,18 @@ via `@par` or `delayed`. The above computation can be executed with the lazy
133
135
API by substituting `@spawn` with `@par` and `fetch` with `collect`:
134
136
135
137
```julia
136
-
p =@paradd1(4)
137
-
q =@paradd2(p)
138
-
r =@paradd1(3)
139
-
s =@parcombine(p, q, r)
138
+
p =Dagger.@paradd1(4)
139
+
q =Dagger.@paradd2(p)
140
+
r =Dagger.@paradd1(3)
141
+
s =Dagger.@parcombine(p, q, r)
140
142
141
143
@assertcollect(s) ==16
142
144
```
143
145
144
146
or similarly, in block form:
145
147
146
148
```julia
147
-
s =@parbegin
149
+
s =Dagger.@parbegin
148
150
p =add1(4)
149
151
q =add2(p)
150
152
r =add1(3)
@@ -159,7 +161,7 @@ operation, you can call `compute` on the thunk. This will return a `Chunk`
159
161
object which references the result (see [Chunks](@ref) for more details):
160
162
161
163
```julia
162
-
x =@par1+2
164
+
x =Dagger.@par1+2
163
165
cx =compute(x)
164
166
cx::Chunk
165
167
@assertcollect(cx) ==3
@@ -207,7 +209,7 @@ Scheduler options can be constructed and passed to `collect()` or `compute()`
207
209
as the keyword argument `options` for lazy API usage:
208
210
209
211
```julia
210
-
t =@par1+2
212
+
t =Dagger.@par1+2
211
213
opts = Dagger.Sch.SchedulerOptions(;single=1) # Execute on worker 1
212
214
213
215
compute(t; options=opts)
@@ -221,10 +223,9 @@ Thunk options can be passed to `@spawn/spawn`, `@par`, and `delayed` similarly:
0 commit comments