Peano
Loading...
Searching...
No Matches
tarch::multicore::orchestration::GeneticOptimisation Class Reference

A hard coded strategy that can realise a few standard tasking patterns. More...

#include <SamplingMulticoreOrchestration.h>

Inheritance diagram for tarch::multicore::orchestration::GeneticOptimisation:
Collaboration diagram for tarch::multicore::orchestration::GeneticOptimisation:

Data Structures

struct  Key
 
struct  Value
 

Public Member Functions

 GeneticOptimisation ()
 
virtual ~GeneticOptimisation ()=default
 
virtual void startBSPSection () override
 
virtual void endBSPSection () override
 
virtual int getNumberOfTasksToHoldBack () override
 
virtual FuseInstruction getNumberOfTasksToFuseAndTargetDevice () override
 
virtual bool fuseTasksImmediatelyWhenSpawned () override
 
virtual ExecutionPolicy paralleliseForkJoinSection (int nestedParallelismLevel, int numberOfTasks, int taskType) override
 Determine how to handle/realise parallelisation within fork/join region.
 
- Public Member Functions inherited from tarch::multicore::orchestration::Strategy
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 FuseInstruction fuse (int taskType)=0
 How many tasks shall system hold back from tasking runtime in user-defined queues.
 

Private Member Functions

void createInitialConfigurations ()
 
void normalise ()
 
void increaseProbabilityOfActiveConfiguration ()
 
void removeUnreasonableProbabilities ()
 
void pickNewActiveConfigurationRandomly ()
 

Private Attributes

std::map< Key, Value_configurationVariants
 
Key _activeKey
 
tarch::timing::Watch _currentWatch
 
double _lastDuration
 
int _bspRunThroughsWithActiveKey
 
int _currentDevice
 

Static Private Attributes

static tarch::logging::Log _log
 

Additional Inherited Members

- Public Types inherited from tarch::multicore::orchestration::Strategy
enum class  ExecutionPolicy { RunSerially , RunParallel }
 Provide hint of execution policy. More...
 
- Static Public Attributes inherited from tarch::multicore::orchestration::Strategy
static constexpr int EndOfBSPSection = -1
 

Detailed Description

A hard coded strategy that can realise a few standard tasking patterns.

Definition at line 25 of file SamplingMulticoreOrchestration.h.

Constructor & Destructor Documentation

◆ GeneticOptimisation()

tarch::multicore::orchestration::GeneticOptimisation::GeneticOptimisation ( )

Definition at line 43 of file SamplingMulticoreOrchestration.cpp.

References createInitialConfigurations(), and normalise().

Here is the call graph for this function:

◆ ~GeneticOptimisation()

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

Member Function Documentation

◆ createInitialConfigurations()

void tarch::multicore::orchestration::GeneticOptimisation::createInitialConfigurations ( )
private

Definition at line 53 of file SamplingMulticoreOrchestration.cpp.

References tarch::multicore::Core::getInstance().

Referenced by GeneticOptimisation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ endBSPSection()

void tarch::multicore::orchestration::GeneticOptimisation::endBSPSection ( )
overridevirtual

Definition at line 98 of file SamplingMulticoreOrchestration.cpp.

◆ fuseTasksImmediatelyWhenSpawned()

bool tarch::multicore::orchestration::GeneticOptimisation::fuseTasksImmediatelyWhenSpawned ( )
overridevirtual

◆ getNumberOfTasksToFuseAndTargetDevice()

tarch::multicore::orchestration::GeneticOptimisation::FuseInstruction tarch::multicore::orchestration::GeneticOptimisation::getNumberOfTasksToFuseAndTargetDevice ( )
overridevirtual

Definition at line 225 of file SamplingMulticoreOrchestration.cpp.

References tarch::multicore::Core::getInstance().

Here is the call graph for this function:

◆ getNumberOfTasksToHoldBack()

int tarch::multicore::orchestration::GeneticOptimisation::getNumberOfTasksToHoldBack ( )
overridevirtual

Definition at line 221 of file SamplingMulticoreOrchestration.cpp.

◆ increaseProbabilityOfActiveConfiguration()

void tarch::multicore::orchestration::GeneticOptimisation::increaseProbabilityOfActiveConfiguration ( )
private

Definition at line 128 of file SamplingMulticoreOrchestration.cpp.

References logInfo, and tarch::multicore::orchestration::GeneticOptimisation::Key::toString().

Here is the call graph for this function:

◆ normalise()

void tarch::multicore::orchestration::GeneticOptimisation::normalise ( )
private

Definition at line 76 of file SamplingMulticoreOrchestration.cpp.

References logInfo.

Referenced by GeneticOptimisation().

Here is the caller graph for this function:

◆ paralleliseForkJoinSection()

tarch::multicore::orchestration::Strategy::ExecutionPolicy tarch::multicore::orchestration::GeneticOptimisation::paralleliseForkJoinSection ( int nestedParallelismLevel,
int numberOfTasks,
int taskType )
overridevirtual

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.

Implements tarch::multicore::orchestration::Strategy.

Definition at line 242 of file SamplingMulticoreOrchestration.cpp.

References tarch::multicore::orchestration::Strategy::RunParallel, and tarch::multicore::orchestration::Strategy::RunSerially.

◆ pickNewActiveConfigurationRandomly()

void tarch::multicore::orchestration::GeneticOptimisation::pickNewActiveConfigurationRandomly ( )
private

Definition at line 203 of file SamplingMulticoreOrchestration.cpp.

References logInfo.

◆ removeUnreasonableProbabilities()

void tarch::multicore::orchestration::GeneticOptimisation::removeUnreasonableProbabilities ( )
private

Definition at line 184 of file SamplingMulticoreOrchestration.cpp.

References logInfo.

◆ startBSPSection()

void tarch::multicore::orchestration::GeneticOptimisation::startBSPSection ( )
overridevirtual

Definition at line 92 of file SamplingMulticoreOrchestration.cpp.

Field Documentation

◆ _activeKey

Key tarch::multicore::orchestration::GeneticOptimisation::_activeKey
private

Definition at line 57 of file SamplingMulticoreOrchestration.h.

◆ _bspRunThroughsWithActiveKey

int tarch::multicore::orchestration::GeneticOptimisation::_bspRunThroughsWithActiveKey
private

Definition at line 60 of file SamplingMulticoreOrchestration.h.

◆ _configurationVariants

std::map<Key, Value> tarch::multicore::orchestration::GeneticOptimisation::_configurationVariants
private

Definition at line 55 of file SamplingMulticoreOrchestration.h.

◆ _currentDevice

int tarch::multicore::orchestration::GeneticOptimisation::_currentDevice
private

Definition at line 61 of file SamplingMulticoreOrchestration.h.

◆ _currentWatch

tarch::timing::Watch tarch::multicore::orchestration::GeneticOptimisation::_currentWatch
private

Definition at line 58 of file SamplingMulticoreOrchestration.h.

◆ _lastDuration

double tarch::multicore::orchestration::GeneticOptimisation::_lastDuration
private

Definition at line 59 of file SamplingMulticoreOrchestration.h.

◆ _log

tarch::logging::Log tarch::multicore::orchestration::GeneticOptimisation::_log
staticprivate

Definition at line 46 of file SamplingMulticoreOrchestration.h.


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