|
Peano
|
Represents a queue of fusable tasks. More...
#include <FusableTasksQueue.h>

Public Member Functions | |
| FusableTasksQueue (int type_) | |
| ~FusableTasksQueue ()=default | |
| FusableTasksQueue (const FusableTasksQueue &)=delete | |
| void | insertReadyTask (Task *task, int taskNumber) |
| Insert a new ready task into the local queues. | |
| void | drainReadyTasks () |
| Drain all the ready tasks. | |
| TaskNumber | getFirstReadyTaskNumber () |
| Return number of first ready task. | |
| std::pair< TaskNumber, Task * > | extractFirstReadyTask (TaskNumber handlingTask) |
| Get first ready task. | |
| Task * | extractReadyTask (TaskNumber taskNumber, TaskNumber handlingTask) |
| Extract specific ready task. | |
| void | runningTaskFinished (TaskNumber taskNumber) |
| TaskNumber | getTaskHandlingRunningTask (TaskNumber taskNumber) |
| void | updateTaskFusionProbabilities (bool triggerFusion) |
| Update the internal stats. | |
| std::pair< TaskNumber, Task * > | extractReadyTask (TaskNumber handlingTask) |
| bool | isTaskReadyOrRunning (int taskNumber, bool tryLock) |
| bool | isTaskReady (int taskNumber, bool tryLock) |
| int | getType () const |
| int | getNumberOfReadyTasks () |
| Query the number of ready tasks. | |
Static Public Attributes | |
| static constexpr int | AnyTask = -1 |
| static const std::string | SizeOfFusableTaskQueueStatisticsIdentifier |
| static constexpr bool | UseTryLockAndReturnTrueIfLockFailed = true |
| Can be used with the queries below if you prefer those names over the boolean values. | |
| static constexpr bool | LockQueueAndReturnReliableResult = false |
Private Types | |
| using | ReadyTasks = std::map< int, tarch::multicore::Task* > |
| Each task in the queue is identified through a pointer to the task plus a task (dependency) number. | |
| using | RunningTasks = std::map< int, int > |
| Map fusable task (number) onto the number of the ProcessReadyTask which actually handles them. | |
Private Attributes | |
| const int | _type |
| ReadyTasks | _readyTasks |
| Tasks that are ready to go. | |
| RunningTasks | _runningTasks |
| Tasks that are currently running. | |
| tarch::multicore::BooleanSemaphore | _readyTasksSemaphore |
| tarch::multicore::BooleanSemaphore | _runningTasksSemaphore |
| tarch::multicore::BooleanSemaphore | _statisticsSemaphore |
| tarch::timing::GlidingAverageMeasurement | _numberOfReadyTasksPerProcessTaskExecution |
| tarch::timing::GlidingAverageMeasurement | _probabilityThatTaskIsCompleted |
Static Private Attributes | |
| static tarch::logging::Log | _log |
Represents a queue of fusable tasks.
Each queue object is tied to one particular task type. We can query this type via getType().
The task queue does not implement a particular task fusion strategy, but is a mere tool used by various strategies. The documentation of tarch::multicore::orchestration::FusionImplementation provides an overview of these strategies. That means: the queue itself offers a small set of operations, which is really all the tools you need to actually construct a fusion. The different strategies then differ in the way they use these operations, the order how they invoke them, and so forth.
The queue distinguishes three different task states: pending, ready and running. When we insert a task, we label it as either pending (with incoming dependencies which are not yet fulfilled) or ready. If the tasking subsystem manages to fullfill the in-dependencies of a pending task, it is the responsibility of the task system to move the task within the queue from pending to running through a call to movePendingTaskIntoReadyTaskQueue().
If tasks are starting to run, we have to label them as running as well. There are no routines for this, as the task queue is always paired up with instances of ProcessOneReadyTask or ProcessSetOfReadyTasks. See remark on the queue usage below.
We hand over a task to the task queue either by inserting it directly into the task queue, or by telling the queue that a previously pending task has now become ready. After that, we have given up ownership of this fusable task. The ownership resides within the queue.
However, we can construct instances of ProcessOneReadyTask and ProcessSetOfReadyTasks over the task queue. They are responsible for the lifecycle management within the queue and allow us to work with the tasks that we have dumped into it.
The decision when or which of these two tasks to construct over the queue is influenced by the queue's status, as well as by our chosen task fusion strategy. All strategies handle the tasks within the queue by constructing new tasks of type ProcessOneReadyTask and ProcessSetOfReadyTasks over the task queue. If they wait for any of these tasks immediately, we have blocking semantics. As we issue the tasks in certain orders and quantities, we can construct various task processing patterns.
Definition at line 78 of file FusableTasksQueue.h.
|
private |
Each task in the queue is identified through a pointer to the task plus a task (dependency) number.
Definition at line 198 of file FusableTasksQueue.h.
|
private |
Map fusable task (number) onto the number of the ProcessReadyTask which actually handles them.
Definition at line 204 of file FusableTasksQueue.h.
| tarch::multicore::taskfusion::FusableTasksQueue::FusableTasksQueue | ( | int | type_ | ) |
|
default |
|
delete |
| void tarch::multicore::taskfusion::FusableTasksQueue::drainReadyTasks | ( | ) |
Drain all the ready tasks.
This routine is used by tarch::multicore::taskfusion::processAllReadyTasks().
| std::pair< TaskNumber, Task * > tarch::multicore::taskfusion::FusableTasksQueue::extractFirstReadyTask | ( | TaskNumber | handlingTask | ) |
Get first ready task.
Takes the ready task out of the queue and also leaves an entry that handlingTask will handle this task.
| std::pair< TaskNumber, Task * > tarch::multicore::taskfusion::FusableTasksQueue::extractReadyTask | ( | TaskNumber | handlingTask | ) |
| Task * tarch::multicore::taskfusion::FusableTasksQueue::extractReadyTask | ( | TaskNumber | taskNumber, |
| TaskNumber | handlingTask ) |
Extract specific ready task.
| TaskNumber tarch::multicore::taskfusion::FusableTasksQueue::getFirstReadyTaskNumber | ( | ) |
Return number of first ready task.
This routine gives you the number of the first ready task in the queue, or it returns tarch::multicore::NoOutDependencies if there's no task left. Even if you get a valid entry, there's no guarantee that this task still remains in the queue. Some ProcessSetOfReadyTasks instance might have grabbed it straight after this routine returned.
| int tarch::multicore::taskfusion::FusableTasksQueue::getNumberOfReadyTasks | ( | ) |
Query the number of ready tasks.
In principle, we would be fine with making this routine not thread-safe, i.e. we could accept if it returned a value smaller than the actual size. However, such an unsafe version confuses the thread sanitizer, and I'm also not sure if there could be further knock-on effects, so I eventually decided to make the routine thread-safe.
As we employ a sempahore internally, the routine cannot be const.
| TaskNumber tarch::multicore::taskfusion::FusableTasksQueue::getTaskHandlingRunningTask | ( | TaskNumber | taskNumber | ) |
| int tarch::multicore::taskfusion::FusableTasksQueue::getType | ( | ) | const |
| void tarch::multicore::taskfusion::FusableTasksQueue::insertReadyTask | ( | Task * | task, |
| int | taskNumber ) |
Insert a new ready task into the local queues.
Is used by run() but we might also want to use it externally. Before we insert the actual task, we also remove the task's completedTaskNumbers, so noone thinks ahead of time that we are done already.
| bool tarch::multicore::taskfusion::FusableTasksQueue::isTaskReady | ( | int | taskNumber, |
| bool | tryLock ) |
| bool tarch::multicore::taskfusion::FusableTasksQueue::isTaskReadyOrRunning | ( | int | taskNumber, |
| bool | tryLock ) |
| void tarch::multicore::taskfusion::FusableTasksQueue::runningTaskFinished | ( | TaskNumber | taskNumber | ) |
| void tarch::multicore::taskfusion::FusableTasksQueue::updateTaskFusionProbabilities | ( | bool | triggerFusion | ) |
Update the internal stats.
This routine updates the internal statistics tied to the queue, and if there's a complete data set, it also dumps the stats into whoever will listen.
We obviously need to lock _statisticsSemaphore as we write into the statistics. But we also need to lock _readyTasksSemaphore as we read out the queue size.
| triggerFusion | If this is true, we have just triggered the fusion. If it is false however, then it means that we skip any fusion, as our task of interest has finished already. |
|
staticprivate |
Definition at line 190 of file FusableTasksQueue.h.
|
private |
Definition at line 220 of file FusableTasksQueue.h.
|
private |
Definition at line 221 of file FusableTasksQueue.h.
|
private |
Tasks that are ready to go.
Definition at line 209 of file FusableTasksQueue.h.
|
private |
Definition at line 216 of file FusableTasksQueue.h.
|
private |
Tasks that are currently running.
Definition at line 214 of file FusableTasksQueue.h.
|
private |
Definition at line 217 of file FusableTasksQueue.h.
|
private |
Definition at line 219 of file FusableTasksQueue.h.
|
private |
Definition at line 192 of file FusableTasksQueue.h.
Referenced by dastgen2.attributes.UserDefinedType.UserDefinedType::get_methods(), dastgen2.attributes.UserDefinedType.UserDefinedType::get_native_MPI_type(), dastgen2.attributes.UserDefinedType.UserDefinedType::get_plain_C_attributes(), exahype2.dslhype.SyntaxTree.TCustom::is_nested_memref(), exahype2.dslhype.SyntaxTree.Argument::print_cpp(), exahype2.dslhype.SyntaxTree.TCustom::print_cpp(), exahype2.dslhype.SyntaxTree.TCustom::print_mlir(), exahype2.dslhype.SyntaxTree.Argument::print_omp(), exahype2.dslhype.SyntaxTree.TCustom::print_omp(), exahype2.dslhype.SyntaxTree.Argument::print_sycl(), exahype2.dslhype.SyntaxTree.TCustom::print_sycl(), and exahype2.dslhype.SyntaxTree.TCustom::print_tree().
|
staticconstexpr |
Definition at line 80 of file FusableTasksQueue.h.
|
staticconstexpr |
Definition at line 163 of file FusableTasksQueue.h.
|
static |
Definition at line 82 of file FusableTasksQueue.h.
|
staticconstexpr |
Can be used with the queries below if you prefer those names over the boolean values.
Makes it clearer what a function does.
Definition at line 162 of file FusableTasksQueue.h.