Peano
MulticoreOrchestration.cpp
Go to the documentation of this file.
2 
3 #include <limits>
4 
5 #include "tarch/multicore/Task.h"
6 #include "tarch/accelerator/Device.h"
7 
8 #ifdef PureFV
9 #else
10 #include "tasks/CCZ4SBH_FD4EnclaveTask.h"
11 #endif
12 
13 #ifdef PureFD4
14 #else
15 #include "tasks/CCZ4SBH_FVEnclaveTask.h"
16 #endif
17 
19  _nestedBSPLevels(0),
20  _maxFiniteVolumeTasks(0),
21  _finiteVolumeTasksInThisBSPSection(0)
22  {}
23 
25  if (_nestedBSPLevels==0) {
26  _finiteVolumeTasksInThisBSPSection = 0;
27  }
28  _nestedBSPLevels++;
29 
30 }
31 
33  _nestedBSPLevels--;
34  if (_nestedBSPLevels==0) {
35  _maxFiniteVolumeTasks = std::max(_maxFiniteVolumeTasks, _finiteVolumeTasksInThisBSPSection);
36  }
37 }
38 
40  if ( taskType == tasks::CCZ4SBH_FVEnclaveTask::getEnclaveTaskTypeId() ) {
41  _finiteVolumeTasksInThisBSPSection++;
42  }
43 
44  if (
45  _nestedBSPLevels>0
46  and
47  tarch::accelerator::Device::getInstance().getNumberOfDevices()>0
48  and
49  taskType == tasks::CCZ4SBH_FVEnclaveTask::getEnclaveTaskTypeId()
50  ) {
51  return _maxFiniteVolumeTasks;
52  }
53  else {
54  return 0;
55  }
56 }
57 
58 benchmarks::exahype2::ccz4::MulticoreOrchestration::FuseInstruction benchmarks::exahype2::ccz4::MulticoreOrchestration::getNumberOfTasksToFuseAndTargetDevice(
59  int taskType
60 ) {
61  if (
62  taskType == tasks::CCZ4SBH_FVEnclaveTask::getEnclaveTaskTypeId()
63  ) {
64  return benchmarks::exahype2::ccz4::MulticoreOrchestration::FuseInstruction(
65  0, 1, 1
66  );
67  }
68  else {
69  return benchmarks::exahype2::ccz4::MulticoreOrchestration::FuseInstruction(
70  0, 16, std::numeric_limits<int>::max()
71  );
72  }
73 }
74 
76  return true;
77 }
78 
79 tarch::multicore::orchestration::Strategy::ExecutionPolicy benchmarks::exahype2::ccz4::MulticoreOrchestration::paralleliseForkJoinSection(
80  int nestedParallelismLevel, int numberOfTasks, int codeLocationIdentifier
81 ) {
82  if (nestedParallelismLevel > 1) {
83  return tarch::multicore::orchestration::Strategy::ExecutionPolicy::RunSerially;
84  }
85  else {
86  return tarch::multicore::orchestration::Strategy::ExecutionPolicy::RunParallel;
87  }
88 }
virtual bool fuseTasksImmediatelyWhenSpawned(int taskType) override
Ensure Finite Volume tasks end up on GPU asap.
virtual void startBSPSection(int nestedParallelismLevel) override
Start a fork/join section.
virtual void endBSPSection(int nestedParallelismLevel) override
End fork/join section.
virtual FuseInstruction getNumberOfTasksToFuseAndTargetDevice(int taskType) override
Ensure right cardinality ends up on GPU.
virtual ExecutionPolicy paralleliseForkJoinSection(int nestedParallelismLevel, int numberOfTasks, int taskType) override
Determine how to parallelise a fork/join section.
virtual int getNumberOfTasksToHoldBack(int taskType) override
How many tasks should be held back.