Task Class Reference
HiCR
|
#include <task.hpp>
Public Types | |
enum | callback_t { onTaskExecute , onTaskSuspend , onTaskFinish , onTaskSync } |
using | taskCallbackMap_t = HiCR::tasking::CallbackMap< Task *, callback_t > |
Public Member Functions | |
__INLINE__ | Task (std::shared_ptr< HiCR::ExecutionUnit > executionUnit, taskCallbackMap_t *callbackMap=nullptr) |
__INLINE__ void | setCallbackMap (taskCallbackMap_t *callbackMap) |
__INLINE__ taskCallbackMap_t * | getCallbackMap () |
__INLINE__ void | sendSyncSignal () |
__INLINE__ const HiCR::ExecutionState::state_t | getState () |
__INLINE__ void | setExecutionUnit (std::shared_ptr< HiCR::ExecutionUnit > executionUnit) |
__INLINE__ std::shared_ptr< HiCR::ExecutionUnit > | getExecutionUnit () const |
__INLINE__ void | initialize (std::unique_ptr< HiCR::ExecutionState > executionState) |
__INLINE__ void | run () |
__INLINE__ void | suspend () |
Detailed Description
This class defines the basic execution unit managed by a task-based runtime system.
It includes a function to execute, an internal state, and an callback map that triggers callbacks (if defined) whenever a state transition occurs.
The function represents the entire lifetime of the task. That is, a task executes a single function, the one provided by the user, and will reach a terminated state after the function is fully executed.
A task may be suspended before the function is fully executed. This is either by voluntary yielding, or by reaching an synchronous operation that prompts it to suspend. These two suspension reasons will result in different states.
Member Typedef Documentation
◆ taskCallbackMap_t
Type definition for the task's callback map
Member Enumeration Documentation
◆ callback_t
Enumeration of possible task-related callbacks that can trigger a user-defined function callback
Constructor & Destructor Documentation
◆ Task()
|
inline |
Constructor for the task class. It requires a user-defined function to execute The task is considered finished when the function runs to completion.
- Parameters
-
[in] executionUnit Specifies the function/kernel to execute. [in] callbackMap Pointer to the callback map callbacks to be called by the task
Member Function Documentation
◆ getCallbackMap()
|
inline |
Gets the task's callback map.
- Returns
- A pointer to the task's an callback map. NULL, if not defined.
◆ getExecutionUnit()
|
inline |
Returns the execution unit assigned to this task
- Returns
- The execution unit assigned to this task
◆ getState()
|
inline |
Queries the task's internal state.
- Returns
- The task internal state
◆ initialize()
|
inline |
Implements the initialization routine of a task, that stores and initializes the execution state to run to completion
- Parameters
-
[in] executionState A previously initialized execution state
◆ run()
|
inline |
This function starts running a task. It needs to be performed by a worker, by passing a pointer to itself.
The execution of the task will trigger change of state from initialized to running. Before reaching the terminated state, the task might transition to some of the suspended states.
◆ sendSyncSignal()
|
inline |
Sends a sync signal, triggering the associated callback
◆ setCallbackMap()
|
inline |
Sets the task's callback map. This map will be queried whenever a state transition occurs, and if the map defines a callback for it, it will be executed.
- Parameters
-
[in] callbackMap A pointer to an callback map
◆ setExecutionUnit()
|
inline |
Sets the execution unit assigned to this task
- Parameters
-
[in] executionUnit The execution unit to assign to this task
◆ suspend()
|
inline |
This function yields the execution of the task, and returns to the worker's context.
The documentation for this class was generated from the following file:
- /home/runner/work/HiCR/HiCR/include/hicr/frontends/tasking/task.hpp
Generated by