1 #ifndef DASH__UTIL__PATTERN_METRICS_H__ 2 #define DASH__UTIL__PATTERN_METRICS_H__ 4 #include <dash/Types.h> 14 template<
typename PatternT>
18 typedef typename PatternT::index_type index_t;
19 typedef typename PatternT::size_type extent_t;
25 init_metrics(pattern);
28 constexpr
int num_blocks()
const noexcept {
52 return _min_blocks * _block_size;
66 return _max_blocks * _block_size;
73 return _num_bal_units;
80 return _num_imb_units;
87 return _unit_blocks[unit];
94 void init_metrics(
const PatternT & pattern)
96 _num_blocks = pattern.blockspec().size();
98 size_t nunits = pattern.teamspec().size();
99 _unit_blocks.resize(nunits);
101 for (
size_t u = 0; u < nunits; ++u) {
104 for (
int bi = 0; bi < _num_blocks; ++bi) {
105 auto block = pattern.block(bi);
106 auto block_unit = pattern.unit_at(std::array<index_t, 2> {{
110 _unit_blocks[block_unit]++;
113 _block_size = pattern.blocksize(0) * pattern.blocksize(1);
115 _unit_blocks.begin() + nunits);
117 _unit_blocks.begin() + nunits);
118 _num_bal_units = std::count(_unit_blocks.begin(),
119 _unit_blocks.begin() + nunits,
121 _num_imb_units = _min_blocks == _max_blocks
123 : std::count(_unit_blocks.begin(),
124 _unit_blocks.begin() + nunits,
127 int min_elements = _min_blocks * _block_size;
128 int max_elements = _max_blocks * _block_size;
129 _imb_factor =
static_cast<float>(max_elements) /
130 static_cast<float>(min_elements);
134 std::vector<int> _unit_blocks;
139 int _num_imb_units = 0;
140 int _num_bal_units = 0;
141 double _imb_factor = 0.0;
147 #endif // DASH__UTIL__PATTERN_METRICS_H__ This class is a simple memory pool which holds allocates elements of size ValueType.
constexpr int unit_local_blocks(dash::team_unit_t unit) const noexcept
Number of blocks mapped to given unit.
constexpr double imbalance_factor() const noexcept
Relation of (max.
const ElementType * min_element(const ElementType *l_range_begin, const ElementType *l_range_end, Compare compare=std::less< const ElementType &>())
Finds an iterator pointing to the element with the smallest value in the range [first,last).
constexpr int num_imbalanced_units() const noexcept
Number of units mapped to maximum number of blocks per unit.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
constexpr int max_blocks_per_unit() const noexcept
Maximum number of blocks mapped to any unit.
constexpr int max_elements_per_unit() const noexcept
Maximum number of elements mapped to any unit.
GlobIter max_element(const GlobIter &first, const GlobIter &last, Compare compare=Compare())
Finds an iterator pointing to the element with the greatest value in the range [first,last).
constexpr int min_elements_per_unit() const noexcept
Minimum number of elements mapped to any unit.
constexpr int num_balanced_units() const noexcept
Number of units mapped to minimum number of blocks per unit.
constexpr int min_blocks_per_unit() const noexcept
Minimum number of blocks mapped to any unit.
constexpr auto block(OffsetT block_idx, const ViewType &view) -> typename std::enable_if<(!dash::view_traits< ViewType >::is_local::value), ViewBlockMod< ViewType > >::type
Blocks view from global view.