Skip to content

Commit c01e4af

Browse files
committed
Add metadata to EagerThunk
1 parent 541c3bd commit c01e4af

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
99
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1010
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1111
MemPool = "f9f48841-c794-520a-933b-121f7ba6ed94"
12+
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
1213
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
1314
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1415
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"

src/eager_thunk.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ end
3636
Options(;options...) = Options((;options...))
3737
Options(options...) = Options((;options...))
3838

39+
"""
40+
EagerThunkMetadata
41+
42+
Represents some useful metadata pertaining to an `EagerThunk`:
43+
- `return_type::Type` - The inferred return type of the task
44+
"""
45+
mutable struct EagerThunkMetadata
46+
return_type::Type
47+
end
48+
3949
"""
4050
EagerThunk
4151
@@ -46,9 +56,11 @@ be `fetch`'d or `wait`'d on at any time.
4656
mutable struct EagerThunk
4757
uid::UInt
4858
future::ThunkFuture
59+
metadata::EagerThunkMetadata
4960
finalizer_ref::DRef
5061
thunk_ref::DRef
51-
EagerThunk(uid, future, finalizer_ref) = new(uid, future, finalizer_ref)
62+
EagerThunk(uid, future, metadata, finalizer_ref) =
63+
new(uid, future, metadata, finalizer_ref)
5264
end
5365

5466
Base.isready(t::EagerThunk) = isready(t.future)

src/submission.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,22 @@ function eager_process_options_submission_to_local(id_map, options::NamedTuple)
217217
return options
218218
end
219219
end
220+
function EagerThunkMetadata(spec::EagerTaskSpec)
221+
f = chunktype(spec.f).instance
222+
arg_types = ntuple(i->chunktype(spec.args[i][2]), length(spec.args))
223+
return_type = Base._return_type(f, Base.to_tuple_type(arg_types))
224+
return EagerThunkMetadata(return_type)
225+
end
226+
chunktype(t::EagerThunk) = t.metadata.return_type
220227
function eager_spawn(spec::EagerTaskSpec)
221228
# Generate new EagerThunk
222229
uid = eager_next_id()
223230
future = ThunkFuture()
231+
metadata = EagerThunkMetadata(spec)
224232
finalizer_ref = poolset(EagerThunkFinalizer(uid); device=MemPool.CPURAMDevice())
225233

226234
# Return unlaunched EagerThunk
227-
return EagerThunk(uid, future, finalizer_ref)
235+
return EagerThunk(uid, future, metadata, finalizer_ref)
228236
end
229237
function eager_launch!((spec, task)::Pair{EagerTaskSpec,EagerThunk})
230238
# Lookup EagerThunk -> ThunkID

0 commit comments

Comments
 (0)