ug4
|
A load-balancer redistributes grids using the specified partitioner and process-hierarchy. More...
#include <load_balancer.h>
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) |
A load-balancer redistributes grids using the specified partitioner and process-hierarchy.
ug::LoadBalancer::LoadBalancer | ( | ) |
References ug::ProcessHierarchy::create(), m_balanceWeights, m_processHierarchy, and make_sp().
|
virtual |
|
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.
|
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.
|
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.
|
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().
|
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.
void ug::LoadBalancer::create_quality_record | ( | const char * | label | ) |
|
virtual |
References m_createVerticalInterfaces.
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().
|
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.
|
private |
References pcl::ProcessCommunicator::allreduce(), ug::MultiGrid::begin(), ug::Grid::distributed_grid_manager(), ug::MultiGrid::end(), SmartPtr< T, FreePolicy >::get(), ug::IBalanceWeights::get_weight(), ug::ProcessHierarchy::global_proc_com(), ug::ProcessHierarchy::hierarchy_level_from_grid_level(), SmartPtr< T, FreePolicy >::invalid(), ug::DistributedGridManager::is_ghost(), m_balanceWeights, m_mg, m_processHierarchy, make_sp(), ug::ProcessHierarchy::num_global_procs_involved(), ug::MultiGrid::num_levels(), PCL_RO_MAX, PCL_RO_MIN, PCL_RO_SUM, and pcl::ProcessCommunicator::size().
void ug::LoadBalancer::print_last_quality_record | ( | ) | const |
References m_qualityRecords, ug::Table< T >::num_cols(), ug::Table< T >::num_rows(), and UG_LOG.
void ug::LoadBalancer::print_quality_records | ( | ) | const |
References m_qualityRecords, and UG_LOG.
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.
References m_partitioner, and SmartPtr< T, FreePolicy >::valid().
|
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().
|
virtual |
If the balance falls below the given threshold, then rebalance will perform redistribution.
Set to 0.9 by default.
References m_balanceThreshold.
|
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.
References m_balanceWeights.
|
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.
|
virtual |
References m_mg.
Referenced by ug::DomainLoadBalancer< TDomain >::DomainLoadBalancer().
|
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.
References m_processHierarchy.
|
virtual |
Sets the partitioner which is used to partition the grid into balanced parts.
References m_partitioner, and partitioner.
|
private |
Referenced by rebalance(), and set_balance_threshold().
|
private |
Referenced by estimate_distribution_quality_impl(), LoadBalancer(), rebalance(), and set_balance_weights().
|
private |
Referenced by enable_vertical_interface_creation(), and rebalance().
|
private |
Referenced by rebalance(), and set_element_threshold().
|
private |
Referenced by estimate_distribution_quality(), estimate_distribution_quality_impl(), rebalance(), and set_grid().
|
private |
Referenced by problems_occurred(), rebalance(), and set_partitioner().
|
private |
|
private |
Referenced by create_quality_record(), print_last_quality_record(), and print_quality_records().
|
private |
Referenced by add_serializer(), and rebalance().