DASH  0.3.0
BlockPattern1D.h
1 #ifndef DASH__BLOCK_PATTERN_1D_H_
2 #define DASH__BLOCK_PATTERN_1D_H_
3 
4 #include <dash/Types.h>
5 #include <dash/Distribution.h>
6 #include <dash/Exception.h>
7 #include <dash/Dimensional.h>
8 #include <dash/Cartesian.h>
9 #include <dash/Team.h>
10 
11 #include <dash/pattern/BlockPattern.h>
12 #include <dash/pattern/PatternProperties.h>
13 #include <dash/pattern/internal/PatternArguments.h>
14 
15 #include <dash/internal/Math.h>
16 #include <dash/internal/Logging.h>
17 
18 #include <functional>
19 #include <array>
20 #include <type_traits>
21 
22 
23 namespace dash {
24 
31 template<
32  MemArrange Arrangement,
33  typename IndexType
34 >
35 class BlockPattern<1, Arrangement, IndexType>
36 {
37 private:
38  static const dim_t NumDimensions = 1;
39 
40 public:
41  static constexpr const char * PatternName = "BlockPattern1D";
42 
43 public:
46  // Block extents are constant for every dimension.
48  // Identical number of elements in every block.
50  // Size of blocks may differ.
55  // Number of blocks assigned to a unit may differ.
60  // Local indices iterate over block boundaries.
62  // Local element order corresponds to canonical linearization
63  // within entire local memory.
66 
67 private:
69  typedef typename std::make_unsigned<IndexType>::type
70  SizeType;
73  self_t;
83  TeamSpec_t;
85  SizeSpec_t;
87  ViewSpec_t;
88  typedef internal::PatternArguments<NumDimensions, IndexType>
89  PatternArguments_t;
90 
91 public:
92  typedef IndexType index_type;
93  typedef SizeType size_type;
94  typedef ViewSpec_t viewspec_type;
95  typedef struct {
96  team_unit_t unit;
97  IndexType index;
98  } local_index_t;
99  typedef struct {
100  team_unit_t unit;
101  std::array<index_type, NumDimensions> coords;
102  } local_coords_t;
103 
104 private:
106  SizeType _size = 0;
108  MemoryLayout_t _memory_layout;
111  DistributionSpec_t _distspec;
113  dash::Team * _team = nullptr;
115  TeamSpec_t _teamspec;
117  SizeType _nunits = 0;
119  SizeType _blocksize = 0;
121  SizeType _nblocks = 0;
123  SizeType _local_size = 0;
125  LocalMemoryLayout_t _local_memory_layout;
127  SizeType _nlblocks = 0;
129  SizeType _local_capacity = 0;
131  std::array<IndexType, 2> _lbegin_lend = { };
133  IndexType _lend = -1;
134 
135 public:
136  constexpr BlockPattern() = delete;
137 
157  template<typename ... Args>
162  SizeType arg,
166  Args && ... args)
167  : BlockPattern(PatternArguments_t(arg, args...))
168  { }
169 
197  const SizeSpec_t sizespec,
199  const DistributionSpec_t dist,
201  const TeamSpec_t teamspec,
204  : _size(sizespec.size()),
205  _memory_layout(std::array<SizeType, 1> {{ _size }}),
206  _distspec(dist),
207  _team(&team),
208  _teamspec(
209  teamspec,
210  _distspec,
211  *_team),
212  _nunits(_team->size()),
213  _blocksize(initialize_blocksize(
214  _size,
215  _distspec,
216  _nunits)),
217  _nblocks(initialize_num_blocks(
218  _size,
219  _blocksize,
220  _nunits)),
221  _local_size(
222  initialize_local_extent(_team->myid())),
223  _local_memory_layout(std::array<SizeType, 1> {{ _local_size }}),
224  _nlblocks(initialize_num_local_blocks(
225  _blocksize,
226  _local_size)),
227  _local_capacity(initialize_local_capacity()),
228  _lbegin_lend(initialize_local_range(_local_size))
229  { }
230 
258  const SizeSpec_t sizespec,
261  const DistributionSpec_t dist = DistributionSpec_t(),
263  Team & team = dash::Team::All())
264  : _size(sizespec.size()),
265  _memory_layout(std::array<SizeType, 1> {{ _size }}),
266  _distspec(dist),
267  _team(&team),
268  _teamspec(_distspec, *_team),
269  _nunits(_team->size()),
270  _blocksize(initialize_blocksize(
271  _size,
272  _distspec,
273  _nunits)),
274  _nblocks(initialize_num_blocks(
275  _size,
276  _blocksize,
277  _nunits)),
278  _local_size(
279  initialize_local_extent(_team->myid())),
280  _local_memory_layout(std::array<SizeType, 1> {{ _local_size }}),
281  _nlblocks(initialize_num_local_blocks(
282  _blocksize,
283  _local_size)),
284  _local_capacity(initialize_local_capacity()),
285  _lbegin_lend(initialize_local_range(_local_size))
286  { }
287 
291  constexpr BlockPattern(self_t && other) = default;
292 
296  constexpr BlockPattern(const self_t & other) = default;
297 
304  constexpr BlockPattern(self_t & other)
305  : BlockPattern(static_cast<const self_t &>(other)) {
306  }
307 
311  self_t & operator=(self_t && other) = default;
312 
316  self_t & operator=(const self_t & other) = default;
317 
321  constexpr bool operator==(
323  const self_t & other
324  ) const {
325  // no need to compare all members as most are derived from
326  // constructor arguments.
327  return (
328  this == &other
329  || ( _size == other._size &&
330  _distspec == other._distspec &&
331  _teamspec == other._teamspec &&
332  _nblocks == other._nblocks &&
333  _nlblocks == other._nlblocks &&
334  _local_size == other._local_size &&
335  _blocksize == other._blocksize &&
336  _nunits == other._nunits &&
337  _lbegin_lend == other._lbegin_lend
338  )
339  );
340  }
341 
345  constexpr bool operator!=(
347  const self_t & other
348  ) const {
349  return !(*this == other);
350  }
351 
357  constexpr IndexType lbegin() const {
358  return _lbegin_lend[0];
359  }
360 
366  constexpr IndexType lend() const {
367  return _lbegin_lend[1];
368  }
369 
373 
379  constexpr team_unit_t unit_at(
381  const std::array<IndexType, NumDimensions> & coords,
383  const ViewSpec_t & viewspec) const {
384  return team_unit_t (((coords[0] + viewspec.offset(0)) / _blocksize)
385  % _nunits);
386  }
387 
393  constexpr team_unit_t unit_at(
394  const std::array<IndexType, NumDimensions> & coords) const {
395  return team_unit_t((coords[0] / _blocksize) % _nunits);
396  }
397 
403  constexpr team_unit_t unit_at(
405  IndexType global_pos,
407  const ViewSpec_t & viewspec
408  ) const {
409  return team_unit_t(((global_pos + viewspec.offset(0)) / _blocksize)
410  % _nunits);
411  }
412 
418  constexpr team_unit_t unit_at(
420  IndexType global_pos
421  ) const {
422  return team_unit_t((global_pos / _blocksize) % _nunits);
423  }
424 
428 
438  IndexType extent(dim_t dim) const {
439  DASH_ASSERT_EQ(
440  0, dim,
441  "Wrong dimension for Pattern::local_extent. " <<
442  "Expected dimension = 0, got " << dim);
443  return _size;
444  }
445 
455  template <dim_t dim = 0>
456  constexpr IndexType extent() const {
457  static_assert(
458  0 == dim,
459  "Wrong dimension for Pattern::local_extent. "
460  "Expected dimension = 0");
461  return _size;
462  }
463 
475  IndexType local_extent(dim_t dim) const {
476  DASH_ASSERT_EQ(
477  0, dim,
478  "Wrong dimension for Pattern::local_extent. " <<
479  "Expected dimension = 0, got " << dim);
480  return _local_size;
481  }
482 
494  template <dim_t dim = 0>
495  constexpr IndexType local_extent() const {
496  static_assert(
497  0 == dim,
498  "Wrong dimension for Pattern::local_extent. "
499  "Expected dimension = 0");
500  return _local_size;
501  }
502 
514  constexpr std::array<SizeType, NumDimensions> local_extents(
515  team_unit_t unit) const {
516  return std::array<SizeType, 1> {{
517  unit == _team->myid()
518  ? _local_size
519  : initialize_local_extent(unit)
520  }};
521  }
522 
534  constexpr std::array<SizeType, NumDimensions> local_extents() const {
535  return std::array<SizeType, 1> {{ _local_size }};
536  }
537 
541 
548  constexpr IndexType local_at(
550  const std::array<IndexType, NumDimensions> & local_coords,
552  const ViewSpec_t & viewspec) const {
553  return local_coords[0] + viewspec.offset(0);
554  }
555 
561  constexpr IndexType local_at(
563  const std::array<IndexType, NumDimensions> & local_coords) const {
564  return local_coords[0];
565  }
566 
575  constexpr local_coords_t local(
576  const std::array<IndexType, NumDimensions> & global_coords) const {
577  return local_coords_t {
578  unit_at(global_coords), // .unit
579  local_coords(global_coords) // .coords
580  };
581  }
582 
590  constexpr local_index_t local(
591  IndexType g_index) const {
592  return local_index(coords(g_index));
593  }
594 
601  constexpr std::array<IndexType, NumDimensions> local_coords(
602  const std::array<IndexType, NumDimensions> & global_coords
603  ) const noexcept {
604  return std::array<IndexType, 1> {{
605  static_cast<IndexType>(
606  (((global_coords[0] / _blocksize) / _nunits) * _blocksize)
607  + (global_coords[0] % _blocksize)
608  )
609  }};
610  }
611 
617  constexpr local_index_t local_index(
618  const std::array<IndexType, NumDimensions> & g_coords) const {
619  return local_index_t {
620  team_unit_t(unit_at(g_coords[0])),
621  at(g_coords)
622  };
623  }
624 
628 
634  constexpr std::array<IndexType, NumDimensions> global(
635  team_unit_t unit,
636  const std::array<IndexType, NumDimensions> & local_coords) const {
637  return (_nunits < 2)
638  ? local_coords
639  : std::array<IndexType, 1> {{
640  static_cast<IndexType>(
641  (( _distspec[0].local_index_to_block_coord(
642  static_cast<IndexType>(unit),
643  local_coords[0],
644  _nunits)
645  ) * _blocksize)
646  + (local_coords[0] % _blocksize)
647  )
648  }};
649  }
650 
656  constexpr std::array<IndexType, NumDimensions> global(
657  const std::array<IndexType, NumDimensions> & l_coords) const
658  {
659  return global(_team->myid(), l_coords);
660  }
661 
670  constexpr IndexType global(
671  IndexType l_index) const
672  {
673  return global(_team->myid(), std::array<IndexType, 1> {{ l_index }})[0];
674  }
675 
684  constexpr IndexType global_index(
685  team_unit_t unit,
686  const std::array<IndexType, NumDimensions> & l_coords) const
687  {
688  return global(unit, l_coords)[0];
689  }
690 
697  constexpr IndexType global_at(
699  const std::array<IndexType, NumDimensions> & global_coords,
701  const ViewSpec_t & viewspec) const {
702  return global_coords[0] + viewspec.offset(0);
703  }
704 
710  constexpr IndexType global_at(
712  const std::array<IndexType, NumDimensions> & global_coords) const {
713  return global_coords[0];
714  }
715 
716 
720 
729  constexpr IndexType at(
730  const std::array<IndexType, NumDimensions> & g_coords) const {
731  return local_coords(g_coords)[0];
732  }
733 
741  constexpr IndexType at(
742  const std::array<IndexType, 1> & g_coords,
743  const ViewSpec_t & viewspec) const {
744  return local_coords(
745  std::array<IndexType, 1> {{
746  g_coords[0] + viewspec.offset(0)
747  }}
748  )[0];
749  }
750 
758  template<typename ... Values>
759  constexpr IndexType at(IndexType value, Values ... values) const {
760  static_assert(
761  sizeof...(values) == NumDimensions-1,
762  "Wrong parameter number");
763  return at(std::array<IndexType, NumDimensions> {
764  value, (IndexType)values...
765  });
766  }
767 
771 
778  constexpr bool has_local_elements(
780  dim_t dim,
782  IndexType dim_offset,
784  team_unit_t unit) const {
785  // Check if unit id lies in cartesian sub-space of team spec
786  return _teamspec.includes_index(
787  unit,
788  dim,
789  dim_offset);
790  }
791 
797  constexpr bool is_local(
798  IndexType index,
799  team_unit_t unit) const {
800  return unit_at(index) == unit;
801  }
802 
809  constexpr bool is_local(
810  IndexType index) const {
811  return is_local(index, team().myid());
812  }
813 
817 
821  constexpr BlockSpec_t blockspec() const {
822  return BlockSpec_t({ _nblocks });
823  }
824 
828  constexpr BlockSpec_t local_blockspec() const
829  {
830  return BlockSpec_t({ _nlblocks });
831  }
832 
838  constexpr index_type block_at(
840  const std::array<index_type, NumDimensions> & g_coords) const {
841  return g_coords[0] / _blocksize;
842  }
843 
849  constexpr local_index_t local_block_at(
851  const std::array<index_type, NumDimensions> & g_coords) const {
852  return local_index_t {
853  // unit id:
854  static_cast<team_unit_t>(
855  (g_coords[0] / _blocksize) % _teamspec.size()),
856  // local block index:
857  static_cast<index_type>(
858  (g_coords[0] / _blocksize) / _teamspec.size())
859  };
860  }
861 
866  constexpr ViewSpec_t block(
868  index_type g_block_index) const
869  {
870  return ViewSpec_t(
871  {{ static_cast<index_type>(g_block_index * _blocksize) }},
872  {{ static_cast<size_type>(
873  _blocksize - ( g_block_index < _nblocks - 1
874  ? 0
875  : underfilled_blocksize(0) )
876  ) }}
877  );
878  }
879 
884  constexpr ViewSpec_t local_block(
886  index_type l_block_index) const
887  {
888  // Local block index to local block coords:
889  return ViewSpec_t(
890  {{ static_cast<index_type>( global(l_block_index * _blocksize) ) }},
891  {{ static_cast<size_type>(
892  (l_block_index == (_nlblocks - 1)
893  ? (_local_size % _blocksize == 0
894  ? _blocksize
895  : _local_size % _blocksize )
896  : _blocksize )
897  ) }}
898  );
899  }
900 
905  ViewSpec_t local_block_local(
906  index_type l_block_index) const
907  {
908  DASH_LOG_DEBUG_VAR("BlockPattern<1>.local_block_local()", l_block_index);
909  index_type offset = l_block_index * _blocksize;
910  std::array<index_type, NumDimensions> offsets = {{ offset }};
911  std::array<size_type, NumDimensions> extents = {{ _blocksize }};
912  if(l_block_index == (_nlblocks - 1))
913  {
914  size_type remaining = _local_size % extents[0];
915  extents[0] = (remaining == 0) ? extents[0] : remaining;
916  }
917  ViewSpec_t block_vs(offsets, extents);
918  DASH_LOG_DEBUG_VAR("BlockPattern<1>.local_block_local >", block_vs);
919  return block_vs;
920  }
921 
929  constexpr SizeType blocksize(
931  dim_t dimension) const {
932  return _blocksize;
933  }
934 
943  constexpr SizeType max_blocksize() const {
944  return _blocksize;
945  }
946 
953  constexpr SizeType local_capacity() const
954  {
955  return _local_capacity;
956  }
957 
968  constexpr SizeType local_size(team_unit_t unit) const
969  {
970  return (unit == _team->myid().id)
971  ? _local_size
972  : initialize_local_extent(unit);
973  }
974 
985  constexpr SizeType local_size() const noexcept
986  {
987  return _local_size;
988  }
989 
995  constexpr IndexType num_units() const noexcept {
996  return _nunits;
997  }
998 
1004  constexpr IndexType capacity() const noexcept {
1005  return _size;
1006  }
1007 
1013  constexpr IndexType size() const noexcept {
1014  return _size;
1015  }
1016 
1021  constexpr dash::Team & team() const noexcept {
1022  return *_team;
1023  }
1024 
1028  constexpr const DistributionSpec_t & distspec() const noexcept {
1029  return _distspec;
1030  }
1031 
1037  constexpr SizeSpec_t sizespec() const {
1038  return SizeSpec_t(std::array<SizeType, 1> {{ _size }});
1039  }
1040 
1046  constexpr const std::array<SizeType, NumDimensions> extents() const {
1047  return std::array<SizeType, 1> {{ _size }};
1048  }
1049 
1056  constexpr const TeamSpec_t & teamspec() const {
1057  return _teamspec;
1058  }
1059 
1066  constexpr std::array<IndexType, NumDimensions> coords(
1067  IndexType index) const {
1068  return std::array<IndexType, 1> {{ index }};
1069  }
1070 
1077  constexpr std::array<IndexType, NumDimensions> coords(
1078  IndexType index,
1079  const ViewSpec_t & viewspec) const {
1080  return std::array<IndexType, 1> {{ index + viewspec.offset(0) }};
1081  }
1082 
1086  constexpr static MemArrange memory_order() {
1087  return Arrangement;
1088  }
1089 
1093  constexpr static dim_t ndim() {
1094  return 1;
1095  }
1096 
1102  constexpr SizeType underfilled_blocksize(
1103  dim_t dimension) const {
1104  // Underflow blocksize = regular blocksize - overflow blocksize:
1105  return ( _blocksize == 0 || _size % _blocksize == 0
1106  ? 0
1107  : _blocksize - (_size % _blocksize)
1108  );
1109  }
1110 
1111 private:
1112 
1113  BlockPattern(const PatternArguments_t & arguments)
1114  : _size(arguments.sizespec().size()),
1115  _memory_layout(std::array<SizeType, 1> {{ _size }}),
1116  _distspec(arguments.distspec()),
1117  _team(&arguments.team()),
1118  _teamspec(arguments.teamspec()),
1119  _nunits(_team->size()),
1120  _blocksize(initialize_blocksize(
1121  _size,
1122  _distspec,
1123  _nunits)),
1124  _nblocks(initialize_num_blocks(
1125  _size,
1126  _blocksize,
1127  _nunits)),
1128  _local_size(
1129  initialize_local_extent(_team->myid())),
1130  _local_memory_layout(std::array<SizeType, 1> {{ _local_size }}),
1131  _nlblocks(initialize_num_local_blocks(
1132  _blocksize,
1133  _local_size)),
1134  _local_capacity(initialize_local_capacity()),
1135  _lbegin_lend(initialize_local_range(_local_size))
1136  {}
1137 
1142  SizeType initialize_blocksize(
1143  SizeType size,
1144  const DistributionSpec_t & distspec,
1145  SizeType nunits) const {
1146  DASH_LOG_TRACE_VAR("BlockPattern<1>.init_blocksize", nunits);
1147  if (nunits == 0) {
1148  return 0;
1149  }
1150  const Distribution & dist = distspec[0];
1151  return dist.max_blocksize_in_range(
1152  size, // size of range (extent)
1153  nunits); // number of blocks (units)
1154  }
1155 
1160  SizeType initialize_num_blocks(
1161  SizeType size,
1162  SizeType blocksize,
1163  SizeType nunits) const {
1164  if (blocksize == 0) {
1165  return 0;
1166  }
1167  DASH_LOG_TRACE("BlockPattern<1>.init_num_blocks()",
1168  "size", size, "blocksize", blocksize, "nunits", nunits);
1169  SizeType n_blocks = dash::math::div_ceil(
1170  size,
1171  blocksize);
1172  DASH_LOG_TRACE_VAR("BlockPattern<1>.init_blockspec", n_blocks);
1173  return n_blocks;
1174  }
1175 
1179  SizeType initialize_num_local_blocks(
1180  SizeType blocksize,
1181  SizeType local_size) const {
1182  auto num_l_blocks = local_size;
1183  if (blocksize > 0) {
1184  num_l_blocks = dash::math::div_ceil(
1185  num_l_blocks,
1186  blocksize);
1187  } else {
1188  num_l_blocks = 0;
1189  }
1190  DASH_LOG_TRACE_VAR("BlockPattern<1>.init_num_local_blocks", num_l_blocks);
1191  return num_l_blocks;
1192  }
1193 
1201  SizeType initialize_local_capacity() const {
1202  SizeType l_capacity = 1;
1203  if (_nunits == 0) {
1204  return 0;
1205  }
1206  auto max_l_blocks = dash::math::div_ceil(
1207  _nblocks,
1208  _nunits);
1209  DASH_LOG_TRACE_VAR("BlockPattern<1>.init_lcapacity.d", _nunits);
1210  DASH_LOG_TRACE_VAR("BlockPattern<1>.init_lcapacity.d", max_l_blocks);
1211  l_capacity = max_l_blocks * _blocksize;
1212  DASH_LOG_DEBUG_VAR("BlockPattern<1>.init_lcapacity >", l_capacity);
1213  return l_capacity;
1214  }
1215 
1220  constexpr std::array<IndexType, 2>
1221  initialize_local_range(SizeType l_size) const {
1222  return (l_size == 0)
1223  ? std::array<IndexType, 2> {{ 0, 0 }}
1224  : std::array<IndexType, 2> {{
1225  global(0),
1226  global(l_size - 1) + 1
1227  }};
1228  }
1229 
1233  constexpr SizeType initialize_local_extent(
1234  team_unit_t unit) const
1235  {
1236  return (_nunits == 0
1237  ? 0
1238  : (_nblocks == 1 && _nunits == 1
1239  ? _size
1240  // Possibly there are more blocks than units in dimension
1241  // and no block left for this unit. Local extent in d then
1242  // becomes 0.
1243  : ((_nblocks / _nunits) * _blocksize
1244  // Unbalanced blocks owned by the unit:
1245  + (static_cast<SizeType>(unit) < (_nblocks % _nunits)
1246  ? _blocksize
1247  : 0 )
1248  // If the last block in the dimension is underfilled and
1249  // assigned to the local unit, subtract the missing extent:
1250  - (static_cast<SizeType>(unit) ==
1251  // Unit id assigned to the last block:
1252  (_nblocks % _nunits == 0
1253  ? _nunits - 1
1254  : ((_nblocks % _nunits) - 1 ))
1256  : 0 )
1257  )
1258  )
1259  );
1260 
1261  }
1262 };
1263 
1264 } // namespace dash
1265 
1266 #endif // DASH__BLOCK_PATTERN_1D_H_
All blocks have identical size.
static constexpr MemArrange memory_order()
Memory order followed by the pattern.
constexpr IndexType local_at(const std::array< IndexType, NumDimensions > &local_coords, const ViewSpec_t &viewspec) const
local
bool includes_index(IndexType index, dim_t dimension, IndexType dim_offset) const
Whether the given index lies in the cartesian sub-space specified by a dimension and offset in the di...
Definition: TeamSpec.h:385
global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
constexpr SizeType blocksize(dim_t dimension) const
Maximum number of elements in a single block in the given dimension.
constexpr SizeType local_capacity() const
Maximum number of elements assigned to a single unit in total, equivalent to the local capacity of ev...
constexpr SizeType local_size(team_unit_t unit) const
The actual number of elements in this pattern that are local to the specified unit in total...
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
Defines how a list of global indices is mapped to single units within a Team.
Definition: BlockPattern.h:42
constexpr IndexType global_index(team_unit_t unit, const std::array< IndexType, NumDimensions > &l_coords) const
Resolve an element&#39;s linear global index from a given unit&#39;s local coordinates of that element...
constexpr SizeType blocksize(dim_t dimension) const noexcept
Maximum number of elements in a single block in the given dimension.
constexpr const DistributionSpec_t & distspec() const noexcept
Distribution specification of this pattern.
constexpr IndexType global_at(const std::array< IndexType, NumDimensions > &global_coords) const
Convert given global coordinates to linear global offset (index).
constexpr IndexType local_at(const std::array< IndexType, NumDimensions > &local_coords) const
Convert given local coordinates to linear local offset (index).
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
Local element order corresponds to a logical linearization within single blocks (if blocked) or withi...
constexpr IndexType size() const noexcept
The number of elements arranged in this pattern.
constexpr const DistributionSpec_t & distspec() const noexcept
Distribution specification of this pattern.
constexpr bool operator!=(const self_t &other) const
Inquality comparison operator.
BlockPattern(SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...
BlockPattern(SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...
Definition: BlockPattern.h:180
Specifies cartesian extents in a specific number of dimensions.
Definition: Cartesian.h:197
constexpr index_type block_at(const std::array< index_type, NumDimensions > &g_coords) const
Gobal index of block at given global coordinates.
constexpr BlockSpec_t blockspec() const
block
IndexType local_extent(dim_t dim) const
The actual number of elements in this pattern that are local to the calling unit in the given dimensi...
Specifies view parameters for implementing submat, rows and cols.
Definition: Dimensional.h:430
constexpr std::array< IndexType, NumDimensions > coords(IndexType index, const ViewSpec_t &viewspec) const
Convert given global linear offset (index) to global cartesian coordinates using viewspec.
constexpr IndexType at(const std::array< IndexType, NumDimensions > &g_coords) const
at
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
constexpr std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const noexcept
Converts global coordinates to their associated unit&#39;s respective local coordinates.
constexpr IndexType extent() const
The number of elements in this pattern in the given dimension.
constexpr const TeamSpec_t & teamspec() const noexcept
Cartesian arrangement of the Team containing the units to which this pattern&#39;s elements are mapped...
constexpr team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords) const
Convert given coordinate in pattern to its assigned unit id.
constexpr SizeType underfilled_blocksize(dim_t dimension) const
Number of elements missing in the overflow block of given dimension compared to the regular blocksize...
constexpr const TeamSpec_t & teamspec() const
Cartesian arrangement of the Team containing the units to which this pattern&#39;s elements are mapped...
constexpr bool has_local_elements(dim_t dim, IndexType dim_offset, team_unit_t unit) const
is_local
constexpr BlockPattern(self_t &other)
Copy constructor using non-const lvalue reference parameter.
All local indices are mapped to a single logical index domain and thus not indexed blockwise...
BlockPattern(const SizeSpec_t sizespec, const DistributionSpec_t dist, const TeamSpec_t teamspec, dash::Team &team=dash::Team::All())
Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec, TeamSpec and a Team.
constexpr local_index_t local_index(const std::array< IndexType, NumDimensions > &g_coords) const
Resolves the unit and the local index from global coordinates.
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
local_index_t local_index(const std::array< IndexType, NumDimensions > &global_coords) const
Resolves the unit and the local index from global coordinates.
Definition: BlockPattern.h:677
The number of blocks assigned to units may differ.
constexpr std::array< IndexType, NumDimensions > global(const std::array< IndexType, NumDimensions > &l_coords) const
Converts local coordinates of active unit to global coordinates.
Block extents are constant for every dimension.
BlockPattern(const SizeSpec_t sizespec, const DistributionSpec_t dist=DistributionSpec_t(), Team &team=dash::Team::All())
Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec and a Team...
SizeType underfilled_blocksize(dim_t dimension) const
Number of elements missing in the overflow block of given dimension compared to the regular blocksize...
constexpr SizeSpec_t sizespec() const
Size specification of the index space mapped by this pattern.
constexpr bool is_local(IndexType index) const
Whether the given global index is local to the unit that created this pattern instance.
size_t size() const
The number of units in this team.
Definition: Team.h:498
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given global linear offset (index) to global cartesian coordinates.
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
Definition: BlockPattern.h:710
Cartesian space defined by extents in n dimensions.
Definition: Cartesian.h:26
constexpr SizeType local_size(team_unit_t unit=UNDEFINED_TEAM_UNIT_ID) const noexcept
The actual number of elements in this pattern that are local to the calling unit in total...
bool is_local(IndexType index, team_unit_t unit) const
Whether the given global index is local to the specified unit.
Definition: BlockPattern.h:960
constexpr std::array< SizeType, NumDimensions > local_extents(team_unit_t unit) const
The actual number of elements in this pattern that are local to the given unit, by dimension...
constexpr ViewSpec_t block(index_type g_block_index) const
View spec (offset and extents) of block at global linear block index in cartesian element space...
constexpr team_unit_t unit_at(IndexType global_pos, const ViewSpec_t &viewspec) const
Convert given global linear index to its assigned unit id.
A Team instance specifies a subset of all available units.
Definition: Team.h:41
constexpr IndexType capacity() const noexcept
The maximum number of elements arranged in this pattern.
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
Definition: BlockPattern.h:430
constexpr local_index_t local(IndexType g_index) const
Converts global index to its associated unit and respective local index.
constexpr SizeSpec_t sizespec() const noexcept
Size specification of the index space mapped by this pattern.
constexpr local_index_t local_block_at(const std::array< index_type, NumDimensions > &g_coords) const
Local index of block at given global coordinates.
Defines a cartesian, totally-ordered index space by mapping linear indices to cartesian coordinates d...
Definition: Cartesian.h:239
pattern_mapping_properties< pattern_mapping_tag::unbalanced > mapping_properties
Satisfiable properties in pattern property category Mapping:
constexpr bool operator==(const self_t &other) const
Equality comparison operator.
constexpr IndexType lbegin() const
Resolves the global index of the first local element in the pattern.
Specifies how a Pattern distributes elements to units in a specific dimension.
Definition: Distribution.h:24
BlockPattern & operator=(const BlockPattern &other)
Assignment operator.
Definition: BlockPattern.h:380
constexpr BlockSpec_t local_blockspec() const
Cartesian arrangement of local pattern blocks.
constexpr std::array< SizeType, NumDimensions > local_extents() const
The actual number of elements in this pattern that are local to the active unit, by dimension...
constexpr std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
Definition: Types.h:319
constexpr IndexType local_extent() const
The actual number of elements in this pattern that are local to the calling unit in the given dimensi...
static constexpr dim_t ndim()
Number of dimensions of the cartesian space partitioned by the pattern.
constexpr IndexType at(const std::array< IndexType, 1 > &g_coords, const ViewSpec_t &viewspec) const
Global coordinates and viewspec to local index.
constexpr IndexType global(IndexType l_index) const
Resolve an element&#39;s linear global index from the calling unit&#39;s local index of that element...
constexpr team_unit_t unit_at(IndexType global_pos) const
Convert given global linear index to its assigned unit id.
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.
Definition: Distribution.h:114
constexpr dash::Team & team() const noexcept
The Team containing the units to which this pattern&#39;s elements are mapped.
constexpr ViewSpec_t local_block(index_type l_block_index) const
View spec (offset and extents) of block at local linear block index in global cartesian element space...
constexpr IndexType lend() const
Resolves the global index past the last local element in the pattern.
constexpr IndexType num_units() const noexcept
The number of units to which this pattern&#39;s elements are mapped.
pattern_layout_properties< pattern_layout_tag::canonical, pattern_layout_tag::linear > layout_properties
Satisfiable properties in pattern property category Layout:
constexpr IndexType at(IndexType value, Values ... values) const
Global coordinates to local index.
constexpr bool is_local(IndexType index, team_unit_t unit) const
Whether the given global index is local to the specified unit.
constexpr IndexType size() const noexcept
The number of elements arranged in this pattern.
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395
constexpr IndexType global_at(const std::array< IndexType, NumDimensions > &global_coords, const ViewSpec_t &viewspec) const
Convert given global coordinates and viewspec to linear global offset (index).
constexpr team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
constexpr SizeType max_blocksize() const
Maximum number of elements in a single block in all dimensions.
static Team & All()
The invariant Team instance containing all available units.
Definition: Team.h:213
see https://en.cppreference.com/w/cpp/feature_test for recommended feature tests
Definition: cstddef.h:8
IndexType at(const std::array< IndexType, NumDimensions > &global_coords) const
at
Definition: BlockPattern.h:855
constexpr local_coords_t local(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit and its respective local coordinates.
ViewSpec_t local_block_local(index_type l_block_index) const
View spec (offset and extents) of block at local linear block index in local cartesian element space...
constexpr const std::array< SizeType, NumDimensions > & extents() const noexcept
Size specification of the index space mapped by this pattern.
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const noexcept
Convert given global linear offset (index) to global cartesian coordinates.
constexpr const std::array< SizeType, NumDimensions > extents() const
Size specification of the index space mapped by this pattern.
IndexType extent(dim_t dim) const
extent
constexpr dash::Team & team() const noexcept
The Team containing the units to which this pattern&#39;s elements are mapped.
DistributionSpec describes distribution patterns of all dimensions,.
Definition: Dimensional.h:222
Generic type of mapping properties of a model satisfying the Pattern concept.
constexpr SizeType local_size() const noexcept
The actual number of elements in this pattern that are local to the calling unit in total...
pattern_partitioning_properties< pattern_partitioning_tag::rectangular, pattern_partitioning_tag::balanced, pattern_partitioning_tag::unbalanced > partitioning_properties
Satisfiable properties in pattern property category Partitioning: