Partition a one-dimensional domain into balanced subdomains. More...
Public Member Functions | |
balanced_partition (value_type const &dom, size_t p=get_num_locations()) | |
balanced_partition () | |
Create a partition with no domain. Leaves the partition in an inconsistent state and must be used in conjunction with set_domain. | |
balanced_partition (value_type const &domain, balanced_partition const &other) | |
Copy constructor using instead the given domain . | |
domain_type | domain () const |
Get the partition's domain [0, .., p-1]. | |
void | set_domain (value_type const &dom) |
Set the global domain to partition. More... | |
value_type | operator[] (index_type idx) const |
Return the subdomain at a given index. This is the inverse of find. More... | |
boost::optional< value_type > | try_get_domain (index_type pid) const |
Returns the domain of gids that map to the specified partition if the mapping from GID to partition id is recognized. More... | |
size_t | size () const |
Return the number of partitions generated. | |
value_type const & | global_domain () const |
Return the original domain that was used to create subdomains. | |
index_type | find (gid_type const &g) const |
Returns the index of the partition that contains the gid g . More... | |
template<typename ODom , typename MFG > | |
std::vector< std::pair< domain_type, bool > > | contained_in (ODom const &dom, MFG const &mfg) |
Determine which partition has the elements referenced for the given domain. More... | |
Public Types | |
using | domain_type = indexed_domain< size_t > |
The domain of the partitioner itself (i.e., the domain [0, ..., p-1]) | |
using | index_type = typename domain_type::index_type |
Type used to describe the i'th subdomain. | |
using | value_type = Dom |
Type of the subdomains produced by the partition. | |
using | gid_type = typename value_type::index_type |
Type of the GIDs in the subdomains. | |
using | size_type = typename value_type::size_type |
Type of the size of the subdomains. | |
Protected Attributes | |
value_type | m_domain |
The global original domain. | |
size_t | m_npart |
The number of partitions. | |
Partition a one-dimensional domain into balanced subdomains.
If the given domain contains the GIDs [0, 1, ..., n-1] and the number of partitions to generate is p, then each subdomain will have size n/p and will contain contiguous chunks of GID in domain order. In the case that the number of elements does not evenly divide the requested number of partitions, the remaining elements are evenly distributed across the subdomains, guaranteeing that no two subdomains differ in size by more than one.
Dom | Type of the domain to be partitioned |
stapl::balanced_partition< Dom, Integral >::balanced_partition | ( | value_type const & | dom, |
size_t | p = get_num_locations() |
||
) |
Create a partition with a domain and a partitioning factor.
dom | The domain to partition |
p | The number of partitions to generate |
void stapl::balanced_partition< Dom, Integral >::set_domain | ( | value_type const & | dom | ) |
Set the global domain to partition.
dom | The domain to partition |
value_type stapl::balanced_partition< Dom, Integral >::operator[] | ( | index_type | idx | ) | const |
boost::optional<value_type> stapl::balanced_partition< Dom, Integral >::try_get_domain | ( | index_type | pid | ) | const |
Returns the domain of gids that map to the specified partition if the mapping from GID to partition id is recognized.
This is functionally equivalent to the index operator for this partition.
pid | id of the partition whose domain is required |
index_type stapl::balanced_partition< Dom, Integral >::find | ( | gid_type const & | g | ) | const |
Returns the index of the partition that contains the gid g
.
g | gid to find |
g
std::vector<std::pair<domain_type,bool> > stapl::balanced_partition< Dom, Integral >::contained_in | ( | ODom const & | dom, |
MFG const & | mfg | ||
) |
Determine which partition has the elements referenced for the given domain.
The returned information is a collection (possibly empty) of pairs. Each pair contains information about which partitions are included in the given domain and how they are included (True: if is fully contained, False: if is partially included). The returned collection only has elements if there is at least one partition that contains elements on the given domain.
dom | Domain to compare |
mfg | Mapping function generator used to get the associated mapping function to each partition. The generated mapping function is used to project generated partitioned domains into the given domain. |