Peano
Loading...
Searching...
No Matches
loadbalancing.cpp
Go to the documentation of this file.
1#include "loadbalancing.h"
2
3#include "tarch/logging/Log.h"
4
6
8
9#include "tarch/tarch.h"
10
11#include <stdlib.h>
12
13
14namespace {
15 // If I don't instantiate it here, i.e. outside of a function, then I run risk
16 // that it is initialised late and thus has the wrong time stamp.
17 tarch::logging::Log _log( "toolbox::loadbalancing" );
18}
19
20
22 std::ostringstream msg;
23
24 int sumLocal = 0;
25 int sumRemote = 0;
26 std::set<int> idsOfLocalSpacetrees = peano4::parallel::SpacetreeSet::getInstance().getLocalSpacetrees();
27
28 msg << idsOfLocalSpacetrees.size() << " tree(s): ";
29
30 for (auto p: idsOfLocalSpacetrees) {
31 msg << "(#" << p << ":"
33 << "/"
35 << ")";
38 }
39 if (idsOfLocalSpacetrees.empty()) {
40 msg << "no trees hosted on this node - therefore no load";
41 }
42 else {
43 msg << " total=" << sumLocal << "/" << sumRemote << " (local/virtual)";
44 }
45
46 logInfo( "dumpStatistics()", msg.str() );
47}
48
49
51 std::set<int> idsOfLocalSpacetrees = peano4::parallel::SpacetreeSet::getInstance().getLocalSpacetrees();
52 int heaviestSpacetree = -1;
53 int maxLocalUnrefinedCells = -1;
54
55 for (auto p: idsOfLocalSpacetrees) {
56 if (
58 and
60 ) {
62 heaviestSpacetree = p;
63 }
64 }
65
66 logDebug( "getWeightOfHeaviestLocalSpacetree()", "id=" << heaviestSpacetree << ", #octants=" << peano4::parallel::SpacetreeSet::getInstance().getGridStatistics(heaviestSpacetree).getNumberOfLocalUnrefinedCells() );
67 return heaviestSpacetree==-1 ? -1 : peano4::parallel::SpacetreeSet::getInstance().getGridStatistics(heaviestSpacetree).getNumberOfLocalUnrefinedCells();
68}
#define ThreePowerD
Definition Globals.h:24
#define logDebug(methodName, logMacroMessageStream)
Definition Log.h:50
#define logInfo(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Definition Log.h:411
peano4::grid::GridStatistics getGridStatistics() const
Return statistics object for primary spacetree.
static SpacetreeSet & getInstance()
std::set< int > getLocalSpacetrees() const
Log Device.
Definition Log.h:516
tarch::logging::Log _log("exahype2::fv")
int getWeightOfHeaviestLocalSpacetree()
This is a helper routine which is used by ExaHyPE's default main for for example.
void dumpStatistics()
Dump the stats of the lb to the terminal (info device).