Peano
Loading...
Searching...
No Matches
FusableTasksQueue.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5
6#include "tarch/logging/Log.h"
10
11
12#include <map>
13#include <unordered_set>
14
15
16namespace tarch {
17 namespace multicore {
18 namespace taskfusion {
22 }
23 }
24}
25
26
79 public:
80 static constexpr int AnyTask = -1;
81
83
85 ~FusableTasksQueue() = default;
87
96 void insertReadyTask( Task* task, int taskNumber );
97
104
115
124 std::pair< TaskNumber, Task* > extractFirstReadyTask( TaskNumber handlingTask );
125
129 Task* extractReadyTask( TaskNumber taskNumber, TaskNumber handlingTask );
130
131 void runningTaskFinished( TaskNumber taskNumber );
132
134
154 void updateTaskFusionProbabilities( bool triggerFusion );
155
156 std::pair< TaskNumber, Task* > extractReadyTask( TaskNumber handlingTask );
157
162 static constexpr bool UseTryLockAndReturnTrueIfLockFailed = true;
163 static constexpr bool LockQueueAndReturnReliableResult = false;
164
166 int taskNumber,
167 bool tryLock
168 );
169
171 int taskNumber,
172 bool tryLock
173 );
174
175 int getType() const;
176
189 private:
191
192 const int _type;
193
198 using ReadyTasks = std::map< int, tarch::multicore::Task* >;
199
204 using RunningTasks = std::map< int, int >;
205
210
215
218
222};
Log Device.
Definition Log.h:516
Abstract super class for a job.
Definition Task.h:21
Represents a queue of fusable tasks.
void drainReadyTasks()
Drain all the ready tasks.
tarch::timing::GlidingAverageMeasurement _probabilityThatTaskIsCompleted
ReadyTasks _readyTasks
Tasks that are ready to go.
std::pair< TaskNumber, Task * > extractFirstReadyTask(TaskNumber handlingTask)
Get first ready task.
static constexpr bool UseTryLockAndReturnTrueIfLockFailed
Can be used with the queries below if you prefer those names over the boolean values.
std::map< int, tarch::multicore::Task * > ReadyTasks
Each task in the queue is identified through a pointer to the task plus a task (dependency) number.
bool isTaskReadyOrRunning(int taskNumber, bool tryLock)
std::pair< TaskNumber, Task * > extractReadyTask(TaskNumber handlingTask)
TaskNumber getTaskHandlingRunningTask(TaskNumber taskNumber)
TaskNumber getFirstReadyTaskNumber()
Return number of first ready task.
std::map< int, int > RunningTasks
Map fusable task (number) onto the number of the ProcessReadyTask which actually handles them.
tarch::multicore::BooleanSemaphore _readyTasksSemaphore
void updateTaskFusionProbabilities(bool triggerFusion)
Update the internal stats.
void insertReadyTask(Task *task, int taskNumber)
Insert a new ready task into the local queues.
tarch::multicore::BooleanSemaphore _statisticsSemaphore
RunningTasks _runningTasks
Tasks that are currently running.
static const std::string SizeOfFusableTaskQueueStatisticsIdentifier
int getNumberOfReadyTasks()
Query the number of ready tasks.
Task * extractReadyTask(TaskNumber taskNumber, TaskNumber handlingTask)
Extract specific ready task.
tarch::multicore::BooleanSemaphore _runningTasksSemaphore
tarch::timing::GlidingAverageMeasurement _numberOfReadyTasksPerProcessTaskExecution
void runningTaskFinished(TaskNumber taskNumber)
FusableTasksQueue(const FusableTasksQueue &)=delete
bool isTaskReady(int taskNumber, bool tryLock)
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:19