chombo-discharge
Loading...
Searching...
No Matches
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.
 
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.
 
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.
 
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.
 
static void sort (Vector< Box > &a_boxes, const BoxSorting a_which)
 Sorts boxes (according to sorting argument)
 
static void gatherBoxes (Vector< Box > &a_boxes)
 Gather boxes.
 
static void gatherLoads (Vector< Real > &a_loads)
 Gather computational loads.
 
static void gatherLoads (Vector< int > &a_loads)
 Gather compute loads.
 
static void gatherLoads (Vector< long > &a_loads)
 Gather compute loads.
 
static void gatherBoxesAndLoads (Vector< Box > &a_boxes, Vector< int > &a_loads)
 Gather boxes and loads.
 

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.
 
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.
 
template<class T >
static void standardSort (Vector< Box > &a_boxes, Vector< T > &a_loads)
 Standard box sorting, calls C++ std::sort.
 
template<class T >
static void shuffleSort (Vector< Box > &a_boxes, Vector< T > &a_loads)
 Randomly shuffles boxes and loads.
 
template<class T , int DIM>
static void sortSFC (Vector< Box > &a_boxes, Vector< T > &a_loads, const std::function< uint64_t(const std::array< uint32_t, DIM >)> &a_sfcEncoder) noexcept
 Generic SFC sorting function.
 
template<int DIM>
static uint64_t mortonIndex (const std::array< uint32_t, DIM > a_coords) noexcept
 Helper function for computing a Morton code using 21 bits per direction.
 
template<int DIM>
static uint64_t hilbertIndex (const std::array< uint32_t, DIM > &a_coords)
 Helper function for computing a Hilbert index.
 

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

◆ mortonIndex()

template<int DIM>
uint64_t LoadBalancing::mortonIndex ( const std::array< uint32_t, DIM a_coords)
staticprotectednoexcept

Helper function for computing a Morton code using 21 bits per direction.

Parameters
[in]a_coords

◆ 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.

◆ sortSFC()

template<class T , int DIM>
void LoadBalancing::sortSFC ( Vector< Box > &  a_boxes,
Vector< T > &  a_loads,
const std::function< uint64_t(const std::array< uint32_t, DIM >)> &  a_sfcEncoder 
)
staticprotectednoexcept

Generic SFC sorting function.

Parameters
[in,out]a_boxesGrid boxes to be sorted
[in,out]a_loadsComputational loads to be sorted along with the boxes.
[in]a_sfcEncoderFunction for turning a grid index into an SFC index.

◆ 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: