Peano
Loading...
Searching...
No Matches
Hardcoded.cpp
Go to the documentation of this file.
2
4
5#include "tarch/Assertions.h"
7
10
11
12tarch::logging::Log toolbox::loadbalancing::strategies::Hardcoded::_log( "toolbox::loadbalancing::strategies::Hardcoded" );
13
14
16 std::initializer_list<int> timeStamps,
17 std::initializer_list<int> splittingTrees,
18 std::initializer_list<int> numberOfCells,
19 std::initializer_list<int> destinationRanks,
20 std::initializer_list<peano4::SplitInstruction::Mode> modes,
21 bool handOutOnePartitionPerCore
22):
23 AbstractLoadBalancing( nullptr, nullptr ),
24 _currentTimeStamp(0),
25 _handOutOnePartitionPerCore(handOutOnePartitionPerCore) {
26 assertionEquals4( timeStamps.size(), numberOfCells.size(), timeStamps.size(), splittingTrees.size(), numberOfCells.size(), destinationRanks.size() );
27 assertionEquals4( splittingTrees.size(), numberOfCells.size(), timeStamps.size(), splittingTrees.size(), numberOfCells.size(), destinationRanks.size() );
28 assertionEquals4( destinationRanks.size(), numberOfCells.size(), timeStamps.size(), splittingTrees.size(), numberOfCells.size(), destinationRanks.size() );
29 assertionEquals4( modes.size(), numberOfCells.size(), timeStamps.size(), splittingTrees.size(), numberOfCells.size(), destinationRanks.size() );
30
31 auto timeStamp = timeStamps.begin();
32 auto splittingTree = splittingTrees.begin();
33 auto cells = numberOfCells.begin();
34 auto destinationRank = destinationRanks.begin();
35 auto mode = modes.begin();
36
37 while (timeStamp!=timeStamps.end()) {
38 _splits.push( Split( *timeStamp, *splittingTree, *cells, *destinationRank, *mode ) );
39 timeStamp++;
40 splittingTree++;
41 cells++;
42 destinationRank++;
43 mode++;
44 }
45
46 // I would love to have some info output here, but some codes use the lb as static attribute
47 // so it might come up before the logging infrastructure is up. This means that the logInfo
48 // will crash.
49 // logInfo( "Hardcoded(...)", "created hardcoded load balancing strategy with " << _splits.size() << " decomposition(s)" );
50}
51
52
53
55 timeStamp( split.timeStamp ),
56 splittingTree( split.splittingTree ),
57 numberOfCells( split.numberOfCells ),
58 destinationRank( split.destinationRank ),
59 mode( split.mode ) {
60}
61
62
63toolbox::loadbalancing::strategies::Hardcoded::Split::Split( int timeStamp_, int splittingTree_, int numberOfCells_, int destinationRank_, peano4::SplitInstruction::Mode mode_ ):
64 timeStamp( timeStamp_),
65 splittingTree( splittingTree_),
66 numberOfCells( numberOfCells_ ),
67 destinationRank( destinationRank_ ),
68 mode(mode_) {
69}
70
71
74
75 while (not _splits.empty() and _currentTimeStamp>=_splits.front().timeStamp) {
76 Split split( _splits.front() );
77 _splits.pop();
78 if ( peano4::parallel::SpacetreeSet::getInstance().isLocalSpacetree( split.splittingTree) ) {
81 "finishStep()",
82 "wanted to split " << split.numberOfCells << " cell(s) from tree " <<
83 split.splittingTree << " and to deploy them to new tree on rank " << split.destinationRank <<
84 ". However, load (re-)balancing is deactivated"
85 );
86 }
87 else if (
89 and
91 and
93 ) {
95 "finishStep()", "ignore instruction to split rank further by cutting of " << split.numberOfCells <<
96 ", as lb is told not to overbook local cores"
97 );
98 }
100 split.splittingTree,
101 peano4::SplitInstruction{split.numberOfCells,split.mode},
102 split.destinationRank
103 )) {
105 "finishStep()",
106 "had been told to split " << split.numberOfCells << " cell(s) from tree " <<
107 split.splittingTree << " and to deploy them to new tree on rank " << split.destinationRank <<
108 ". However, that failed"
109 );
110 }
111 }
112 }
113
115}
116
117
#define assertionEquals4(lhs, rhs, larg, rarg, three, four)
#define logError(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Definition Log.h:464
#define logWarning(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Definition Log.h:440
static SpacetreeSet & getInstance()
std::set< int > getLocalSpacetrees() const
Log Device.
Definition Log.h:516
static Rank & getInstance()
This operation returns the singleton instance.
Definition Rank.cpp:539
int getRank() const
Return rank of this node.
Definition Rank.cpp:529
static Core & getInstance()
Definition Core.cpp:56
int getNumberOfThreads() const
Returns the number of threads that is used.
Definition Core.cpp:67
virtual void finishStep() override
Finish the step.
Definition Hardcoded.cpp:72
int _currentTimeStamp
Time stamp might be the slightly wrong wording.
Definition Hardcoded.h:82
Hardcoded(std::initializer_list< int > timeStamps, std::initializer_list< int > splittingTrees, std::initializer_list< int > numberOfCells, std::initializer_list< int > destinationRanks, std::initializer_list< peano4::SplitInstruction::Mode > modes, bool handOutOnePartitionPerCore)
Definition Hardcoded.cpp:15
void dumpStatistics()
Dump the stats of the lb to the terminal (info device).
@ SwitchedOff
You usually don't get this state when we query the configuration, i.e.
Instruction to split.
Definition grid.h:34