13 "toolbox::loadbalancing::strategies::SplitOversizedTree"
33 std::ostringstream msg;
36 <<
"(type=split-oversized-tree"
37 <<
",state=" <<
::toString(
_state) <<
",statistics=" << _statistics.toString() <<
",cost-metrics="
38 << _costMetrics->toString() <<
",round-robin-token=" << _roundRobinToken <<
",blacklist=" << _blacklist.toString()
39 <<
",heaviest-local-tree=" << getIdOfHeaviestLocalSpacetree() <<
" (analysed)"
42 <<
",is-inter-rank-balancing-bad=" << isInterRankBalancingBad()
43 <<
",is-intra-rank-balancing-bad=" << isIntraRankBalancingBad() <<
",target-tree-cost=" << getTargetTreeCost()
44 <<
",min-tree-size=" << _configuration->getMinTreeSize(
_state) <<
")";
52 logDebug(
"updateState()",
"don't update as we have switched off");
53 }
else if (areRanksUnemployed()) {
59 }
else if (isIntraRankBalancingBad() and doesLocalTreeViolateThreshold()) {
72 if (not _statistics.hasConsistentViewOfWorld()) {
85 result |= _costMetrics->getCostOfLocalTree(p) > getTargetTreeCost();
95 logInfo(
"updateLoadBalancing()",
"load balancing's state=" <<
toString());
100 int heaviestSpacetree = getIdOfHeaviestLocalSpacetree(_configuration->getWorstCaseBalancingRatio(
_state));
105 heaviestSpacetree!=NoHeaviestTreeAvailable
107 not _blacklist.isBlacklisted(heaviestSpacetree)
109 weightOfHeaviestSpacetree > getTargetTreeCost()
113 computeNumberOfSplits(heaviestSpacetree)>0
116 "updateLoadBalancing()",
117 "Not all ranks are used. Split once and deploy to lightest global rank " << _costMetrics->getLightestRank()
119 triggerSplit(heaviestSpacetree, _costMetrics->getLightestRank(), 1);
120 }
else if (heaviestSpacetree != NoHeaviestTreeAvailable) {
122 "updateLoadBalancing()",
123 "can't split heaviest tree " << heaviestSpacetree <<
" even though this tree is too heavy " <<
toString()
128 int heaviestSpacetree = getIdOfHeaviestLocalSpacetree();
133 heaviestSpacetree != NoHeaviestTreeAvailable
135 not _blacklist.isBlacklisted(heaviestSpacetree)
137 weightOfHeaviestSpacetree > getTargetTreeCost()
139 computeNumberOfSplits(heaviestSpacetree) > 0
142 "updateLoadBalancing()",
143 "biggest local tree "
144 << heaviestSpacetree <<
" is too heavy as it hosts " << weightOfHeaviestSpacetree
145 <<
" cells. Try to split tree " << computeNumberOfSplits(heaviestSpacetree)
146 <<
" times and to offload subsection(s) of tree to " << _costMetrics->getLightestRank() <<
" " <<
toString()
148 triggerSplit(heaviestSpacetree, _costMetrics->getLightestRank(), computeNumberOfSplits(heaviestSpacetree));
149 }
else if (heaviestSpacetree != NoHeaviestTreeAvailable) {
151 "updateLoadBalancing()",
152 "can't split heaviest tree "
153 << heaviestSpacetree <<
" and fork off to remote rank,as "
154 <<
"heaviest tree is on blacklist " <<
toString()
163 not _blacklist.isBlacklisted(p)
165 _costMetrics->getCostOfLocalTree(p) > getTargetTreeCost()
167 computeNumberOfSplits(p) > 0
170 "updateLoadBalancing()",
172 << p <<
" is too heavy as it has a weight of " << _costMetrics->getCostOfLocalTree(p)
173 <<
". Try to split tree " << computeNumberOfSplits(p) <<
" times on local rank " <<
toString()
174 <<
" (max local trees=" << _configuration->getMaxLocalTreesPerRank(
_state)
175 <<
", min-tree-size=" << _configuration->getMinTreeSize(
_state) <<
")"
188 _statistics.updateGlobalView();
189 _costMetrics->updateGlobalView();
192 updateLoadBalancing();
195 _statistics.notifyOfStateChange(
_state);
202 int numberOfSplits =
static_cast<int>(_costMetrics->getCostOfLocalTree(sourceTree) / getTargetTreeCost()) - 1;
204 numberOfSplits = std::max(1, numberOfSplits);
205 numberOfSplits = std::min(
207 _configuration->getMaxLocalTreesPerRank(
_state)
217 currentSourceTreeCells / (numberOfSplits + 1) < _configuration->getMinTreeSize(
_state)
224 return numberOfSplits;
229 int sourceTree,
int targetRank,
int numberOfSplits
231 const int numberOfSplitCells = std::max(
234 / (1 + numberOfSplits)
236 for (
int i = 0; i < numberOfSplits; i++) {
243 logInfo(
"triggerSplit()",
"wanted to split local rank " << sourceTree <<
" but failed");
246 _blacklist.triggeredSplit(sourceTree);
247 _statistics.incLocalNumberOfSplits();
253 const int TargetNumberOfThreads = std::min(
255 _configuration->getMaxLocalTreesPerRank(
_state),
#define logDebug(methodName, logMacroMessageStream)
#define logInfo(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
bool split(int treeId, const peano4::SplitInstruction &instruction, int targetRank)
Split a local tree.
peano4::grid::GridStatistics getGridStatistics() const
Return statistics object for primary spacetree.
static SpacetreeSet & getInstance()
std::set< int > getLocalSpacetrees() const
int getNumberOfRanks() const
static Rank & getInstance()
This operation returns the singleton instance.
int getRank() const
Return rank of this node.
static Core & getInstance()
int getNumberOfThreads() const
Returns the number of threads that is used.
std::string toString(Filter filter)
int getNumberOfLocalUnrefinedCells() const