16#include <tbb/task_arena.h>
17#include <tbb/task_group.h>
18#include <oneapi/tbb/task_arena.h>
19#include <oneapi/tbb/concurrent_hash_map.h>
38 class GlobalTaskGroup :
public ::oneapi::tbb::task_group {
40 GlobalTaskGroup() : task_group() {}
57 GlobalTaskGroup globalTaskGroup;
59 #if !defined(SharedTBBExtension) and !defined(TBB_USE_TASK_GROUP_PREVIEW)
61 static ::oneapi::tbb::dynamic_task_graph taskGraph(globalTaskGroup);
116 ::tbb::task_group taskGroup;
117 for (
auto& p : tasks) {
118 taskGroup.run([&tasks, p]() ->
void {
128void tarch::multicore::native::waitForTasks(
const std::set<TaskNumber>& inDependencies) {
129 #if !defined(SharedTBBExtension) and !defined(TBB_USE_TASK_GROUP_PREVIEW)
130 ::oneapi::tbb::task_handle* handle = new ::oneapi::tbb::task_handle(
131 globalTaskGroup.defer(
144 taskHandleRepository.addDependencies( handle, inDependencies );
146 logDebug(
"waitForTasks(std::set)",
"run new TBB helper task and wait immediately" );
147 #if !defined(SharedTBBExtension) and !defined(TBB_USE_TASK_GROUP_PREVIEW)
149 globalTaskGroup.run_and_wait( handle );
151 taskGraph.put( *handle );
152 taskGraph.wait( *handle );
155 logDebug(
"waitForTasks(std::set)",
"TBB helper task complete, so free handle" );
160void tarch::multicore::native::waitForAllTasks() {
161 #if !defined(SharedTBBExtension) and !defined(TBB_USE_TASK_GROUP_PREVIEW)
163 taskGraph.wait_for_all();
166 globalTaskGroup.wait();
170void tarch::multicore::native::spawnTask(
172 const std::set<TaskNumber>& inDependencies,
173 const TaskNumber& taskNumber
175 #if !defined(SharedTBBExtension) and !defined(TBB_USE_TASK_GROUP_PREVIEW)
176 ::oneapi::tbb::task_handle* handle = new ::oneapi::tbb::task_handle(
177 globalTaskGroup.defer(
201 taskHandleRepository.addDependency( handle, taskNumber );
202 taskHandleRepository.addDependencies( handle, inDependencies );
204 #if !defined(SharedTBBExtension) and !defined(TBB_USE_TASK_GROUP_PREVIEW)
206 globalTaskGroup.run( handle );
208 taskGraph.put( *handle );
211 if (taskNumber==NoOutDependencies) {
215 taskHandleRepository.registerTask(handle, taskNumber);
#define logDebug(methodName, logMacroMessageStream)
tarch::logging::Log _log("::")
Simple utility class around dynamic task graphs to work with integer task numbers.
Represents one node in task graph.
void wait(MPI_Request &request, const std::string &fullQualifiedClassName, const std::string &functionName)
Wrapper around MPI_Wait.
void spawnAndWaitAsTaskLoop(const std::vector< tarch::multicore::Task * > &tasks)
Map onto native tasking.
std::string toString(const std::set< TaskNumber > &taskNumbers)
Construct string representation.