Peano 4
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
15toolbox::loadbalancing::strategies::Hardcoded::Hardcoded(std::initializer_list<int> timeStamps, std::initializer_list<int> splittingTrees, std::initializer_list<int> numberOfCells, std::initializer_list<int> destinationRanks, bool handOutOnePartitionPerCore):
16 AbstractLoadBalancing( nullptr, nullptr ),
17 _currentTimeStamp(0),
18 _handOutOnePartitionPerCore(handOutOnePartitionPerCore) {
19 assertionEquals4( timeStamps.size(), numberOfCells.size(), timeStamps.size(), splittingTrees.size(), numberOfCells.size(), destinationRanks.size() );
20 assertionEquals4( splittingTrees.size(), numberOfCells.size(), timeStamps.size(), splittingTrees.size(), numberOfCells.size(), destinationRanks.size() );
21 assertionEquals4( destinationRanks.size(), numberOfCells.size(), timeStamps.size(), splittingTrees.size(), numberOfCells.size(), destinationRanks.size() );
22
23 auto timeStamp = timeStamps.begin();
24 auto splittingTree = splittingTrees.begin();
25 auto cells = numberOfCells.begin();
26 auto destinationRank = destinationRanks.begin();
27
28 while (timeStamp!=timeStamps.end()) {
29 _splits.push( Split( *timeStamp, *splittingTree, *cells, *destinationRank ) );
30 timeStamp++;
31 splittingTree++;
32 cells++;
33 destinationRank++;
34 }
35
36 // I would love to have some info output here, but some codes use the lb as static attribute
37 // so it might come up before the logging infrastructure is up. This means that the logInfo
38 // will crash.
39 // logInfo( "Hardcoded(...)", "created hardcoded load balancing strategy with " << _splits.size() << " decomposition(s)" );
40}
41
42
43
45 timeStamp( split.timeStamp ),
46 splittingTree( split.splittingTree ),
47 numberOfCells( split.numberOfCells ),
48 destinationRank( split.destinationRank ) {
49}
50
51
52toolbox::loadbalancing::strategies::Hardcoded::Split::Split( int timeStamp_, int splittingTree_, int numberOfCells_, int destinationRank_ ):
53 timeStamp( timeStamp_),
54 splittingTree( splittingTree_),
55 numberOfCells( numberOfCells_ ),
56 destinationRank( destinationRank_ ) {
57}
58
59
62
63 while (not _splits.empty() and _currentTimeStamp>=_splits.front().timeStamp) {
64 Split split( _splits.front() );
65 _splits.pop();
66 if ( peano4::parallel::SpacetreeSet::getInstance().isLocalSpacetree( split.splittingTree) ) {
69 "finishStep()",
70 "wanted to split " << split.numberOfCells << " cell(s) from tree " <<
71 split.splittingTree << " and to deploy them to new tree on rank " << split.destinationRank <<
72 ". However, load (re-)balancing is deactivated"
73 );
74 }
75 else if (
77 and
79 and
81 ) {
83 "finishStep()", "ignore instruction to split rank further by cutting of " << split.numberOfCells <<
84 ", as lb is told not to overbook local cores"
85 );
86 }
88 split.splittingTree,
89 peano4::SplitInstruction{split.numberOfCells,peano4::SplitInstruction::Mode::BottomUp},
90 split.destinationRank
91 )) {
93 "finishStep()",
94 "had been told to split " << split.numberOfCells << " cell(s) from tree " <<
95 split.splittingTree << " and to deploy them to new tree on rank " << split.destinationRank <<
96 ". However, that failed"
97 );
98 }
99 }
100 }
101
103}
104
105
#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:538
int getRank() const
Return rank of this node.
Definition Rank.cpp:528
static Core & getInstance()
Definition Core.cpp:55
int getNumberOfThreads() const
Returns the number of threads that is used.
Definition Core.cpp:66
virtual void finishStep() override
Finish the step.
Definition Hardcoded.cpp:60
int _currentTimeStamp
Time stamp might be the slightly wrong wording.
Definition Hardcoded.h:74
Hardcoded(std::initializer_list< int > timeStamps, std::initializer_list< int > splittingTrees, std::initializer_list< int > numberOfCells, std::initializer_list< int > destinationRanks, 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