Peano
Loading...
Searching...
No Matches
tarch::multicore::orchestration::Strategy Class Referenceabstract

Interface for any task orchestration. More...

#include <Strategy.h>

Inheritance diagram for tarch::multicore::orchestration::Strategy:

Data Structures

struct  FuseInstruction
 Fuse instruction. More...
 

Public Types

enum class  ExecutionPolicy { RunSerially , RunParallel }
 Provide hint of execution policy. More...
 

Public Member Functions

virtual ~Strategy ()=default
 
virtual void startBSPSection (int nestedParallelismLevel)=0
 Notifies the strategy that we enter a BSP section.
 
virtual void endBSPSection (int nestedParallelismLevel)=0
 Notifies the strategy that we leave a BSP (fork-join) section.
 
virtual void updateFuseStatistics (int taskType, int queueSize, double averageNumberOfPendingReadyTasksPerProcessTaskExecution, double probabilityThatTaskIsCompleted)=0
 Update task fusion status.
 
virtual FuseInstruction fuse (int taskType)=0
 How many tasks to fuse and to which device to deploy.
 
virtual ExecutionPolicy paralleliseForkJoinSection (int nestedParallelismLevel, int numberOfTasks, int taskType)=0
 Determine how to handle/realise parallelisation within fork/join region.
 

Static Public Attributes

static constexpr int EndOfBSPSection = -1
 

Detailed Description

Interface for any task orchestration.

There are multiple orchestration strategies implementing this interface and hence guiding the task execution pattern. You can create those and make them live by calling tarch::multicore::setOrchestration().

Please consult the operation fuse() and its result type, FuseInstruction, for details on the exact decision process.

Definition at line 36 of file Strategy.h.

Member Enumeration Documentation

◆ ExecutionPolicy

Provide hint of execution policy.

See also
tarch::multicore::spawnAndWait() for rationale and details re the BSP sections of the code.
tarch::multicore::taskfusion for some remarks how the policies implemented through a strategy affect the task fusion.
The page Multicore programming for generic documentation on the design of the whole multicore component.
Enumerator
RunSerially 
RunParallel 

Definition at line 48 of file Strategy.h.

Constructor & Destructor Documentation

◆ ~Strategy()

virtual tarch::multicore::orchestration::Strategy::~Strategy ( )
virtualdefault

Member Function Documentation

◆ endBSPSection()

virtual void tarch::multicore::orchestration::Strategy::endBSPSection ( int nestedParallelismLevel)
pure virtual

Notifies the strategy that we leave a BSP (fork-join) section.

Implemented in benchmarks::exahype2::ccz4::MulticoreOrchestration, tarch::multicore::orchestration::AllOnGPU, and tarch::multicore::orchestration::Hardcoded.

◆ fuse()

virtual FuseInstruction tarch::multicore::orchestration::Strategy::fuse ( int taskType)
pure virtual

How many tasks to fuse and to which device to deploy.

See also
Consult the page Task fusion strategies for recommendations and hints on task fusion strategies.
Consult the namespace documentation of tarch::multicore::taskfusion for details on the realisation of the task fusion.
Parameters
taskTypeTask type for which we want to know if to fuse or not.

Implemented in tarch::multicore::orchestration::AllOnGPU, and tarch::multicore::orchestration::Hardcoded.

Referenced by tarch::multicore::taskfusion::ProcessReadyTask::processTasks(), tarch::multicore::taskfusion::ProcessReadyTask::run(), and tarch::multicore::taskfusion::translateFusableTaskIntoTaskSequence().

Here is the caller graph for this function:

◆ paralleliseForkJoinSection()

virtual ExecutionPolicy tarch::multicore::orchestration::Strategy::paralleliseForkJoinSection ( int nestedParallelismLevel,
int numberOfTasks,
int taskType )
pure virtual

Determine how to handle/realise parallelisation within fork/join region.

Peano models its execution with multiple parallel, nested fork/join sections. You could also think of these as mini-BSP sections. This routine guides the orchestration how to map those BSP sections onto tasks.

The decision can be guided by basically arbitrary contextual factors. The most important one for me is the nesting factor. As we work mainly with OpenMP, where tasks are tied to one core, it makes limited sense to have nested parallel fors. Notably, it makes stuff slower. So usually, I return ExecutionPolicy::RunSerially with anything with a nesting level greater than 1.

Parameters
nestedParallelismLevelPlease compare with tarch::multicore::spawnAndWait() which ensures that this flag equals 1 on the top level. A parameter of 0 would mean that no fork/join region has been opened. For such a parameter, the code would not query this function.
taskTypeIf we enter a fork-join section, this section logically spawns a set of tasks, which are all of the same type. So the task type here is given implicitly by the code location. But each BSP section has a unique identifier.

Implemented in benchmarks::exahype2::ccz4::MulticoreOrchestration, tarch::multicore::orchestration::AllOnGPU, tarch::multicore::orchestration::Hardcoded, and tarch::multicore::orchestration::GeneticOptimisation.

◆ startBSPSection()

virtual void tarch::multicore::orchestration::Strategy::startBSPSection ( int nestedParallelismLevel)
pure virtual

◆ updateFuseStatistics()

virtual void tarch::multicore::orchestration::Strategy::updateFuseStatistics ( int taskType,
int queueSize,
double averageNumberOfPendingReadyTasksPerProcessTaskExecution,
double probabilityThatTaskIsCompleted )
pure virtual

Update task fusion status.

Feed orchestration with some stats around the task queue of interest. This routine is not called every time a process read tasks kicks off, but only every now and then. Furthermore, please note that this routine is invoked iff the orchestration beforehand had decided to fuse tasks.

Parameters
taskTypeNumber of the task that we are studying
queueSizeSize of the queue at this observation point
averageNumberOfPendingReadyTasksPerProcessTaskExecutionaverage over number of tasks in the queue whenever a process task has kicked off and the underlying real task has not completed yet.
probabilityThatTaskIsCompletedProbability that task result has been there already when the corresponding instance of ProcessReadyTask fires up. This is a biased value: If we try to look up if a task is already completed and the underlying dictionary is locked, then this counts as a "no hit" as well.

Implemented in tarch::multicore::orchestration::AllOnGPU, and tarch::multicore::orchestration::Hardcoded.

Referenced by tarch::multicore::taskfusion::ProcessReadyTask::run().

Here is the caller graph for this function:

Field Documentation

◆ EndOfBSPSection

constexpr int tarch::multicore::orchestration::Strategy::EndOfBSPSection = -1
staticconstexpr

Definition at line 130 of file Strategy.h.


The documentation for this class was generated from the following file: