Skip to content

Commit ebdfda4

Browse files
committed
Add metadata to EagerThunk
1 parent 080d7bc commit ebdfda4

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1313
MemPool = "f9f48841-c794-520a-933b-121f7ba6ed94"
14+
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
1415
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
1516
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1617
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

src/dtask.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ end
3939
Options(;options...) = Options((;options...))
4040
Options(options...) = Options((;options...))
4141

42+
"""
43+
DTaskMetadata
44+
45+
Represents some useful metadata pertaining to a `DTask`:
46+
- `return_type::Type` - The inferred return type of the task
47+
"""
48+
mutable struct DTaskMetadata
49+
return_type::Type
50+
end
51+
4252
"""
4353
DTask
4454
@@ -50,9 +60,11 @@ more details.
5060
mutable struct DTask
5161
uid::UInt
5262
future::ThunkFuture
63+
metadata::DTaskMetadata
5364
finalizer_ref::DRef
5465
thunk_ref::DRef
55-
DTask(uid, future, finalizer_ref) = new(uid, future, finalizer_ref)
66+
67+
DTask(uid, future, metadata, finalizer_ref) = new(uid, future, metadata, finalizer_ref)
5668
end
5769

5870
const EagerThunk = DTask

src/submission.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,27 @@ function eager_process_options_submission_to_local(id_map, options::NamedTuple)
218218
return options
219219
end
220220
end
221+
222+
function DTaskMetadata(spec::DTaskSpec)
223+
f = chunktype(spec.f).instance
224+
arg_types = ntuple(i->chunktype(spec.args[i][2]), length(spec.args))
225+
return_type = Base.promote_op(f, arg_types...)
226+
return DTaskMetadata(return_type)
227+
end
228+
221229
function eager_spawn(spec::DTaskSpec)
222230
# Generate new DTask
223231
uid = eager_next_id()
224232
future = ThunkFuture()
233+
metadata = DTaskMetadata(spec)
225234
finalizer_ref = poolset(DTaskFinalizer(uid); device=MemPool.CPURAMDevice())
226235

227236
# Create unlaunched DTask
228-
return DTask(uid, future, finalizer_ref)
237+
return DTask(uid, future, metadata, finalizer_ref)
229238
end
239+
240+
chunktype(t::DTask) = t.metadata.return_type
241+
230242
function eager_launch!((spec, task)::Pair{DTaskSpec,DTask})
231243
# Assign a name, if specified
232244
eager_assign_name!(spec, task)

0 commit comments

Comments
 (0)