Task Class Reference

HiCR: HiCR::tasking::Task Class Reference
HiCR
HiCR::tasking::Task Class Reference

#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_tgetCallbackMap ()
 
__INLINE__ void sendSyncSignal ()
 
__INLINE__ const HiCR::ExecutionState::state_t getState ()
 
__INLINE__ void setExecutionUnit (std::shared_ptr< HiCR::ExecutionUnit > executionUnit)
 
__INLINE__ std::shared_ptr< HiCR::ExecutionUnitgetExecutionUnit () 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

Enumerator
onTaskExecute 

Triggered as the task starts or resumes execution

onTaskSuspend 

Triggered as the task is preempted into suspension by an asynchronous callback

onTaskFinish 

Triggered as the task finishes execution

onTaskSync 

Triggered as the task receives a sync signal (used for mutual exclusion mechanisms)

Constructor & Destructor Documentation

◆ Task()

__INLINE__ HiCR::tasking::Task::Task ( std::shared_ptr< HiCR::ExecutionUnit executionUnit,
taskCallbackMap_t callbackMap = nullptr 
)
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]executionUnitSpecifies the function/kernel to execute.
[in]callbackMapPointer to the callback map callbacks to be called by the task

Member Function Documentation

◆ getCallbackMap()

__INLINE__ taskCallbackMap_t * HiCR::tasking::Task::getCallbackMap ( )
inline

Gets the task's callback map.

Returns
A pointer to the task's an callback map. NULL, if not defined.

◆ getExecutionUnit()

__INLINE__ std::shared_ptr< HiCR::ExecutionUnit > HiCR::tasking::Task::getExecutionUnit ( ) const
inline

Returns the execution unit assigned to this task

Returns
The execution unit assigned to this task

◆ getState()

__INLINE__ const HiCR::ExecutionState::state_t HiCR::tasking::Task::getState ( )
inline

Queries the task's internal state.

Returns
The task internal state

◆ initialize()

__INLINE__ void HiCR::tasking::Task::initialize ( std::unique_ptr< HiCR::ExecutionState executionState)
inline

Implements the initialization routine of a task, that stores and initializes the execution state to run to completion

Parameters
[in]executionStateA previously initialized execution state

◆ run()

__INLINE__ void HiCR::tasking::Task::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__ void HiCR::tasking::Task::sendSyncSignal ( )
inline

Sends a sync signal, triggering the associated callback

◆ setCallbackMap()

__INLINE__ void HiCR::tasking::Task::setCallbackMap ( taskCallbackMap_t callbackMap)
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]callbackMapA pointer to an callback map

◆ setExecutionUnit()

__INLINE__ void HiCR::tasking::Task::setExecutionUnit ( std::shared_ptr< HiCR::ExecutionUnit executionUnit)
inline

Sets the execution unit assigned to this task

Parameters
[in]executionUnitThe execution unit to assign to this task

◆ suspend()

__INLINE__ void HiCR::tasking::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