1 #ifndef DASH__DISTRIBUTION_H_ 2 #define DASH__DISTRIBUTION_H_ 4 #include <dash/Types.h> 5 #include <dash/Exception.h> 6 #include <dash/internal/Math.h> 7 #include <dash/internal/Logging.h> 29 friend std::ostream & operator<<(
31 const self_t & distribution);
34 dash::internal::DistributionType type{dash::internal::DIST_NONE};
48 dash::internal::DistributionType distType,
56 self_t& operator=(
const self_t& other) =
default;
62 template <
typename IndexType,
typename SizeType>
66 IndexType unit_teamspec_coord,
68 IndexType local_index,
70 SizeType num_units_in_dim)
const {
72 SizeType local_block_offset = 0;
74 case dash::internal::DIST_NONE:
78 case dash::internal::DIST_BLOCKED:
81 return unit_teamspec_coord;
82 case dash::internal::DIST_TILE:
84 case dash::internal::DIST_BLOCKCYCLIC:
87 local_block_offset = local_index / blocksz;
92 return (local_block_offset * num_units_in_dim) +
94 case dash::internal::DIST_CYCLIC:
96 DASH_LOG_TRACE(
"Distribution.local_index_to_block_coord",
97 "unit_teamspec_coord", unit_teamspec_coord,
98 "local_index", local_index,
99 "num_units_in_dim", num_units_in_dim);
100 return unit_teamspec_coord + local_index * num_units_in_dim;
104 "Distribution type undefined in " <<
105 "local_index_to_block_coord");
113 template <
typename IndexType,
typename SizeType>
118 SizeType num_units)
const 120 DASH_LOG_TRACE(
"Distribution.max_blocksize_in_range()",
121 "range:", range,
"nunits:", num_units);
123 case dash::internal::DIST_NONE:
125 case dash::internal::DIST_BLOCKED:
126 return num_units == 0 ? 0 : dash::math::div_ceil(range, num_units);
127 case dash::internal::DIST_CYCLIC:
129 case dash::internal::DIST_BLOCKCYCLIC:
130 case dash::internal::DIST_TILE:
131 DASH_LOG_TRACE(
"Distribution.max_blocksize_in_range",
132 "TILE",
"blocksz:", blocksz);
135 return std::min<SizeType>(range, blocksz);
139 "Distribution type undefined in max_blocksize_in_range");
147 return (this->type == other.type &&
148 this->blocksz == other.blocksz);
154 return !(*
this == other);
203 #endif // DASH__DISTRIBUTION_H_ internal::default_unsigned_index default_size_t
Unsigned integer type used as default for size values.
This class is a simple memory pool which holds allocates elements of size ValueType.
bool operator==(const Distribution &other) const
Equality comparison operator.
Distribution TILE(int blockSize)
Distribution specifying that elements in a Pattern's dimension shall be distributed to units in a til...
const Distribution CYCLIC
Distribution specifying that elements in a Pattern's dimension shall be distributed by cycling among ...
Distribution BLOCKCYCLIC(int blockSize)
Distribution specifying that elements in a Pattern's dimension shall be distributed to units in block...
bool operator!=(const Distribution &other) const
Inequality comparison operator.
Distribution()=default
Constructor, initializes Distribution with distribution type NONE.
const Distribution NONE
Distribution specifying that elements in a Pattern's dimension shall not be distributed.
IndexType local_index_to_block_coord(IndexType unit_teamspec_coord, IndexType local_index, SizeType num_units_in_dim) const
Resolve the block coordinate for a given local index in the distribution's dimension.
Specifies how a Pattern distributes elements to units in a specific dimension.
IndexType max_blocksize_in_range(IndexType range, SizeType num_units) const
The maximum size of a single block within an extent for a given total number of units.
const Distribution BLOCKED
Distribution specifying that elements in a Pattern's dimension shall be distributed to units in even-...
Distribution(dash::internal::DistributionType distType, int blockSize)
Constructor, initializes Distribution with a distribution type and a block size.