Peano
Loading...
Searching...
No Matches
CustomCellWeight.cpp
Go to the documentation of this file.
1#include "CustomCellWeight.h"
2
4
6
8
9
11tarch::logging::Log toolbox::loadbalancing::metrics::CustomCellWeight::_log( "toolbox::loadbalancing::metrics::CustomCellWeight" );
14
15
18
19
21 return CostMetrics::toString( "custom-cell-weight" );
22}
23
24
26 _previousCellWeights.clear();
27 _previousCellWeights.insert( _currentCellWeights.begin(), _currentCellWeights.end() );
28
29 _currentCellWeights.clear();
30
31 _localRankWeight = 0;
32 for (auto& p: _previousCellWeights) {
33 _localRankWeight += p.second;
34 }
35
37}
38
39
41 if ( _previousCellWeights.count(spacetreeNumber)==0 ) {
42 return 0.0;
43 }
44 else {
45 return _previousCellWeights.at(spacetreeNumber);
46 }
47}
48
49
50void toolbox::loadbalancing::metrics::CustomCellWeight::logCellWeight( int spacetreeNumber, double weight ) {
51 tarch::multicore::Lock lock( _semaphore );
52 if ( _currentCellWeights.count(spacetreeNumber)==0 ) {
53 _currentCellWeights.insert( std::pair<int,double>(spacetreeNumber,0.0) );
54 }
55 lock.free();
56
57 _currentCellWeights[spacetreeNumber] += weight;
58}
59
60
Log Device.
Definition Log.h:516
Create a lock around a boolean semaphore region.
Definition Lock.h:19
void free()
Free the lock.
Definition Lock.cpp:37
virtual void updateGlobalView()
Please overwrite in subclass and set the value of _localRankWeight.
virtual std::string toString() const =0
Feel free to invoke the variant below if you want.
virtual double getCostOfLocalTree(int spacetreeNumber) const override
Implementation of abstract superclass routine.
static void logCellWeight(int spacetreeNumber, double weight)
Report weight of one cell.
static std::map< int, double > _previousCellWeights
Mapping of trees onto cell weights.
static tarch::multicore::BooleanSemaphore _semaphore
static std::map< int, double > _currentCellWeights
Mapping of trees onto cell weights.
virtual void updateGlobalView() override
Update global view.
virtual std::string toString() const override
Feel free to invoke the variant below if you want.