|
Peano
|
#include <AbstractLoadBalancing.h>


Public Member Functions | |
| AbstractLoadBalancing (Configuration *configuration, CostMetrics *costMetrics) | |
| Constructor. | |
| virtual | ~AbstractLoadBalancing () |
| Destructor. | |
| virtual std::string | toString () const |
| Create a string representation of load balancing object. | |
| virtual void | enable (bool) |
| Switch on/off. | |
| virtual bool | hasSplitRecently () const |
| Has mesh split recently. | |
| bool | isEnabled (bool globally) const |
| Is load balancing enabled. | |
| virtual int | getGlobalNumberOfTrees () const |
| Delegate to stats. | |
| virtual bool | hasStagnated () const |
| A load balancing can either be stagnating or be switched off for this predicate to hold. | |
| virtual void | finishSimulation () |
| virtual void | finishStep ()=0 |
| Finish the step. | |
| void | setConfigurationAndMetricsNullWithoutDelete () |
| This is only used when you concatenate balancing rules and you want to disable any deletion. | |
Static Public Attributes | |
| static constexpr int | NoHeaviestTreeAvailable = -1 |
| Is used by tree identification and either indicates that there are no trees at all or means that the heaviest tree is on the blacklist. | |
Protected Member Functions | |
| bool | fitsIntoMemory (State state) const |
| Ensure enough memory is left-over. | |
| bool | isInterRankBalancingBad () const |
| Is the balancing between the ranks ok. | |
| bool | isIntraRankBalancingBad () const |
| Is the balancing on the rank ok. | |
| bool | areRanksUnemployed () const |
| double | getWeightOfHeaviestLocalSpacetree () const |
| int | getIdOfHeaviestLocalSpacetree () const |
| Determines the maximum spacetree size a tree should have in the optimal case. | |
| int | getIdOfHeaviestLocalSpacetree (double tolerance) const |
| Similar to getIdOfHeaviestLocalSpacetree() but you might get one of the trees back that is close to the heaviest one up to tolerance. | |
Protected Attributes | |
| Blacklist | _blacklist |
| Statistics | _statistics |
| Configuration * | _configuration |
| CostMetrics * | _costMetrics |
| State | _state |
| Ensure that you invoke. | |
Static Protected Attributes | |
| static tarch::logging::Log | _log |
Definition at line 24 of file AbstractLoadBalancing.h.
| toolbox::loadbalancing::AbstractLoadBalancing::AbstractLoadBalancing | ( | Configuration * | configuration, |
| CostMetrics * | costMetrics ) |
Constructor.
Data ownership is handed over to the load balancing, i.e. the balancing has to delete the configuration object unless you pass in the nullptr. If you pass in the nullptr, you cannot use the object, so this should be done with care by any subclass.
Many implementations of AbstractLoadBalancing change the _state field immediately in their constructor. Please ensure that you invoke
_statistics.notifyOfStateChange(_state);
afterwards to ensure that the statistics are correct right from the start.
I originally thought it might be reasonable to add assertions to ensure that configuration and costMetrics are not nullptr. However, there are specific hard-coded load balancing schemes which do explicitly use nullptr arguments. Hardcoded is the prime example. Therefore, I do not nullptr checks here and I leave it to subclasses to add the corresponding assertions if they require proper pointers here.
|
virtual |
Destructor.
Free the configuration and cost metrics objects. See the discussion in the constructor for contextual information re the validity of nullptr arguments here.
|
protected |
|
virtual |
Switch on/off.
Reimplemented in toolbox::loadbalancing::strategies::cascade::Cascade< HostedLoadBalancing0, HostedLoadBalancing1 >, and toolbox::loadbalancing::strategies::NoLoadBalancing.
Referenced by toolbox::loadbalancing::strategies::cascade::Cascade< HostedLoadBalancing0, HostedLoadBalancing1 >::enable().

|
virtual |
|
pure virtual |
Finish the step.
No matter what you do here, you have to invoke
_statistics.updateGlobalView();
_blacklist.update();
in this routine.
Implemented in toolbox::loadbalancing::strategies::cascade::Cascade< HostedLoadBalancing0, HostedLoadBalancing1 >, toolbox::loadbalancing::strategies::Hardcoded, toolbox::loadbalancing::strategies::NoLoadBalancing, toolbox::loadbalancing::strategies::RecursiveBipartition, toolbox::loadbalancing::strategies::SplitOversizedTree, toolbox::loadbalancing::strategies::SpreadOut, toolbox::loadbalancing::strategies::SpreadOutHierarchically, and toolbox::loadbalancing::strategies::SpreadOutOnceGridStagnates.
|
protected |
Ensure enough memory is left-over.
|
virtual |
Delegate to stats.
Reimplemented in toolbox::loadbalancing::strategies::cascade::Cascade< HostedLoadBalancing0, HostedLoadBalancing1 >.
|
protected |
Determines the maximum spacetree size a tree should have in the optimal case.
As this routine does not really adopt the blacklist, it can introduce cyclles: If we repeatedly try to split the same rank this means that we have tried to split it, have not been successful, and tried again. This can happen, as not all trees can be split. See peano4::grid::Spacetree::isCellTopDownSplitCandidate() and peano4::grid::Spacetree::isCellBottomUpSplitCandidate() for a discussion which cells can be split and which can't. As not all cells can't be given away, not all trees can be split up.
If two or more trees have the same weight, the routine should randomly return one of them.
| tolerance | By default, you get the last heaviest tree. But you can ask for a random tree |
|
protected |
Similar to getIdOfHeaviestLocalSpacetree() but you might get one of the trees back that is close to the heaviest one up to tolerance.
Tolerance here is the relative difference: So you are guaranteed that
\( m_i \geq tolerance \cdot m_{max} \)
or
\( \frac{m_i}{m_{max}} \geq tolerance \)
|
protected |
|
virtual |
Has mesh split recently.
Means that mesh has split over the past three iterations. The number three is hard-coded, as we need three iterations to perform a proper split:
If we have then not come to the conclusion that we should immediately split again, then we haven't split recently.
Reimplemented in toolbox::loadbalancing::strategies::cascade::Cascade< HostedLoadBalancing0, HostedLoadBalancing1 >.
|
virtual |
A load balancing can either be stagnating or be switched off for this predicate to hold.
Reimplemented in toolbox::loadbalancing::strategies::cascade::Cascade< HostedLoadBalancing0, HostedLoadBalancing1 >.
| bool toolbox::loadbalancing::AbstractLoadBalancing::isEnabled | ( | bool | globally | ) | const |
Is load balancing enabled.
Clarifies whether load balancing is, in principle, enabled. We we return true, it means that we are not disabled. The balancer might still be temporarily suspended.
|
protected |
Is the balancing between the ranks ok.
This operation checks if the inter-rank load decomposition does violate the overall load balancing constraints. The global balancing is determined by a cascade of checks:
|
protected |
Is the balancing on the rank ok.
Similar to isInterRankBalancingBad(), this operation runs through a series of checks:
| void toolbox::loadbalancing::AbstractLoadBalancing::setConfigurationAndMetricsNullWithoutDelete | ( | ) |
This is only used when you concatenate balancing rules and you want to disable any deletion.
Please do not invoke it unless you know exactly what you are doing.
|
virtual |
Create a string representation of load balancing object.
Generic string serialisation. You might want to extend it. Therefore, the routine is labelled as virtual.
The routine has to be able to deal with the fact that _costMetrics might be nullptr according to AbstractLoadBalancing(). The configuration in return does not feed into toString(). Therefore, we don't have to check if it is pointing to nullptr.
Reimplemented in toolbox::loadbalancing::strategies::RecursiveBipartition, and toolbox::loadbalancing::strategies::SplitOversizedTree.
|
protected |
Definition at line 155 of file AbstractLoadBalancing.h.
|
protected |
Definition at line 159 of file AbstractLoadBalancing.h.
|
protected |
Definition at line 161 of file AbstractLoadBalancing.h.
|
staticprotected |
Definition at line 153 of file AbstractLoadBalancing.h.
|
protected |
Ensure that you invoke.
_statistics.notifyOfStateChange(_state)
whenever you change the state. Otherwise, the MPI will have an invalid view of the whole world.
Definition at line 171 of file AbstractLoadBalancing.h.
Referenced by toolbox::loadbalancing::strategies::cascade::Cascade< HostedLoadBalancing0, HostedLoadBalancing1 >::hasStagnated().
|
protected |
Definition at line 157 of file AbstractLoadBalancing.h.
|
staticconstexpr |
Is used by tree identification and either indicates that there are no trees at all or means that the heaviest tree is on the blacklist.
See implementation remarks in class description.
Definition at line 31 of file AbstractLoadBalancing.h.