ug4
ug::LoadBalancer Class Reference

A load-balancer redistributes grids using the specified partitioner and process-hierarchy. More...

#include <load_balancer.h>

+ Inheritance diagram for ug::LoadBalancer:

Public Member Functions

void create_quality_record (const char *label)
 
virtual void enable_vertical_interface_creation (bool enable)
 
 LoadBalancer ()
 
void print_last_quality_record () const
 
void print_quality_records () const
 
bool problems_occurred ()
 indicates whether problems occurred during the last rebalancing. More...
 
virtual bool rebalance ()
 performs load balancing if the balance is too bad or if a distribution level has been reached. More...
 
virtual void set_balance_threshold (number threshold)
 If the balance falls below the given threshold, then rebalance will perform redistribution. More...
 
virtual void set_balance_weights (SPBalanceWeights balanceWeights)
 Sets a callback class which provides the balance weight for a given element. More...
 
virtual void set_element_threshold (size_t threshold)
 
virtual void set_grid (MultiGrid *mg)
 
virtual void set_next_process_hierarchy (SPProcessHierarchy procHierarchy)
 Sets a callback class which provides connection weights between two neighbor elements. More...
 
virtual void set_partitioner (SPPartitioner partitioner)
 Sets the partitioner which is used to partition the grid into balanced parts. More...
 
virtual ~LoadBalancer ()
 
virtual number estimate_distribution_quality (std::vector< number > *pLvlQualitiesOut)
 
number estimate_distribution_quality ()
 
virtual void add_serializer (SPVertexDataSerializer cb)
 add serialization callbacks. More...
 
virtual void add_serializer (SPEdgeDataSerializer cb)
 add serialization callbacks. More...
 
virtual void add_serializer (SPFaceDataSerializer cb)
 add serialization callbacks. More...
 
virtual void add_serializer (SPVolumeDataSerializer cb)
 add serialization callbacks. More...
 
virtual void add_serializer (SPGridDataSerializer cb)
 add serialization callbacks. More...
 

Private Member Functions

template<class TElem >
number estimate_distribution_quality_impl (std::vector< number > *pLvlQualitiesOut)
 

Private Attributes

number m_balanceThreshold
 
SPBalanceWeights m_balanceWeights
 
bool m_createVerticalInterfaces
 
size_t m_elementThreshold
 
MultiGridm_mg
 
SPPartitioner m_partitioner
 
SPProcessHierarchy m_processHierarchy
 
StringStreamTable m_qualityRecords
 
GridDataSerializationHandler m_serializer
 

Detailed Description

A load-balancer redistributes grids using the specified partitioner and process-hierarchy.

Constructor & Destructor Documentation

◆ LoadBalancer()

ug::LoadBalancer::LoadBalancer ( )

◆ ~LoadBalancer()

ug::LoadBalancer::~LoadBalancer ( )
virtual

Member Function Documentation

◆ add_serializer() [1/5]

virtual void ug::LoadBalancer::add_serializer ( SPEdgeDataSerializer  cb)
inlinevirtual

add serialization callbacks.

Used when the grid is being distributed to pack data associated with grid objects or associated classes like subset-handlers.

References ug::GridDataSerializationHandler::add(), and m_serializer.

◆ add_serializer() [2/5]

virtual void ug::LoadBalancer::add_serializer ( SPFaceDataSerializer  cb)
inlinevirtual

add serialization callbacks.

Used when the grid is being distributed to pack data associated with grid objects or associated classes like subset-handlers.

References ug::GridDataSerializationHandler::add(), and m_serializer.

◆ add_serializer() [3/5]

virtual void ug::LoadBalancer::add_serializer ( SPGridDataSerializer  cb)
inlinevirtual

add serialization callbacks.

Used when the grid is being distributed to pack data associated with grid objects or associated classes like subset-handlers.

References ug::GridDataSerializationHandler::add(), and m_serializer.

◆ add_serializer() [4/5]

virtual void ug::LoadBalancer::add_serializer ( SPVertexDataSerializer  cb)
inlinevirtual

add serialization callbacks.

Used when the grid is being distributed to pack data associated with grid objects or associated classes like subset-handlers.

References ug::GridDataSerializationHandler::add(), and m_serializer.

Referenced by ug::DomainLoadBalancer< TDomain >::DomainLoadBalancer().

◆ add_serializer() [5/5]

virtual void ug::LoadBalancer::add_serializer ( SPVolumeDataSerializer  cb)
inlinevirtual

add serialization callbacks.

Used when the grid is being distributed to pack data associated with grid objects or associated classes like subset-handlers.

References ug::GridDataSerializationHandler::add(), and m_serializer.

◆ create_quality_record()

void ug::LoadBalancer::create_quality_record ( const char *  label)

◆ enable_vertical_interface_creation()

void ug::LoadBalancer::enable_vertical_interface_creation ( bool  enable)
virtual

◆ estimate_distribution_quality() [1/2]

number ug::LoadBalancer::estimate_distribution_quality ( )

The returned distribution quality represents the global quality of the elements of highest dimension and is the same on all processes. You may optionally specify a pointer to a std::vector which will be filled with the distribution-qualities for each level. By default the pointer is set to NULL and no level-qualities are thus returned. If a process doesn't participate on a given level, it will write -1 to the corresponding entry in pLvlQualitiesOut.

Referenced by create_quality_record(), and rebalance().

◆ estimate_distribution_quality() [2/2]

number ug::LoadBalancer::estimate_distribution_quality ( std::vector< number > *  pLvlQualitiesOut)
virtual

The returned distribution quality represents the global quality of the elements of highest dimension and is the same on all processes. You may optionally specify a pointer to a std::vector which will be filled with the distribution-qualities for each level. By default the pointer is set to NULL and no level-qualities are thus returned. If a process doesn't participate on a given level, it will write -1 to the corresponding entry in pLvlQualitiesOut.

References pcl::ProcessCommunicator::allreduce(), ug::EDGE, ug::FACE, m_mg, ug::MultiGrid::num(), PCL_RO_MAX, ug::VERTEX, and ug::VOLUME.

◆ estimate_distribution_quality_impl()

◆ print_last_quality_record()

void ug::LoadBalancer::print_last_quality_record ( ) const

◆ print_quality_records()

void ug::LoadBalancer::print_quality_records ( ) const

References m_qualityRecords, and UG_LOG.

◆ problems_occurred()

bool ug::LoadBalancer::problems_occurred ( )

indicates whether problems occurred during the last rebalancing.

This can e.g. happen if the partitioner has problems to create a partition-map which fullfills the given specifications.

Note
if rebalance returns true, still performed rebalancing, even if problems occurred. However, the new partition may not fullfill all given specifications.

References m_partitioner, and SmartPtr< T, FreePolicy >::valid().

◆ rebalance()

bool ug::LoadBalancer::rebalance ( )
virtual

performs load balancing if the balance is too bad or if a distribution level has been reached.

The balance is calculated using the provieded BalanceWeights class. If an imbalance is detected (minBalanceWeight / maxBalanceWeight < balanceThreshold) on a given set of processes, then redistribution will be performed.

If a distribution level has been reached, e.g. due to refinement, the grid will be redistributed on that level even if the balance is perfectly fine.

Note that no redistribution is performed on a given level, if the number of elements on the target process would in average be below the element threshold.

During redistribution the LoadBalancer tries to distribute elements such that the sum of balance weights of elements on each process is the same on a given level. Furthermore it tries to minimize the connection-weights of edges which connect elements on different processes.

The method returns false if e.g. problems during partitioning occurred.

References ug::DistributeGrid(), estimate_distribution_quality(), GDIST_PROFILE_FUNC, ug::LIB_GRID, m_balanceThreshold, m_balanceWeights, m_createVerticalInterfaces, m_elementThreshold, m_mg, m_partitioner, m_processHierarchy, m_serializer, PCL_DEBUG_BARRIER_ALL, UG_COND_THROW, UG_DLOG, UG_LOG, UG_THROW, and SmartPtr< T, FreePolicy >::valid().

◆ set_balance_threshold()

void ug::LoadBalancer::set_balance_threshold ( number  threshold)
virtual

If the balance falls below the given threshold, then rebalance will perform redistribution.

Set to 0.9 by default.

References m_balanceThreshold.

◆ set_balance_weights()

void ug::LoadBalancer::set_balance_weights ( SPBalanceWeights  balanceWeights)
virtual

Sets a callback class which provides the balance weight for a given element.

Balance weights are used to calculate the current balance and to specify the weight of an element during redistribution.

Note
balance weights are only used if the given partitioner supports them.

References m_balanceWeights.

◆ set_element_threshold()

void ug::LoadBalancer::set_element_threshold ( size_t  threshold)
virtual

If distribution on a given level would lead to less elements per process than the given threshold (in average), then no redistribution will be performed on that level. Default is 1.

References m_elementThreshold.

◆ set_grid()

void ug::LoadBalancer::set_grid ( MultiGrid mg)
virtual

◆ set_next_process_hierarchy()

void ug::LoadBalancer::set_next_process_hierarchy ( SPProcessHierarchy  procHierarchy)
virtual

Sets a callback class which provides connection weights between two neighbor elements.

The higher the weight, the higher the likelyhood that the two elements will reside on the same process after redistribution.

Note
connection weights are only used if the given partitioner supports them. Defines the process hierarchy which will be used during the following calls of rebalance

References m_processHierarchy.

◆ set_partitioner()

void ug::LoadBalancer::set_partitioner ( SPPartitioner  partitioner)
virtual

Sets the partitioner which is used to partition the grid into balanced parts.

References m_partitioner, and partitioner.

Member Data Documentation

◆ m_balanceThreshold

number ug::LoadBalancer::m_balanceThreshold
private

Referenced by rebalance(), and set_balance_threshold().

◆ m_balanceWeights

SPBalanceWeights ug::LoadBalancer::m_balanceWeights
private

◆ m_createVerticalInterfaces

bool ug::LoadBalancer::m_createVerticalInterfaces
private

◆ m_elementThreshold

size_t ug::LoadBalancer::m_elementThreshold
private

Referenced by rebalance(), and set_element_threshold().

◆ m_mg

◆ m_partitioner

SPPartitioner ug::LoadBalancer::m_partitioner
private

◆ m_processHierarchy

◆ m_qualityRecords

StringStreamTable ug::LoadBalancer::m_qualityRecords
private

◆ m_serializer

GridDataSerializationHandler ug::LoadBalancer::m_serializer
private

Referenced by add_serializer(), and rebalance().


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