Peano
Loading...
Searching...
No Matches
Blacklist.cpp
Go to the documentation of this file.
1#include "Blacklist.h"
3
4#include <sstream>
5
6
7tarch::logging::Log toolbox::loadbalancing::Blacklist::_log( "toolbox::loadbalancing::Blacklist" );
8
9
11 lifetime(3),
12 numberOfUnrefinedCells( peano4::parallel::SpacetreeSet::getInstance().getGridStatistics(treeNumber).getNumberOfLocalUnrefinedCells() ),
15}
16
17
20
21
23 std::ostringstream msg;
24 msg << "{";
25 if (_blacklist.empty()) {
26 msg << "blacklist is empty";
27 }
28 else {
29 for (auto p: _blacklist) {
30 msg << "(#" << p.first << ":";
31
32 if (p.second.lifetime>0) {
33 msg << "lifetime=" << p.second.lifetime
34 << ",#cells=" << p.second.numberOfUnrefinedCells;
35 }
36 else {
37 msg << "inactive";
38 }
39
40 msg << ",#splits=" << p.second.numberOfSplits
41 << ",#deg-children=" << p.second.numberOfDegeneratedChildren
42 << ")";
43 }
44 }
45 msg << "}";
46
47 return msg.str();
48}
49
50
52 return _blacklist.count(treeNumber)>0
53 and _blacklist.at(treeNumber).lifetime>0;
54}
55
56
58 for ( auto& p: _blacklist ) {
59 if ( peano4::parallel::SpacetreeSet::getInstance().getGridStatistics(p.first).getRemovedEmptySubtree() ) {
60 logInfo(
61 "update()",
62 "tree " << p.first << " has degenerated child. Set/keep on blacklist"
63 );
64 p.second.numberOfDegeneratedChildren++;
65 p.second.lifetime++;
66 }
67 else if ( p.second.lifetime>0 ) {
69 if ( currentNumberOfCells==p.second.numberOfUnrefinedCells ) {
70 logInfo( "updateBlacklist()", "tree " << p.first << " is on blacklist but seems to have failed to fork off cells successfully, as number of cells did not decrease since last split. Keep on blacklist" );
71 }
72 else if (p.second.lifetime==1) {
73 logInfo( "updateBlacklist()", "remove tree " << p.first << " from blacklist (keep but set at inactive)" );
74 p.second.lifetime = 0;
75 }
76 else if (p.second.lifetime>0) {
77 p.second.lifetime--;
78 }
79 }
80 }
81}
82
83
85 if ( _blacklist.count(newParent)==0 ) {
86 _blacklist.insert( std::pair<int,BlacklistData>(
87 newParent,
88 BlacklistData(newParent)
89 ));
90 }
91 else if ( _blacklist.at(newParent).lifetime==0 ) {
92 _blacklist.at(newParent) = BlacklistData(newParent);
93 }
94 else {
96 "triggerSplit()",
97 "split local rank " << newParent << " though it had been on the blacklist. This happens usually if and only if a tree split multiple times in one iteration"
98 );
99 _blacklist.at(newParent).numberOfSplits++;
100 }
101}
#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()
Log Device.
Definition Log.h:516
void triggeredSplit(int newParent)
Inform blacklist that the load balancing has just triggered a split.
Definition Blacklist.cpp:84
void update()
Update blacklist at end of traversal.
Definition Blacklist.cpp:57
static tarch::logging::Log _log
Definition Blacklist.h:102
std::map< int, BlacklistData > _blacklist
Map of trees numbers onto blacklist entries.
Definition Blacklist.h:111
bool isBlacklisted(int treeNumber) const
Definition Blacklist.cpp:51
The parallel namespace is Peano's core abstracts from both MPI and multicore parallelisation.
int lifetime
Remaining steps how long this blacklist entry should stay on.
Definition Blacklist.h:81
BlacklistData(int treeNumber)
New blacklist entry for entry which has not yet been on blacklist before, i.e.
Definition Blacklist.cpp:10
int numberOfUnrefinedCells
Store number of unrefined cells at time of split.
Definition Blacklist.h:86