Proto  3.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Proto::BoxPartition Class Reference

Box Partition. More...

#include <Proto_BoxPartition.H>

Public Member Functions

 BoxPartition (const ProblemDomain &a_patchDomain)
 
 BoxPartition (const ProblemDomain &a_patchDomain, const std::vector< Point > &a_patches)
 Constructor. More...
 
 BoxPartition (const ProblemDomain &a_patchDomain, const std::vector< Point > &a_patches, unsigned int a_startProc, unsigned int a_endProc)
 Constructor. More...
 
 BoxPartition (const ProblemDomain &a_patchDomain, const std::vector< std::pair< Point, unsigned int >> &a_assignedPatches)
 Constructor (Exteral Load Balancing) More...
 
void define (const ProblemDomain &a_patchDomain, const std::vector< Point > &a_patches, unsigned int a_startProc, unsigned int a_endProc)
 Define. More...
 
void define (const ProblemDomain &a_patchDomain, const std::vector< std::pair< Point, unsigned int >> &a_assignedPatches)
 Define. More...
 
std::shared_ptr< BoxPartitionsortByProc () const
 Sort By Processor. More...
 
bool isSorted () const
 
void loadBalance (std::vector< Point > &a_patches, unsigned int a_startProc, unsigned int a_endProc)
 Load Balance. More...
 
template<typename... vals>
void loadAssign (std::vector< Point > &a_patches, vals... args)
 Load Assign. More...
 
void loadAssign (std::vector< std::pair< int, unsigned int >> &a_assignment, std::vector< Point > &a_patches)
 Load Assign. More...
 
void loadAssign (std::vector< std::pair< int, unsigned int >> &a_assignment)
 Load Assign. More...
 
bool compatible (const BoxPartition &a_rhs)
 Compatibility Query. More...
 
unsigned int numProcs () const
 Number of Processes. More...
 
unsigned int numBoxes () const
 Number of Boxes (Global) More...
 
unsigned int numBoxes (unsigned int a_proc) const
 Number of Boxes (Local) More...
 
const std::vector< std::pair< Point, unsigned int > > & partition () const
 Access Partition. More...
 
unsigned int procStartIndex (unsigned int a_proc) const
 Get Processor Starting Index. More...
 
unsigned int procEndIndex (unsigned int a_proc) const
 Get Processor Ending Index. More...
 
unsigned int globalIndex (unsigned int a_localIndex, unsigned int a_proc)
 Get Global Index. More...
 
unsigned int localIndex (unsigned int a_globalIndex, unsigned int a_proc)
 Get Local Index. More...
 
unsigned int find (Point a_pt)
 Get Patch Index. More...
 
const ProblemDomaindomain () const
 
void print () const
 Print. More...
 
bool doLoadBalance () const
 Check If This Controls Load Balancing. More...
 
template<>
void unpack (std::vector< Point > &a_patches, unsigned int a_globalIndex, int a_proc, unsigned int a_num)
 

Private Member Functions

bool checkProcSorting (const std::vector< std::pair< Point, unsigned int >> a_data)
 
template<typename... vals>
void unpack (std::vector< Point > &a_patches, unsigned int a_globalIndex, int a_proc, unsigned int a_num, vals... a_args)
 
void assign (std::vector< Point > &a_patches, unsigned int a_globalIndex, int a_proc, unsigned int a_num)
 

Private Attributes

bool m_procSorted = true
 
bool m_doLoadBalance = true
 
ProblemDomain m_patchDomain
 Domain in patch space. More...
 
std::unordered_map< uint64_t, int > m_indexMap
 Maps Morton index to global index. More...
 
std::unordered_map< unsigned int, std::pair< unsigned int, unsigned int > > m_procMap
 Maps processor number to global index. More...
 
std::vector< std::pair< Point, unsigned int > > m_partition
 Maps each patch to a proc. More...
 
std::unordered_map< unsigned int, std::vector< unsigned int > > m_procMapUnsorted
 Same as procMap for unsorted data. More...
 

Detailed Description

Box Partition.

This data structure defines the "layoutness" of a collection of patches. More concretely, Box Partition encapsulates the information of which tile locations in a domain have a patch, which tiles are empty, and which MPI processes are responsible for which patch.

Two objects with the same (or equivalent) Box Partitions are "compatible" with one another in the sense of DataIterator because the two objects in question are guaranteed to have the same number of patches for a given MPI process.

Constructor & Destructor Documentation

◆ BoxPartition() [1/4]

Proto::BoxPartition::BoxPartition ( const ProblemDomain a_patchDomain)
inline

Referenced by BoxPartition().

◆ BoxPartition() [2/4]

Proto::BoxPartition::BoxPartition ( const ProblemDomain a_patchDomain,
const std::vector< Point > &  a_patches 
)
inline

Constructor.

Create a BoxPartition from a "patch domain" and an array of patches in that domain. Here patches are assumed to have a uniform size so as to evenly tile a rectangular layout. By default, patches will be distributed evenly across all available processes.

Parameters
a_patchDomainA ProblemDomain where each Point corresponds to a Box
a_patchesA vector of Point each representing a patch

◆ BoxPartition() [3/4]

Proto::BoxPartition::BoxPartition ( const ProblemDomain a_patchDomain,
const std::vector< Point > &  a_patches,
unsigned int  a_startProc,
unsigned int  a_endProc 
)
inline

Constructor.

Create a BoxPartition from a "patch domain" and an array of patches in that domain. Here patches are assumed to have a uniform size so as to evenly tile a rectangular layout. Patches will be distributed evenly across the range of processes in [a_startProc, a_endProc)

Parameters
a_patchDomainA ProblemDomain where each Point corresponds to a Box
a_patchesA vector of Point each representing a patch

References BoxPartition().

◆ BoxPartition() [4/4]

Proto::BoxPartition::BoxPartition ( const ProblemDomain a_patchDomain,
const std::vector< std::pair< Point, unsigned int >> &  a_assignedPatches 
)
inline

Constructor (Exteral Load Balancing)

Member Function Documentation

◆ define() [1/2]

void Proto::BoxPartition::define ( const ProblemDomain a_patchDomain,
const std::vector< Point > &  a_patches,
unsigned int  a_startProc,
unsigned int  a_endProc 
)
inline

Define.

Create a BoxPartition from a "patch domain" and an array of patches in that domain. Here patches are assumed to have a uniform size so as to evenly tile a rectangular layout. Patches will be distributed evenly across the range of processes in [a_startProc, a_endProc)

Parameters
a_patchDomainA ProblemDomain where each Point corresponds to a Box
a_patchesA vector of Point each representing a patch

◆ define() [2/2]

void Proto::BoxPartition::define ( const ProblemDomain a_patchDomain,
const std::vector< std::pair< Point, unsigned int >> &  a_assignedPatches 
)
inline

Define.

Create a BoxPartition from a set of patches that have already been assigned to processors. Use this function if load balancing is executed externally.

Parameters
a_patchDomainA ProblemDomain where each Point corresponds to a Box
a_assignedPatchesA vector of patch-processor pairs

◆ sortByProc()

std::shared_ptr< BoxPartition > Proto::BoxPartition::sortByProc ( ) const
inline

Sort By Processor.

Return a new BoxPartition that is identical to *this except that it is sorted by processor

◆ isSorted()

bool Proto::BoxPartition::isSorted ( ) const
inline

References loadBalance(), and m_procSorted.

◆ loadBalance()

void Proto::BoxPartition::loadBalance ( std::vector< Point > &  a_patches,
unsigned int  a_startProc,
unsigned int  a_endProc 
)
inline

Load Balance.

Rebalance the load of this by distributing the input patches evenly across the range of processes in [a_startProc, a_endProc) The input patches must be contained in the existing ProblemDomain of this

Parameters
a_patchesA vector of patches represented as Points
a_patchDomainA ProblemDomain where each Point corresponds to a Box
a_patchesA vector of Point each representing a patch

Referenced by isSorted().

◆ loadAssign() [1/3]

template<typename... vals>
void Proto::BoxPartition::loadAssign ( std::vector< Point > &  a_patches,
vals...  args 
)
inline

Load Assign.

Manually assign the load of this using the syntax loadAssign(patches, P0, N0, P1, N1, ..., Pk, Nk) where process Pi is assigned Ni boxes. The sum over all Ni should be equal to the length of the patch vector.

Parameters
a_patchesA vector of patches represented as Points
a_patchDomainA ProblemDomain where each Point corresponds to a Box
a_patchesA vector of Point each representing a patch

◆ loadAssign() [2/3]

void Proto::BoxPartition::loadAssign ( std::vector< std::pair< int, unsigned int >> &  a_assignment,
std::vector< Point > &  a_patches 
)
inline

Load Assign.

Manually assign the load of this layout. The first input is a vector of pair<int, unsigned int> where the first entry of each pair is a process and the second is the number of boxes to be assigned to that process. The second input is the set of patches themselves represented as Points.

Parameters
a_assignmentA vector of proc-assignment pairs
a_patchesA vector of patches represented as Points

◆ loadAssign() [3/3]

void Proto::BoxPartition::loadAssign ( std::vector< std::pair< int, unsigned int >> &  a_assignment)
inline

Load Assign.

Manually (re)assign the load of this layout. The input is a vector of pair<int, unsigned int> where the first entry of each pair is a process and the second is the number of boxes to be assigned to that process. The patches themselves are unchanged by this function.

Parameters
a_assignmentA vector of proc-assignment pairs
a_patchesA vector of patches represented as Points

◆ compatible()

bool Proto::BoxPartition::compatible ( const BoxPartition a_rhs)
inline

Compatibility Query.

Determine if this has the same layout structure as another BoxPartition.

◆ numProcs()

unsigned int Proto::BoxPartition::numProcs ( ) const
inline

Number of Processes.

Query the number of processes assigned to this BoxPartition

◆ numBoxes() [1/2]

unsigned int Proto::BoxPartition::numBoxes ( ) const
inline

Number of Boxes (Global)

Query the number of patches in this BoxPartition across all processes

◆ numBoxes() [2/2]

unsigned int Proto::BoxPartition::numBoxes ( unsigned int  a_proc) const
inline

Number of Boxes (Local)

Query the number of patches in this BoxPartition on a specified process

◆ partition()

const std::vector<std::pair<Point, unsigned int> >& Proto::BoxPartition::partition ( ) const
inline

Access Partition.

Access the vector of pair<Point, unsigned int> which maps each patch (represented as a Point) to a process number

References m_partition, and procStartIndex().

◆ procStartIndex()

unsigned int Proto::BoxPartition::procStartIndex ( unsigned int  a_proc) const
inline

Get Processor Starting Index.

Get the index in global array at which a specified process's data begins. Returns this->size() if the processor is not assigned to this.

Referenced by partition().

◆ procEndIndex()

unsigned int Proto::BoxPartition::procEndIndex ( unsigned int  a_proc) const
inline

Get Processor Ending Index.

Get the index in global array at which a specified process's data ends Returns this->size() if the processor is not assigned to this.

◆ globalIndex()

unsigned int Proto::BoxPartition::globalIndex ( unsigned int  a_localIndex,
unsigned int  a_proc 
)
inline

Get Global Index.

Get the global index from a local index and processor number. Works even if the data in this is unsorted.

◆ localIndex()

unsigned int Proto::BoxPartition::localIndex ( unsigned int  a_globalIndex,
unsigned int  a_proc 
)
inline

Get Local Index.

Get the global index from a local index and processor number. Works even if the data in this is unsorted.

◆ find()

unsigned int Proto::BoxPartition::find ( Point  a_pt)
inline

Get Patch Index.

Get the index in global array corresponding to a specified patch. Returns this->size() if the patch is not in this partition's domain.

◆ domain()

const ProblemDomain& Proto::BoxPartition::domain ( ) const
inline

References m_patchDomain.

◆ print()

void Proto::BoxPartition::print ( ) const
inline

Print.

◆ doLoadBalance()

bool Proto::BoxPartition::doLoadBalance ( ) const
inline

Check If This Controls Load Balancing.

References assign(), checkProcSorting(), m_doLoadBalance, and unpack().

◆ checkProcSorting()

bool Proto::BoxPartition::checkProcSorting ( const std::vector< std::pair< Point, unsigned int >>  a_data)
inlineprivate

Referenced by doLoadBalance().

◆ unpack() [1/2]

template<typename... vals>
void Proto::BoxPartition::unpack ( std::vector< Point > &  a_patches,
unsigned int  a_globalIndex,
int  a_proc,
unsigned int  a_num,
vals...  a_args 
)
inlineprivate

Referenced by doLoadBalance().

◆ assign()

void Proto::BoxPartition::assign ( std::vector< Point > &  a_patches,
unsigned int  a_globalIndex,
int  a_proc,
unsigned int  a_num 
)
inlineprivate

Referenced by doLoadBalance().

◆ unpack() [2/2]

template<>
void Proto::BoxPartition::unpack ( std::vector< Point > &  a_patches,
unsigned int  a_globalIndex,
int  a_proc,
unsigned int  a_num 
)
inline

Member Data Documentation

◆ m_procSorted

bool Proto::BoxPartition::m_procSorted = true
private

Referenced by isSorted().

◆ m_doLoadBalance

bool Proto::BoxPartition::m_doLoadBalance = true
private

Referenced by doLoadBalance().

◆ m_patchDomain

ProblemDomain Proto::BoxPartition::m_patchDomain
private

Domain in patch space.

Referenced by domain().

◆ m_indexMap

std::unordered_map<uint64_t, int> Proto::BoxPartition::m_indexMap
private

Maps Morton index to global index.

◆ m_procMap

std::unordered_map<unsigned int, std::pair<unsigned int, unsigned int> > Proto::BoxPartition::m_procMap
private

Maps processor number to global index.

◆ m_partition

std::vector<std::pair<Point, unsigned int> > Proto::BoxPartition::m_partition
private

Maps each patch to a proc.

Referenced by partition().

◆ m_procMapUnsorted

std::unordered_map<unsigned int, std::vector<unsigned int> > Proto::BoxPartition::m_procMapUnsorted
private

Same as procMap for unsorted data.


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