Abstract cost metric.
Base class for any cost metric that you want to use in combination with the generic load balancing strategies. To realise your own cost metric, you have to complete two steps:
- The most important quantity of this class is _localRankWeight which is not set by this abstract base class. I recommend to redefine the routine updateGlobalView(), to set this attribute there, and then to call CostMetric's updateGlobalView() to finish all global data exchange.
- Next, you have to implement getCostOfLocalTree().
updateGlobalView() all-reduces the metrics over all ranks, i.e. all ranks hold the same global weight, lightest rank and minimum of rank weights afterwards. This mirrors toolbox::loadbalancing::Statistics and peano4::parallel::SpacetreeSet::getGridStatistics(). Only _localRankWeight and getCostOfLocalRank() are rank-local.
Definition at line 37 of file CostMetrics.h.
| virtual double toolbox::loadbalancing::CostMetrics::getCostOfLocalTree |
( |
int |
spacetreeNumber | ) |
const |
|
pure virtual |
Query cost of one tree.
This routine is only called by the rank which owns the tree spacetreeNumber. That is, you don't need global knowledge of the tree weight distribution.
The routine is used in multiple places, but the most important one is toolbox::loadbalancing::AbstractLoadBalancing::getIdOfHeaviestLocalSpacetree(), which analyses the whole tree cost distribution on a rank.
Implemented in toolbox::loadbalancing::metrics::CellCount, and toolbox::loadbalancing::metrics::CustomCellWeight.
| virtual void toolbox::loadbalancing::CostMetrics::updateGlobalView |
( |
| ) |
|
|
virtual |
Please overwrite in subclass and set the value of _localRankWeight.
Afterwards, call this superclass routine
The superclass routine all-reduces the global weight, the lightest rank and the minimum of the rank weights over all ranks through tarch::mpi::Rank::allReduce(). The reduction is blocking, i.e. all ranks hold the same values once the routine has terminated. The routine hence has to be called by all ranks at the same time, and only by one thread per rank.
Reimplemented in toolbox::loadbalancing::metrics::CellCount, and toolbox::loadbalancing::metrics::CustomCellWeight.