chombo-discharge
Static Public Member Functions | Static Protected Member Functions | List of all members
LoadBalancing Class Reference

Static class which contains various load balancing routines. More...

#include <CD_LoadBalancing.H>

Static Public Member Functions

template<class T >
static void makeBalance (Vector< int > &a_ranks, const Vector< T > &a_loads, const Vector< Box > &a_boxes)
 Load balancing, assigning ranks to boxes. More...
 
template<class T >
static void makeBalance (Vector< int > &a_ranks, Loads &a_rankLoads, const Vector< T > &a_boxLoads, const Vector< Box > &a_boxes)
 Load balancing, assigning ranks to boxes. More...
 
template<typename T >
static void sort (Vector< Vector< Box >> &a_boxes, Vector< Vector< T >> &a_loads, const BoxSorting a_whichSorting)
 Sorts boxes and loads over a hierarchy according to some sorting criterion. More...
 
template<typename T >
static void sort (Vector< Box > &a_boxes, Vector< T > &a_loads, const BoxSorting a_which)
 Sorting function for sorting boxes and loads. More...
 
static void sort (Vector< Box > &a_boxes, const BoxSorting a_which)
 Sorts boxes (according to sorting argument) More...
 
static void gatherBoxes (Vector< Box > &a_boxes)
 Gather boxes. More...
 
static void gatherLoads (Vector< Real > &a_loads)
 Gather computational loads. More...
 
static void gatherLoads (Vector< int > &a_loads)
 Gather compute loads. More...
 
static void gatherLoads (Vector< long > &a_loads)
 Gather compute loads. More...
 
static void gatherBoxesAndLoads (Vector< Box > &a_boxes, Vector< int > &a_loads)
 Gather boxes and loads. More...
 

Static Protected Member Functions

template<class T >
static std::vector< std::pair< Box, T > > packPairs (const Vector< Box > &a_boxes, const Vector< T > &a_loads)
 Utility function which packs boxes and loads into a vector of pairs. More...
 
template<class T >
static void unpackPairs (Vector< Box > &a_boxes, Vector< T > &a_loads, const std::vector< std::pair< Box, T >> &a_pairs)
 Splits vector pair into separate boxes and loads. More...
 
template<class T >
static void standardSort (Vector< Box > &a_boxes, Vector< T > &a_loads)
 Standard box sorting, calls C++ std::sort. More...
 
template<class T >
static void shuffleSort (Vector< Box > &a_boxes, Vector< T > &a_loads)
 Randomly shuffles boxes and loads. More...
 
template<class T >
static void mortonSort (Vector< Box > &a_boxes, Vector< T > &a_loads)
 Sort boxes using Morton code. More...
 
template<class T >
static bool mortonComparator (const int a_maxBits, const std::pair< Box, T > &a_lhs, const std::pair< Box, T > &a_rhs)
 Morton comparator. More...
 
static int maxBits (std::vector< Box >::iterator a_first, std::vector< Box >::iterator a_last)
 Utility function for Morton sorting which needs the maximum bits. More...
 

Detailed Description

Static class which contains various load balancing routines.

Member Function Documentation

◆ gatherBoxes()

void LoadBalancing::gatherBoxes ( Vector< Box > &  a_boxes)
static

Gather boxes.

Parameters
[in,out]a_boxesLocal boxes
Returns
On output, a_boxes contains the global boxes.

◆ gatherBoxesAndLoads()

void LoadBalancing::gatherBoxesAndLoads ( Vector< Box > &  a_boxes,
Vector< int > &  a_loads 
)
static

Gather boxes and loads.

Parameters
[in,out]a_boxesGrid boxes
[in,out]a_loadsComputational loads
Returns
On output, a_boxes and a_loads have been globally gathered from all ranks.

◆ gatherLoads() [1/3]

void LoadBalancing::gatherLoads ( Vector< int > &  a_loads)
static

Gather compute loads.

Parameters
[in,out]a_loadsComputational loads
Returns
On output, a_loads contains the loads from all ranks.

◆ gatherLoads() [2/3]

void LoadBalancing::gatherLoads ( Vector< long > &  a_loads)
static

Gather compute loads.

Parameters
[in,out]a_loadsComputational loads
Returns
On output, a_loads contains the loads from all ranks.

◆ gatherLoads() [3/3]

void LoadBalancing::gatherLoads ( Vector< Real > &  a_loads)
static

Gather computational loads.

Parameters
[in,out]a_loadsComputational loads
Returns
On output, a_loads contains the loads from all ranks.

◆ makeBalance() [1/2]

template<class T >
void LoadBalancing::makeBalance ( Vector< int > &  a_ranks,
const Vector< T > &  a_loads,
const Vector< Box > &  a_boxes 
)
static

Load balancing, assigning ranks to boxes.

This version does not take into loads already assigned to ranks and will thus always start assigning from rank 0.

Parameters
[out]a_ranksVector containing processor IDs corresponding to boxes (and loads)
[in]a_loadsComputational loads
[in]a_boxesGrid boxes

◆ makeBalance() [2/2]

template<class T >
void LoadBalancing::makeBalance ( Vector< int > &  a_ranks,
Loads a_rankLoads,
const Vector< T > &  a_boxLoads,
const Vector< Box > &  a_boxes 
)
static

Load balancing, assigning ranks to boxes.

This version takes into account loads already assigned to ranks, and assigns grid subsets to the least loaded ranks.

Parameters
[out]a_ranksVector containing processor IDs corresponding to boxes (and loads)
[in,out]a_rankLoadsMPI rank loads so far
[in]a_boxLoadsComputational loads for each box
[in]a_boxesGrid boxes

◆ maxBits()

int LoadBalancing::maxBits ( std::vector< Box >::iterator  a_first,
std::vector< Box >::iterator  a_last 
)
staticprotected

Utility function for Morton sorting which needs the maximum bits.

Parameters
[in]a_firstIterator
[in]a_secondIterator

◆ mortonComparator()

template<class T >
bool LoadBalancing::mortonComparator ( const int  a_maxBits,
const std::pair< Box, T > &  a_lhs,
const std::pair< Box, T > &  a_rhs 
)
staticprotected

Morton comparator.

Parameters
[in]a_maxBitsMaximum bits
[in]a_lhsLeft hand side
[in]a_rhsRight hand side
Returns
Returns true if a_lhs.first has a lower Morton index than a_rhs.first.

◆ mortonSort()

template<class T >
void LoadBalancing::mortonSort ( Vector< Box > &  a_boxes,
Vector< T > &  a_loads 
)
staticprotected

Sort boxes using Morton code.

Parameters
[in,out]a_boxesGrid boxes to be sorted.
[in,out]a_loadsComputational loads to be sorted.

On output, a_boxes and a_loads are Morton sorted.

◆ packPairs()

template<class T >
std::vector< std::pair< Box, T > > LoadBalancing::packPairs ( const Vector< Box > &  a_boxes,
const Vector< T > &  a_loads 
)
staticprotected

Utility function which packs boxes and loads into a vector of pairs.

Parameters
[in]a_boxesGrid boxes
[in]a_loadsComputational loads

◆ shuffleSort()

template<class T >
void LoadBalancing::shuffleSort ( Vector< Box > &  a_boxes,
Vector< T > &  a_loads 
)
staticprotected

Randomly shuffles boxes and loads.

Parameters
[in,out]a_boxesGrid boxes to be shuffled.
[in,out]a_loadsComputational loads to be shuffled.

This shuffles the boxes and loads so that the box distribution is random.

◆ sort() [1/3]

void LoadBalancing::sort ( Vector< Box > &  a_boxes,
const BoxSorting  a_which 
)
static

Sorts boxes (according to sorting argument)

Parameters
[in,out]a_boxesGrid boxes

◆ sort() [2/3]

template<typename T >
void LoadBalancing::sort ( Vector< Box > &  a_boxes,
Vector< T > &  a_loads,
const BoxSorting  a_which 
)
static

Sorting function for sorting boxes and loads.

Parameters
[in,out]a_boxesGrid boxes
[in,out]a_loadsComputational loads
[in]a_whichSorting
Returns
Returns a_boxes and a_loads, sorting according to the argument a_whichSorting.

◆ sort() [3/3]

template<typename T >
void LoadBalancing::sort ( Vector< Vector< Box >> &  a_boxes,
Vector< Vector< T >> &  a_loads,
const BoxSorting  a_whichSorting 
)
static

Sorts boxes and loads over a hierarchy according to some sorting criterion.

Parameters
[in,out]a_boxesGrid boxes
[in,out]a_loadsComputational loads
[in]a_whichSorting
Returns
Returns a_boxes and a_loads, sorting according to the argument a_whichSorting.

◆ standardSort()

template<class T >
void LoadBalancing::standardSort ( Vector< Box > &  a_boxes,
Vector< T > &  a_loads 
)
staticprotected

Standard box sorting, calls C++ std::sort.

Parameters
[in,out]a_boxesBoxes to be sorted.
[in,out]a_loadsLoads to be sorted.

This uses lexicographical indexing of boxes. On output, the boxes/loads are sorted with this ordering.

◆ unpackPairs()

template<class T >
void LoadBalancing::unpackPairs ( Vector< Box > &  a_boxes,
Vector< T > &  a_loads,
const std::vector< std::pair< Box, T >> &  a_pairs 
)
staticprotected

Splits vector pair into separate boxes and loads.

Parameters
[out]a_boxesBoxes.
[out]a_loadsLoads.
[out]a_pairsBoxes and loads, stored as a pair.

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