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 void updateFuseStatistics (int taskType, int queueSize, double averageNumberOfReadyTasksPerProcessTaskExecution, 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 FusionImplementation getFusionImplementation () const =0
 Determine how the implementation handles fusable tasks.

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 ( )

◆ ~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 _configurationVariants, fuseTasksImmediatelyWhenSpawned(), and 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

◆ fuseTasksImmediatelyWhenSpawned()

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

Definition at line 234 of file SamplingMulticoreOrchestration.cpp.

References _activeKey.

Referenced by createInitialConfigurations().

Here is the caller graph for this function:

◆ getNumberOfTasksToFuseAndTargetDevice()

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

Definition at line 225 of file SamplingMulticoreOrchestration.cpp.

References _activeKey, _currentDevice, and 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.

References _activeKey.

◆ increaseProbabilityOfActiveConfiguration()

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

Definition at line 128 of file SamplingMulticoreOrchestration.cpp.

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

Referenced by endBSPSection().

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

◆ normalise()

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

Definition at line 76 of file SamplingMulticoreOrchestration.cpp.

References _configurationVariants, and logInfo.

Referenced by endBSPSection(), and 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 _activeKey, 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 _activeKey, _configurationVariants, and logInfo.

Referenced by endBSPSection().

Here is the caller graph for this function:

◆ removeUnreasonableProbabilities()

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

Definition at line 184 of file SamplingMulticoreOrchestration.cpp.

References _configurationVariants, and logInfo.

Referenced by endBSPSection().

Here is the caller graph for this function:

◆ startBSPSection()

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

Field Documentation

◆ _activeKey

◆ _bspRunThroughsWithActiveKey

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

◆ _configurationVariants

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

◆ _currentDevice

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

◆ _currentWatch

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

◆ _lastDuration

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

Definition at line 59 of file SamplingMulticoreOrchestration.h.

Referenced by endBSPSection(), and GeneticOptimisation().

◆ _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: