Peano
Loading...
Searching...
No Matches
toolbox::loadbalancing::CostMetrics Class Referenceabstract

Abstract cost metric. More...

#include <CostMetrics.h>

Inheritance diagram for toolbox::loadbalancing::CostMetrics:
Collaboration diagram for toolbox::loadbalancing::CostMetrics:

Data Structures

struct  ReductionBuffer
 It is totally annoying, but it seems that MPI's maxloc and reduction are broken in some MPI implementations. More...
 

Public Member Functions

 CostMetrics ()
 
virtual ~CostMetrics ()=default
 
virtual std::string toString () const =0
 Feel free to invoke the variant below if you want.
 
std::string toString (const std::string &metricName) const
 
virtual void waitForGlobalDataExchange ()
 Typically called by.
 
virtual void updateGlobalView ()
 Please overwrite in subclass and set the value of _localRankWeight.
 
virtual double getCostOfLocalTree (int spacetreeNumber) const =0
 Query cost of one tree.
 
virtual double getCostOfLocalRank () const
 Wrapper around getCostOfLocalTree().
 
virtual double getGlobalCost () const
 
virtual int getLightestRank () const
 
virtual double getMinimumOfMaximumRankWeights () const
 

Protected Attributes

double _localRankWeight
 Weight of local rank.
 
double _globalWeight
 
ReductionBuffer _lightestRank
 
double _minimumOfMaximumOfRankWeights
 
MPI_Request * _globalWeightRequest
 Replicate compared to stats.
 
MPI_Request * _lightestRankRequest
 
MPI_Request * _minimumOfMaximumOfRankWeightsRequest
 
double _globalWeightIn
 
double _globalWeightOut
 
ReductionBuffer _lightestRankIn
 
ReductionBuffer _lightestRankOut
 
double _minimumOfMaximumOfRankWeightsIn
 
double _minimumOfMaximumOfRankWeightsOut
 

Static Private Attributes

static tarch::logging::Log _log
 

Detailed Description

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:

  1. 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.
  2. Next, you have to implement getCostOfLocalTree().

Definition at line 32 of file CostMetrics.h.

Constructor & Destructor Documentation

◆ CostMetrics()

toolbox::loadbalancing::CostMetrics::CostMetrics ( )

◆ ~CostMetrics()

virtual toolbox::loadbalancing::CostMetrics::~CostMetrics ( )
virtualdefault

Member Function Documentation

◆ getCostOfLocalRank()

double toolbox::loadbalancing::CostMetrics::getCostOfLocalRank ( ) const
virtual

Wrapper around getCostOfLocalTree().

Loops over all local trees and returns the sum.

Definition at line 39 of file CostMetrics.cpp.

References peano4::parallel::SpacetreeSet::getInstance(), and peano4::parallel::SpacetreeSet::getLocalSpacetrees().

Here is the call graph for this function:

◆ getCostOfLocalTree()

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.

◆ getGlobalCost()

double toolbox::loadbalancing::CostMetrics::getGlobalCost ( ) const
virtual

Definition at line 133 of file CostMetrics.cpp.

◆ getLightestRank()

int toolbox::loadbalancing::CostMetrics::getLightestRank ( ) const
virtual

Definition at line 138 of file CostMetrics.cpp.

References assertion1, tarch::mpi::Rank::getInstance(), tarch::mpi::Rank::getNumberOfRanks(), and toString().

Here is the call graph for this function:

◆ getMinimumOfMaximumRankWeights()

double toolbox::loadbalancing::CostMetrics::getMinimumOfMaximumRankWeights ( ) const
virtual

Definition at line 145 of file CostMetrics.cpp.

◆ toString() [1/2]

virtual std::string toolbox::loadbalancing::CostMetrics::toString ( ) const
pure virtual

Feel free to invoke the variant below if you want.

Or add additional info.

Implemented in toolbox::loadbalancing::metrics::CellCount, and toolbox::loadbalancing::metrics::CustomCellWeight.

Referenced by toolbox::loadbalancing::metrics::CellCount::toString(), and toolbox::loadbalancing::metrics::CustomCellWeight::toString().

Here is the caller graph for this function:

◆ toString() [2/2]

std::string toolbox::loadbalancing::CostMetrics::toString ( const std::string & metricName) const

Definition at line 25 of file CostMetrics.cpp.

◆ updateGlobalView()

void toolbox::loadbalancing::CostMetrics::updateGlobalView ( )
virtual

Please overwrite in subclass and set the value of _localRankWeight.

Afterwards, call this superclass routine

Reimplemented in toolbox::loadbalancing::metrics::CellCount, and toolbox::loadbalancing::metrics::CustomCellWeight.

Definition at line 68 of file CostMetrics.cpp.

References tarch::mpi::Rank::getInstance(), tarch::mpi::Rank::getRank(), and logInfo.

Referenced by toolbox::loadbalancing::metrics::CellCount::updateGlobalView(), and toolbox::loadbalancing::metrics::CustomCellWeight::updateGlobalView().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitForGlobalDataExchange()

void toolbox::loadbalancing::CostMetrics::waitForGlobalDataExchange ( )
virtual

Typically called by.

  • finishSimulation() and
  • finishStep()

Should wrap up any pending MPI stuff. If you add your own collectives in a subclass, overwrite it, but still invoke the superclass.

Definition at line 49 of file CostMetrics.cpp.

Field Documentation

◆ _globalWeight

double toolbox::loadbalancing::CostMetrics::_globalWeight
protected

Definition at line 106 of file CostMetrics.h.

◆ _globalWeightIn

double toolbox::loadbalancing::CostMetrics::_globalWeightIn
protected

Definition at line 119 of file CostMetrics.h.

◆ _globalWeightOut

double toolbox::loadbalancing::CostMetrics::_globalWeightOut
protected

Definition at line 120 of file CostMetrics.h.

◆ _globalWeightRequest

MPI_Request* toolbox::loadbalancing::CostMetrics::_globalWeightRequest
protected

Replicate compared to stats.

Definition at line 114 of file CostMetrics.h.

Referenced by CostMetrics().

◆ _lightestRank

ReductionBuffer toolbox::loadbalancing::CostMetrics::_lightestRank
protected

Definition at line 107 of file CostMetrics.h.

◆ _lightestRankIn

ReductionBuffer toolbox::loadbalancing::CostMetrics::_lightestRankIn
protected

Definition at line 122 of file CostMetrics.h.

◆ _lightestRankOut

ReductionBuffer toolbox::loadbalancing::CostMetrics::_lightestRankOut
protected

Definition at line 123 of file CostMetrics.h.

◆ _lightestRankRequest

MPI_Request* toolbox::loadbalancing::CostMetrics::_lightestRankRequest
protected

Definition at line 115 of file CostMetrics.h.

Referenced by CostMetrics().

◆ _localRankWeight

double toolbox::loadbalancing::CostMetrics::_localRankWeight
protected

Weight of local rank.

Weight of the whole rank. This quantity is the key quantity whenever we actually ask the metrics for information, as it feeds into the total weight, but also helps us to identify underbooked ranks.

Definition at line 104 of file CostMetrics.h.

◆ _log

tarch::logging::Log toolbox::loadbalancing::CostMetrics::_log
staticprivate

Definition at line 128 of file CostMetrics.h.

◆ _minimumOfMaximumOfRankWeights

double toolbox::loadbalancing::CostMetrics::_minimumOfMaximumOfRankWeights
protected

Definition at line 108 of file CostMetrics.h.

◆ _minimumOfMaximumOfRankWeightsIn

double toolbox::loadbalancing::CostMetrics::_minimumOfMaximumOfRankWeightsIn
protected

Definition at line 125 of file CostMetrics.h.

◆ _minimumOfMaximumOfRankWeightsOut

double toolbox::loadbalancing::CostMetrics::_minimumOfMaximumOfRankWeightsOut
protected

Definition at line 126 of file CostMetrics.h.

◆ _minimumOfMaximumOfRankWeightsRequest

MPI_Request* toolbox::loadbalancing::CostMetrics::_minimumOfMaximumOfRankWeightsRequest
protected

Definition at line 116 of file CostMetrics.h.

Referenced by CostMetrics().


The documentation for this class was generated from the following files: