STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Public Types | Protected Attributes
stapl::balanced_partition< Dom, Integral > Struct Template Reference

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

Detailed Description

template<typename Dom, bool Integral = std::is_integral<typename Dom::index_type>::value>
struct stapl::balanced_partition< Dom, Integral >

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.

Template Parameters
DomType of the domain to be partitioned

Constructor & Destructor Documentation

◆ balanced_partition()

template<typename Dom, bool Integral = std::is_integral<typename Dom::index_type>::value>
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.

Parameters
domThe domain to partition
pThe number of partitions to generate

Member Function Documentation

◆ set_domain()

template<typename Dom, bool Integral = std::is_integral<typename Dom::index_type>::value>
void stapl::balanced_partition< Dom, Integral >::set_domain ( value_type const &  dom)

Set the global domain to partition.

Parameters
domThe domain to partition

◆ operator[]()

template<typename Dom, bool Integral = std::is_integral<typename Dom::index_type>::value>
value_type stapl::balanced_partition< Dom, Integral >::operator[] ( index_type  idx) const

Return the subdomain at a given index. This is the inverse of find.

Parameters
idxThe index of the subdomain, which should be from 0 to size() - 1.

◆ try_get_domain()

template<typename Dom, bool Integral = std::is_integral<typename Dom::index_type>::value>
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.

Parameters
pidid of the partition whose domain is required

◆ find()

template<typename Dom, bool Integral = std::is_integral<typename Dom::index_type>::value>
index_type stapl::balanced_partition< Dom, Integral >::find ( gid_type const &  g) const

Returns the index of the partition that contains the gid g.

Parameters
ggid to find
Returns
The index of the subdomain that contains g

◆ contained_in()

template<typename Dom, bool Integral = std::is_integral<typename Dom::index_type>::value>
template<typename ODom , typename MFG >
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.

Example:
Partition: [0..3],[4..6],[7..9],[10..13]
Given domain: [2..9]
Returns: {([0..0],False),([1..2],True)}
Parameters
domDomain to compare
mfgMapping 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.
Returns
a vector of pairs.

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