@@ -9,10 +9,12 @@ Create an auto task in the runtime.
99- `id`: The local task identifier.
1010"""
1111function create_task (rt:: CxxPtr{Runtime} , lib:: Library , id:: LocalTaskID )
12- LegateInternal. create_auto_task (rt, lib, id)
12+ impl = LegateInternal. create_auto_task (rt, lib, id)
13+ return AutoTask (impl)
1314end
1415function create_task (rt:: CxxPtr{Runtime} , lib:: Library , id:: LocalTaskID , domain:: Domain )
15- LegateInternal. create_manual_task (rt, lib, id, domain)
16+ impl = LegateInternal. create_manual_task (rt, lib, id, domain)
17+ return ManualTask (impl)
1618end
1719
1820"""
2123
2224Submit an manual/auto task to the runtime.
2325"""
24- submit_task (rt:: CxxPtr{Runtime} , task:: AutoTask ) = begin
26+ function submit_task (rt:: CxxPtr{Runtime} , task:: AutoTask )
2527 # Update High Water Mark for UFI tracking
26- # MAX_SUBMITTED_TASK_ID bridges the gap until the first variant starts in C++
27- Threads. atomic_max! (MAX_SUBMITTED_TASK_ID, LAST_CREATED_TASK_ID[])
28+ Threads. atomic_max! (MAX_SUBMITTED_TASK_ID, Int (LAST_CREATED_TASK_ID[]))
2829
29- # Use @threadcall to avoid blocking the Julia thread while Legate processes the submission.
30- @threadcall ((:legate_submit_auto_task , Legate. WRAPPER_LIB_PATH), Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}), rt. cpp_object, task. cpp_object)
30+ @threadcall ((:legate_submit_auto_task , Legate. WRAPPER_LIB_PATH), Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}), rt. cpp_object, task. impl. cpp_object)
3131end
32- submit_task (rt:: CxxPtr{Runtime} , task:: ManualTask ) = begin
32+ function submit_task (rt:: CxxPtr{Runtime} , task:: ManualTask )
3333 Threads. atomic_max! (MAX_SUBMITTED_TASK_ID, Int (LAST_CREATED_TASK_ID[]))
34- @threadcall ((:legate_submit_manual_task , Legate. WRAPPER_LIB_PATH), Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}), rt. cpp_object, task. cpp_object)
34+
35+ @threadcall ((:legate_submit_manual_task , Legate. WRAPPER_LIB_PATH), Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}), rt. cpp_object, task. impl. cpp_object)
3536end
3637
3738"""
7374Add a constraint to the task.
7475"""
7576function add_constraint (task:: AutoTask , c:: Constraint )
76- LegateInternal. add_constraint (task, c)
77+ LegateInternal. add_constraint (task. impl , c)
7778end
7879
7980"""
@@ -84,30 +85,29 @@ Add a logical array/store as an input to the task.
8485"""
8586function add_input (
8687 task:: Union{AutoTask,ManualTask} ,
87- item:: Union{LogicalArray,LogicalStore} ,
88- )
89- LegateInternal. add_input (task, item. handle)
88+ item:: LogicalArray{T, N} ,
89+ ) where {T, N}
90+ push! (task. arg_types, Array{T, N})
91+ LegateInternal. add_input (task. impl, item. handle)
9092end
9193
92- """
93- add_output(AutoTask, LogicalArray) -> Variable
94- add_output(ManualTask, LogicalStore) -> Variable
95-
96- Add a logical array/store as an output of the task.
97- """
9894function add_output (
9995 task:: Union{AutoTask,ManualTask} ,
100- item:: Union{LogicalArray,LogicalStore} ,
101- )
102- LegateInternal. add_output (task, item. handle)
96+ item:: LogicalArray{T, N} ,
97+ ) where {T, N}
98+ push! (task. arg_types, Array{T, N})
99+ LegateInternal. add_output (task. impl, item. handle)
103100end
104101
105- """
106- add_scalar(AutoTask, scalar::Scalar)
107- add_scalar(ManualTask, scalar::Scalar)
102+ function add_scalar (task:: Union{AutoTask,ManualTask} , scalar:: ScalarImpl )
103+ # Note: We don't easily have the Julia type here unless we wrap Scalar.
104+ # For now, we rely on the MTW in ufi_poll if this is missing.
105+ # But often Julia tasks are created via wrap_task which does MTW.
106+ LegateInternal. add_scalar (task. impl, scalar)
107+ end
108108
109- Add a scalar argument to the task.
110- """
111- function add_scalar (task:: Union{AutoTask,ManualTask} , scalar :: Scalar )
112- LegateInternal. add_scalar (task, scalar )
109+ # Specialized add_scalar to capture type for precompile
110+ function add_scalar (task :: Union{AutoTask,ManualTask} , x :: T ) where {T <: SUPPORTED_TYPES }
111+ push! (task. arg_types, T )
112+ LegateInternal. add_scalar (task. impl, Scalar (x) )
113113end
0 commit comments