DASH  0.3.0
ShiftTilePattern.h
1 #ifndef DASH__SHIFT_TILE_PATTERN_H_
2 #define DASH__SHIFT_TILE_PATTERN_H_
3 
4 #include <cassert>
5 #include <functional>
6 #include <cstring>
7 #include <array>
8 #include <type_traits>
9 #include <utility>
10 
11 #include <dash/Types.h>
12 #include <dash/Distribution.h>
13 #include <dash/Exception.h>
14 #include <dash/Dimensional.h>
15 #include <dash/Cartesian.h>
16 #include <dash/Team.h>
17 
18 #include <dash/pattern/PatternProperties.h>
19 #include <dash/pattern/internal/PatternArguments.h>
20 
21 #include <dash/internal/Math.h>
22 #include <dash/internal/Logging.h>
23 
24 namespace dash {
25 
42 template<
43  dim_t NumDimensions,
44  MemArrange Arrangement = ROW_MAJOR,
45  typename IndexType = dash::default_index_t>
47 {
48 public:
49  static constexpr char const * PatternName = "ShiftTilePattern";
50 
51 public:
54  // Block extents are constant for every dimension.
56  // Identical number of elements in every block.
61  // Same number of blocks assigned to every unit.
63  // Number of blocks assigned to a unit may differ.
65  // Every unit mapped in any single slice in every dimension.
70  // Elements are contiguous in local memory within single block.
72  // Local element order corresponds to a logical linearization
73  // within single blocks.
76 
77 private:
79  typedef typename std::make_unsigned<IndexType>::type
80  SizeType;
83  self_t;
95  TeamSpec_t;
97  SizeSpec_t;
99  ViewSpec_t;
100  typedef internal::PatternArguments<NumDimensions, IndexType>
101  PatternArguments_t;
102 
103 public:
104  typedef IndexType index_type;
105  typedef SizeType size_type;
106  typedef ViewSpec_t viewspec_type;
107  typedef struct {
108  team_unit_t unit;
109  IndexType index{};
110  } local_index_t;
111  typedef struct {
112  team_unit_t unit;
113  std::array<index_type, NumDimensions> coords;
114  } local_coords_t;
115 
116 private:
120  DistributionSpec_t _distspec;
122  dash::Team * _team = nullptr;
124  TeamSpec_t _teamspec;
127  MemoryLayout_t _memory_layout;
129  SizeType _nunits = dash::Team::All().size();
132  dim_t _major_tiled_dim{};
135  dim_t _minor_tiled_dim{};
137  BlockSizeSpec_t _blocksize_spec;
139  BlockSpec_t _blockspec;
141  BlockSpec_t _local_blockspec;
145  LocalMemoryLayout_t _local_memory_layout;
147  SizeType _local_capacity;
149  IndexType _lbegin;
151  IndexType _lend;
152 
153 public:
188  template<typename ... Args>
193  SizeType arg,
197  Args && ... args)
198  : ShiftTilePattern(PatternArguments_t(arg, args...)) {
199  DASH_LOG_TRACE("ShiftTilePattern()", "Constructor with Argument list");
200  initialize_local_range();
201  }
202 
239  const SizeSpec_t &sizespec,
242  DistributionSpec_t dist,
244  TeamSpec_t teamspec,
247  : _distspec(std::move(dist))
248  , _team(&team)
249  ,
250  // Degrading to 1-dimensional team spec for now:
251  // _teamspec(_distspec, *_team),
252  // _teamspec(
253  // teamspec,
254  // _distspec,
255  // *_team),
256  _teamspec(std::move(teamspec))
257  , _memory_layout(sizespec.extents())
258  , _nunits(_teamspec.size())
259  , _major_tiled_dim(initialize_major_tiled_dim(_distspec))
260  , _minor_tiled_dim((_major_tiled_dim + 1) % NumDimensions)
261  , _blocksize_spec(
262  initialize_blocksizespec(sizespec, _distspec, _teamspec))
263  , _blockspec(initialize_blockspec(sizespec, _blocksize_spec, _teamspec))
264  , _local_blockspec(
265  initialize_local_blockspec(_blockspec, _major_tiled_dim, _nunits))
266  , _local_memory_layout(initialize_local_extents(_team->myid()))
267  , _local_capacity(initialize_local_capacity())
268  {
269  DASH_LOG_TRACE("ShiftTilePattern()", "(sizespec, dist, teamspec, team)");
270  initialize_local_range();
271  }
272 
309  const SizeSpec_t &sizespec,
313  DistributionSpec_t dist = DistributionSpec_t(),
316  : _distspec(std::move(dist))
317  , _team(&team)
318  , _teamspec(_distspec, *_team)
319  , _memory_layout(sizespec.extents())
320  , _nunits(_teamspec.size())
321  , _major_tiled_dim(initialize_major_tiled_dim(_distspec))
322  , _minor_tiled_dim((_major_tiled_dim + 1) % NumDimensions)
323  , _blocksize_spec(
324  initialize_blocksizespec(sizespec, _distspec, _teamspec))
325  , _blockspec(initialize_blockspec(sizespec, _blocksize_spec, _teamspec))
326  , _local_blockspec(
327  initialize_local_blockspec(_blockspec, _major_tiled_dim, _nunits))
328  , _local_memory_layout(initialize_local_extents(_team->myid()))
329  , _local_capacity(initialize_local_capacity())
330  {
331  DASH_LOG_TRACE("ShiftTilePattern()", "(sizespec, dist, team)");
332  initialize_local_range();
333  }
334 
338  ShiftTilePattern(const self_t & other)
339  : _distspec(other._distspec),
340  _team(other._team),
341  _teamspec(other._teamspec),
342  _memory_layout(other._memory_layout),
343  _nunits(other._nunits),
344  _major_tiled_dim(other._major_tiled_dim),
345  _minor_tiled_dim(other._minor_tiled_dim),
346  _blocksize_spec(other._blocksize_spec),
347  _blockspec(other._blockspec),
348  _local_blockspec(other._local_blockspec),
349  _local_memory_layout(other._local_memory_layout),
350  _local_capacity(other._local_capacity),
351  _lbegin(other._lbegin),
352  _lend(other._lend) {
353  }
354 
361  ShiftTilePattern(self_t & other)
362  : ShiftTilePattern(static_cast<const self_t &>(other)) {
363  }
364 
370  const self_t & other
371  ) const {
372  if (this == &other) {
373  return true;
374  }
375  // no need to compare all members as most are derived from
376  // constructor arguments.
377  return(
378  _distspec == other._distspec &&
379  _teamspec == other._teamspec &&
380  _memory_layout == other._memory_layout &&
381  _blockspec == other._blockspec &&
382  _blocksize_spec == other._blocksize_spec &&
383  _nunits == other._nunits
384  );
385  }
386 
392  const self_t & other
393  ) const {
394  return !(*this == other);
395  }
396 
401  if (this != &other) {
402  _distspec = other._distspec;
403  _team = other._team;
404  _teamspec = other._teamspec;
405  _memory_layout = other._memory_layout;
406  _local_memory_layout = other._local_memory_layout;
407  _blocksize_spec = other._blocksize_spec;
408  _blockspec = other._blockspec;
409  _local_blockspec = other._local_blockspec;
410  _local_capacity = other._local_capacity;
411  _nunits = other._nunits;
412  _minor_tiled_dim = other._minor_tiled_dim;
413  _major_tiled_dim = other._major_tiled_dim;
414  _lbegin = other._lbegin;
415  _lend = other._lend;
416  }
417  return *this;
418  }
419 
425  IndexType lbegin() const {
426  return _lbegin;
427  }
428 
434  IndexType lend() const {
435  return _lend;
436  }
437 
441 
449  const std::array<IndexType, NumDimensions> & coords,
451  const ViewSpec_t & viewspec) const
452  {
453  DASH_LOG_TRACE("ShiftTilePattern.unit_at()",
454  "coords:", coords,
455  "viewspec:", viewspec);
456  // Unit id from diagonals in cartesian index space,
457  // e.g (x + y + z) % nunits
458  team_unit_t unit_id{0};
459  for (auto d = 0; d < NumDimensions; ++d) {
460  auto vs_coord = coords[d] + viewspec.offset(d);
461  // Global block coordinate:
462  auto block_coord = vs_coord / _blocksize_spec.extent(d);
463  unit_id += block_coord;
464  }
465  unit_id %= _nunits;
466  DASH_LOG_TRACE_VAR("ShiftTilePattern.unit_at >", unit_id);
467  return unit_id;
468  }
469 
476  const std::array<IndexType, NumDimensions> & coords) const
477  {
478  DASH_LOG_TRACE("ShiftTilePattern.unit_at()",
479  "coords:", coords,
480  "blocksize:", _blocksize_spec.extents());
481  // Unit id from diagonals in cartesian index space,
482  // e.g (x + y + z) % nunits
483  team_unit_t unit_id{0};
484  for (auto d = 0; d < NumDimensions; ++d) {
485  // Global block coordinate:
486  auto block_coord = coords[d] / _blocksize_spec.extent(d);
487  unit_id += block_coord;
488  }
489  unit_id %= _nunits;
490  DASH_LOG_TRACE_VAR("ShiftTilePattern.unit_at >", unit_id);
491  return unit_id;
492  }
493 
501  IndexType global_pos,
503  const ViewSpec_t & viewspec) const
504  {
505  auto global_coords = _memory_layout.coords(global_pos);
506  return unit_at(global_coords, viewspec);
507  }
508 
516  IndexType global_pos) const
517  {
518  auto global_coords = _memory_layout.coords(global_pos);
519  return unit_at(global_coords);
520  }
521 
525 
535  SizeType extent(dim_t dim) const {
536  if (dim >= NumDimensions || dim < 0) {
537  DASH_THROW(
539  "Wrong dimension for ShiftTilePattern::local_extent. "
540  << "Expected dimension between 0 and " << NumDimensions-1 << ", "
541  << "got " << dim);
542  }
543  return _memory_layout.extent(dim);
544  }
545 
557  SizeType local_extent(dim_t dim) const {
558  if (dim >= NumDimensions || dim < 0) {
559  DASH_THROW(
561  "Wrong dimension for ShiftTilePattern::local_extent. "
562  << "Expected dimension between 0 and " << NumDimensions-1 << ", "
563  << "got " << dim);
564  }
565  return _local_memory_layout.extent(dim);
566  }
567 
579  std::array<SizeType, NumDimensions> local_extents() const {
580  // Same local memory layout for all units:
581  return _local_memory_layout.extents();
582  }
583 
587 
594  IndexType local_at(
596  const std::array<IndexType, NumDimensions> & local_coords,
598  const ViewSpec_t & viewspec) const
599  {
600  DASH_LOG_TRACE("ShiftTilePattern.local_at()", local_coords,
601  "view:", viewspec,
602  "local blocks:", _local_blockspec.extents());
603  // Phase coordinates of element:
604  std::array<IndexType, NumDimensions> phase_coords{};
605  // Coordinates of the local block containing the element:
606  std::array<IndexType, NumDimensions> block_coords_l{};
607  for (auto d = 0; d < NumDimensions; ++d) {
608  auto vs_offset_d = viewspec.offset(d);
609  auto vs_coord_d = local_coords[d] + vs_offset_d;
610  auto block_size_d = _blocksize_spec.extent(d);
611  phase_coords[d] = vs_coord_d % block_size_d;
612  block_coords_l[d] = vs_coord_d / block_size_d;
613  }
614  DASH_LOG_TRACE("ShiftTilePattern.local_at",
615  "local block coords:", block_coords_l,
616  "phase coords:", phase_coords);
617  // Number of blocks preceeding the coordinates' block:
618  auto block_offset_l = _local_blockspec.at(block_coords_l);
619  auto local_index =
620  block_offset_l * _blocksize_spec.size() + // preceeding blocks
621  _blocksize_spec.at(phase_coords); // element phase
622  DASH_LOG_TRACE_VAR("ShiftTilePattern.local_at >", local_index);
623  return local_index;
624  }
625 
631  IndexType local_at(
633  const std::array<IndexType, NumDimensions> & local_coords) const
634  {
635  DASH_LOG_TRACE("ShiftTilePattern.local_at()", local_coords,
636  "local blocks:", _local_blockspec.extents());
637  // Phase coordinates of element:
638  std::array<IndexType, NumDimensions> phase_coords{};
639  // Coordinates of the local block containing the element:
640  std::array<IndexType, NumDimensions> block_coords_l{};
641  for (auto d = 0; d < NumDimensions; ++d) {
642  auto vs_coord_d = local_coords[d];
643  auto block_size_d = _blocksize_spec.extent(d);
644  phase_coords[d] = vs_coord_d % block_size_d;
645  block_coords_l[d] = vs_coord_d / block_size_d;
646  }
647  DASH_LOG_TRACE("ShiftTilePattern.local_at",
648  "local block coords:", block_coords_l,
649  "phase coords:", phase_coords);
650  // Number of blocks preceeding the coordinates' block:
651  auto block_offset_l = _local_blockspec.at(block_coords_l);
652  auto local_index =
653  block_offset_l * _blocksize_spec.size() + // preceeding blocks
654  _blocksize_spec.at(phase_coords); // element phase
655  DASH_LOG_TRACE_VAR("ShiftTilePattern.local_at >", local_index);
656  return local_index;
657  }
658 
668  const std::array<IndexType, NumDimensions> & global_coords) const
669  {
670  local_coords_t l_coords;
671  l_coords.coords = local_coords(global_coords);
672  l_coords.unit = unit_at(global_coords);
673  return l_coords;
674  }
675 
684  IndexType g_index) const
685  {
686  DASH_LOG_TRACE_VAR("ShiftTilePattern.local()", g_index);
687  // TODO: Implement dedicated method for this, conversion to/from
688  // global coordinates is expensive.
689  auto g_coords = coords(g_index);
690  return local_index(g_coords);
691  }
692 
699  std::array<IndexType, NumDimensions> local_coords(
700  const std::array<IndexType, NumDimensions> & global_coords) const
701  {
702  std::array<IndexType, NumDimensions> local_coords = global_coords;
703  auto blocksize_d = _blocksize_spec.extent(_major_tiled_dim);
704  auto coord_d = global_coords[_major_tiled_dim];
705  local_coords[_major_tiled_dim] =
706  // Local block offset
707  (coord_d / (blocksize_d * _nunits)) * blocksize_d +
708  // Phase
709  (coord_d % blocksize_d);
710  return local_coords;
711  }
712 
719  const std::array<IndexType, NumDimensions> & global_coords) const
720  {
721  DASH_LOG_TRACE_VAR("Pattern.local_index()", global_coords);
722  // Local offset of the element within all of the unit's local
723  // elements:
724  auto unit = unit_at(global_coords);
725 #ifdef __OLD__
726  // Global coords to local coords:
727  std::array<IndexType, NumDimensions> l_coords =
728  local_coords(global_coords);
729  // Local coords to local offset:
730  auto l_index = local_at(l_coords);
731 #endif
732  auto l_index = at(global_coords);
733  DASH_LOG_TRACE_VAR("Pattern.local_index >", l_index);
734 
735  return local_index_t { team_unit_t(unit), l_index };
736  }
737 
741 
747  std::array<IndexType, NumDimensions> global(
748  team_unit_t unit,
749  const std::array<IndexType, NumDimensions> & local_coords) const {
750  DASH_LOG_DEBUG("ShiftTilePattern.global()",
751  "unit:", unit,
752  "lcoords:", local_coords);
753  // Global coordinate of local element:
754  std::array<IndexType, NumDimensions> global_coords = local_coords;
755  // Local block coordinate of local element:
756  auto blocksize_maj = _blocksize_spec.extent(_major_tiled_dim);
757  auto blocksize_min = _blocksize_spec.extent(_minor_tiled_dim);
758  auto l_block_coord_maj = local_coords[_major_tiled_dim] /
759  blocksize_maj;
760  auto l_block_coord_min = (NumDimensions > 1)
761  ? local_coords[_minor_tiled_dim] /
762  blocksize_min
763  : 0;
764  DASH_LOG_TRACE("ShiftTilePattern.global",
765  "minor tiled dim:", _minor_tiled_dim,
766  "major tiled dim:", _major_tiled_dim,
767  "l_block_coord_min:", l_block_coord_min,
768  "l_block_coord_maj:", l_block_coord_maj);
769  // Apply diagonal shift in major tiled dimension:
770  auto num_shift_blocks = (_nunits + unit -
771  (l_block_coord_min % _nunits))
772  % _nunits;
773  num_shift_blocks += _nunits * l_block_coord_maj;
774  DASH_LOG_TRACE("ShiftTilePattern.global",
775  "num_shift_blocks:", num_shift_blocks,
776  "blocksize_maj:", blocksize_maj);
777  global_coords[_major_tiled_dim] =
778  (num_shift_blocks * blocksize_maj) +
779  local_coords[_major_tiled_dim] % blocksize_maj;
780  DASH_LOG_DEBUG_VAR("ShiftTilePattern.global >", global_coords);
781  return global_coords;
782  }
783 
789  std::array<IndexType, NumDimensions> global(
790  const std::array<IndexType, NumDimensions> & local_coords) const
791  {
792  return global(_team->myid(), local_coords);
793  }
794 
803  IndexType global(
804  IndexType local_index) const
805  {
806  DASH_LOG_TRACE("ShiftTilePattern.global()",
807  "local_index:", local_index,
808  "unit:", team().myid());
809  auto block_size = _blocksize_spec.size();
810  auto phase = local_index % block_size;
811  auto l_block_index = local_index / block_size;
812  // Block coordinate in local memory:
813  auto l_block_coord = _local_blockspec.coords(l_block_index);
814  // Coordinate of element in block:
815  auto phase_coord = _blocksize_spec.coords(phase);
816  DASH_LOG_TRACE("ShiftTilePattern.global",
817  "local block index:", l_block_index,
818  "local block coords:", l_block_coord,
819  "phase coords:", phase_coord);
820  // Coordinate of element in local memory:
821  std::array<IndexType, NumDimensions> l_coords{};
822  for (auto d = 0; d < NumDimensions; ++d) {
823  l_coords[d] = l_block_coord[d] * _blocksize_spec.extent(d) +
824  phase_coord[d];
825  }
826  std::array<IndexType, NumDimensions> g_coords =
827  global(team().myid(), l_coords);
828  auto offset = global_at(g_coords);
829  DASH_LOG_TRACE_VAR("ShiftTilePattern.global >", offset);
830  return offset;
831  }
832 
842  IndexType global_index(
843  team_unit_t unit,
844  const std::array<IndexType, NumDimensions> & local_coords) const
845  {
846  DASH_LOG_TRACE("ShiftTilePattern.global_index()",
847  "unit:", unit,
848  "local_coords:", local_coords);
849  std::array<IndexType, NumDimensions> global_coords =
850  global(unit, local_coords);
851  auto g_index = global_at(global_coords);
852  DASH_LOG_TRACE_VAR("ShiftTilePattern.global_index >", g_index);
853  return g_index;
854  }
855 
869  IndexType global_at(
870  const std::array<IndexType, NumDimensions> & global_coords,
871  const ViewSpec_t & viewspec) const
872  {
873  DASH_LOG_TRACE("ShiftTilePattern.global_at()",
874  "gcoords:", global_coords,
875  "viewspec:", viewspec);
876  // Phase coordinates of element:
877  std::array<IndexType, NumDimensions> phase_coords{};
878  // Coordinates of the block containing the element:
879  std::array<IndexType, NumDimensions> block_coords{};
880  for (auto d = 0; d < NumDimensions; ++d) {
881  auto vs_coord = global_coords[d] + viewspec.offset(d);
882  phase_coords[d] = vs_coord % _blocksize_spec.extent(d);
883  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
884  }
885  DASH_LOG_TRACE("ShiftTilePattern.global_at",
886  "block coords:", block_coords,
887  "phase coords:", phase_coords);
888  // Number of blocks preceeding the coordinates' block, equivalent
889  // to linear global block offset:
890  auto block_index = _blockspec.at(block_coords);
891  DASH_LOG_TRACE("ShiftTilePattern.global_at",
892  "block index:", block_index);
893  auto offset = block_index * _blocksize_spec.size() + // preceed. blocks
894  _blocksize_spec.at(phase_coords); // element phase
895  DASH_LOG_TRACE_VAR("ShiftTilePattern.global_at >", offset);
896  return offset;
897  }
898 
911  IndexType global_at(
912  const std::array<IndexType, NumDimensions> & global_coords) const
913  {
914  DASH_LOG_TRACE("ShiftTilePattern.global_at()",
915  "gcoords:", global_coords);
916  // Phase coordinates of element:
917  std::array<IndexType, NumDimensions> phase_coords;
918  // Coordinates of the block containing the element:
919  std::array<IndexType, NumDimensions> block_coords;
920  for (auto d = 0; d < NumDimensions; ++d) {
921  auto vs_coord = global_coords[d];
922  phase_coords[d] = vs_coord % _blocksize_spec.extent(d);
923  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
924  }
925  DASH_LOG_TRACE("ShiftTilePattern.global_at",
926  "block coords:", block_coords,
927  "phase coords:", phase_coords);
928  // Number of blocks preceeding the coordinates' block, equivalent
929  // to linear global block offset:
930  auto block_index = _blockspec.at(block_coords);
931  DASH_LOG_TRACE("ShiftTilePattern.global_at",
932  "block index:", block_index);
933  auto offset = block_index * _blocksize_spec.size() + // preceed. blocks
934  _blocksize_spec.at(phase_coords); // element phase
935  DASH_LOG_TRACE_VAR("ShiftTilePattern.global_at >", offset);
936  return offset;
937  }
938 
942 
954  IndexType at(
955  const std::array<IndexType, NumDimensions> & global_coords,
956  const ViewSpec_t & viewspec) const
957  {
958  DASH_LOG_TRACE("ShiftTilePattern.at()",
959  "gcoords:", global_coords,
960  "viewspec:", viewspec);
961  // Phase coordinates of element:
962  std::array<IndexType, NumDimensions> phase_coords;
963  // Coordinates of the block containing the element:
964  std::array<IndexType, NumDimensions> block_coords;
965  for (auto d = 0; d < NumDimensions; ++d) {
966  auto vs_coord = global_coords[d] + viewspec.offset(d);
967  phase_coords[d] = vs_coord % _blocksize_spec.extent(d);
968  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
969  }
970  DASH_LOG_TRACE("ShiftTilePattern.at",
971  "block_coords:", block_coords,
972  "phase_coords:", phase_coords);
973  // Number of blocks preceeding the coordinates' block, equivalent
974  // to linear global block offset divided by team size:
975  DASH_LOG_TRACE_VAR("ShiftTilePattern.at", _blockspec.extents());
976  auto block_index = _blockspec.at(block_coords);
977  auto block_index_l = block_index / _nunits;
978  DASH_LOG_TRACE("ShiftTilePattern.at",
979  "global block index:",block_index,
980  "nunits:", _nunits,
981  "local block index:", block_index_l);
982  auto offset = block_index_l * _blocksize_spec.size() + // preceed. blocks
983  _blocksize_spec.at(phase_coords); // element phase
984  DASH_LOG_TRACE_VAR("ShiftTilePattern.at >", offset);
985  return offset;
986  }
987 
996  IndexType at(
997  std::array<IndexType, NumDimensions> global_coords) const
998  {
999  // Note:
1000  // Expects extent[d] to be a multiple of blocksize[d] * nunits[d]
1001  // to ensure the balanced property.
1002  DASH_LOG_TRACE_VAR("ShiftTilePattern.at()", global_coords);
1003  // Phase coordinates of element:
1004  std::array<IndexType, NumDimensions> phase_coords{};
1005  // Coordinates of the block containing the element:
1006  std::array<IndexType, NumDimensions> block_coords{};
1007  for (auto d = 0; d < NumDimensions; ++d) {
1008  auto coord = global_coords[d];
1009  phase_coords[d] = coord % _blocksize_spec.extent(d);
1010  block_coords[d] = coord / _blocksize_spec.extent(d);
1011  }
1012  DASH_LOG_TRACE_VAR("ShiftTilePattern.at", block_coords);
1013  DASH_LOG_TRACE_VAR("ShiftTilePattern.at", phase_coords);
1014  // Number of blocks preceeding the coordinates' block, equivalent
1015  // to linear global block offset divided by team size:
1016  DASH_LOG_TRACE_VAR("ShiftTilePattern.at", _blockspec.extents());
1017  auto block_offset = _blockspec.at(block_coords);
1018  auto block_offset_l = block_offset / _nunits;
1019  DASH_LOG_TRACE_VAR("ShiftTilePattern.at", block_offset);
1020  DASH_LOG_TRACE_VAR("ShiftTilePattern.at", _nunits);
1021  DASH_LOG_TRACE_VAR("ShiftTilePattern.at", block_offset_l);
1022  return block_offset_l * _blocksize_spec.size() + // preceeding blocks
1023  _blocksize_spec.at(phase_coords); // element phase
1024  }
1025 
1033  template<typename ... Values>
1034  IndexType at(Values ... values) const
1035  {
1036  static_assert(
1037  sizeof...(values) == NumDimensions,
1038  "Wrong parameter number");
1039  std::array<IndexType, NumDimensions> inputindex = {
1040  (IndexType)values...
1041  };
1042  return at(inputindex);
1043  }
1044 
1048 
1057  dim_t dim,
1059  IndexType dim_offset,
1061  team_unit_t unit,
1063  const ViewSpec_t & viewspec) const
1064  {
1065  DASH_LOG_TRACE_VAR("ShiftTilePattern.has_local_elements()", dim);
1066  DASH_LOG_TRACE_VAR("ShiftTilePattern.has_local_elements()", dim_offset);
1067  DASH_LOG_TRACE_VAR("ShiftTilePattern.has_local_elements()", unit);
1068  DASH_LOG_TRACE_VAR("ShiftTilePattern.has_local_elements()", viewspec);
1069  // Apply viewspec offset in dimension to given position
1070  dim_offset += viewspec.offset(dim);
1071  // Offset to block offset
1072  IndexType block_coord_d = dim_offset / _blocksize_spec.extent(dim);
1073  DASH_LOG_TRACE_VAR("ShiftTilePattern.has_local_elements", block_coord_d);
1074  // Coordinate of unit in team spec in given dimension
1075  IndexType teamspec_coord_d = block_coord_d % _teamspec.extent(dim);
1076  DASH_LOG_TRACE_VAR("ShiftTilePattern.has_local_elements",
1077  teamspec_coord_d);
1078  // Check if unit id lies in cartesian sub-space of team spec
1079  return _teamspec.includes_index(
1080  teamspec_coord_d,
1081  dim,
1082  dim_offset);
1083  }
1084 
1090  bool is_local(
1091  IndexType index,
1092  team_unit_t unit) const
1093  {
1094  auto glob_coords = coords(index);
1095  auto coords_unit = unit_at(glob_coords);
1096  DASH_LOG_TRACE_VAR("ShiftTilePattern.is_local >", (coords_unit == unit));
1097  return coords_unit == unit;
1098  }
1099 
1106  bool is_local(
1107  IndexType index) const
1108  {
1109  return is_local(index, team().myid());
1110  }
1111 
1115 
1121  index_type block_at(
1123  const std::array<index_type, NumDimensions> & g_coords) const
1124  {
1125  std::array<index_type, NumDimensions> block_coords;
1126  // Coord to block coord to unit coord:
1127  for (auto d = 0; d < NumDimensions; ++d) {
1128  block_coords[d] = g_coords[d] / _blocksize_spec.extent(d);
1129  }
1130  // Block coord to block index:
1131  auto block_idx = _blockspec.at(block_coords);
1132  DASH_LOG_TRACE("ShiftTilePattern.block_at",
1133  "coords", g_coords,
1134  "> block index", block_idx);
1135  return block_idx;
1136  }
1137 
1145  const std::array<index_type, NumDimensions> & g_coords) const
1146  {
1147  DASH_THROW(
1149  "ShiftTilePattern.local_block_at is not implemented");
1150  }
1151 
1156  ViewSpec_t block(
1157  index_type global_block_index) const
1158  {
1159  DASH_LOG_TRACE_VAR("ShiftTilePattern.block()", global_block_index);
1160  // block index -> block coords -> offset
1161  auto block_coords = _blockspec.coords(global_block_index);
1162  DASH_LOG_TRACE_VAR("ShiftTilePattern.block", block_coords);
1163  DASH_LOG_TRACE_VAR("ShiftTilePattern.block", _blocksize_spec.extents());
1164  std::array<index_type, NumDimensions> offsets{};
1165  std::array<size_type, NumDimensions> extents{};
1166  for (auto d = 0; d < NumDimensions; ++d) {
1167  extents[d] = _blocksize_spec.extent(d);
1168  offsets[d] = block_coords[d] * extents[d];
1169  }
1170  DASH_LOG_TRACE("ShiftTilePattern.block",
1171  "offsets:", offsets,
1172  "extents:", extents);
1173  auto block_vs = ViewSpec_t(offsets, extents);
1174  DASH_LOG_TRACE_VAR("ShiftTilePattern.block >", block_vs);
1175  return block_vs;
1176  }
1177 
1182  ViewSpec_t local_block(
1183  index_type local_block_index) const {
1184  DASH_LOG_TRACE_VAR("ShiftTilePattern.local_block()", local_block_index);
1185  // Local block index to local block coords:
1186  auto l_block_coords = _local_blockspec.coords(local_block_index);
1187  DASH_LOG_TRACE_VAR("ShiftTilePattern.local_block()", l_block_coords);
1188  std::array<index_type, NumDimensions> l_elem_coords{};
1189  // TODO: This is convenient but less efficient:
1190  // Translate local coordinates of first element in local block to global
1191  // coordinates:
1192  for (auto d = 0; d < NumDimensions; ++d) {
1193  auto blocksize_d = _blocksize_spec.extent(d);
1194  l_elem_coords[d] = static_cast<index_type>(
1195  l_block_coords[d] * blocksize_d);
1196  }
1197  // Global coordinates of first element in block:
1198  auto g_elem_coords = global(l_elem_coords);
1199  DASH_LOG_TRACE_VAR("ShiftTilePattern.local_block()", g_elem_coords);
1200  std::array<index_type, NumDimensions> offsets{};
1201  std::array<size_type, NumDimensions> extents{};
1202  for (auto d = 0; d < NumDimensions; ++d) {
1203  offsets[d] = g_elem_coords[d];
1204  extents[d] = _blocksize_spec.extent(d);
1205  }
1206  ViewSpec_t block_vs(offsets, extents);
1207  DASH_LOG_TRACE_VAR("ShiftTilePattern.local_block >", block_vs);
1208 #ifdef __TODO__
1209  // Coordinates of the unit within the team spec:
1210  std::array<IndexType, NumDimensions> unit_ts_coord =
1211  _teamspec.coords(unit);
1212  for (auto d = 0; d < NumDimensions; ++d) {
1213  const Distribution & dist = _distspec[d];
1214  auto blocksize_d = block_vs[d].extent;
1215  auto num_units_d = _teamspec.extent(d);
1216  auto num_blocks_d = _blockspec.extent(d);
1217  // Local to global block coords:
1218  auto g_block_coord_d = (l_block_coords[d] + _myid) *
1219  _teamspec.extent(d);
1220  block_vs[d].offset = g_block_coord_d * blocksize_d;
1221  }
1222 #endif
1223  return block_vs;
1224  }
1225 
1230  ViewSpec_t local_block_local(
1231  index_type local_block_index) const {
1232  DASH_LOG_TRACE_VAR("ShiftTilePattern.local_block_local()", local_block_index);
1233  // Initialize viewspec result with block extents:
1234  std::array<index_type, NumDimensions> offsets{};
1235  std::array<size_type, NumDimensions> extents =
1236  _blocksize_spec.extents();
1237  // Local block index to local block coords:
1238  auto l_block_coords = _local_blockspec.coords(local_block_index);
1239  // Local block coords to local element offset:
1240  for (auto d = 0; d < NumDimensions; ++d) {
1241  auto blocksize_d = extents[d];
1242  offsets[d] = l_block_coords[d] * blocksize_d;
1243  }
1244  ViewSpec_t block_vs(offsets, extents);
1245  DASH_LOG_TRACE_VAR("ShiftTilePattern.local_block >", block_vs);
1246  return block_vs;
1247  }
1248 
1252  const BlockSpec_t & blockspec() const
1253  {
1254  return _blockspec;
1255  }
1256 
1260  const BlockSpec_t & local_blockspec() const
1261  {
1262  return _local_blockspec;
1263  }
1264 
1272  SizeType blocksize(
1274  dim_t dimension) const {
1275  return _blocksize_spec.extent(dimension);
1276  }
1277 
1286  inline SizeType max_blocksize() const {
1287  return _blocksize_spec.size();
1288  }
1289 
1296  inline SizeType local_capacity() const {
1297  // Balanced pattern, local capacity identical for every unit and
1298  // same as local size.
1299  return local_size();
1300  }
1301 
1312  inline SizeType local_size(
1313  team_unit_t unit = UNDEFINED_TEAM_UNIT_ID) const
1314  {
1315  return _local_memory_layout.size();
1316  }
1317 
1323  inline IndexType num_units() const {
1324  return _teamspec.size();
1325  }
1326 
1332  inline IndexType capacity() const {
1333  return _memory_layout.size();
1334  }
1335 
1341  inline IndexType size() const {
1342  return _memory_layout.size();
1343  }
1344 
1349  inline dash::Team & team() const {
1350  return *_team;
1351  }
1352 
1356  inline const DistributionSpec_t & distspec() const {
1357  return _distspec;
1358  }
1359 
1365  SizeSpec_t sizespec() const {
1366  return SizeSpec_t(_memory_layout.extents());
1367  }
1368 
1374  const std::array<SizeType, NumDimensions> & extents() const {
1375  return _memory_layout.extents();
1376  }
1377 
1384  const TeamSpec_t & teamspec() const {
1385  return _teamspec;
1386  }
1387 
1394  std::array<IndexType, NumDimensions> coords(
1396  IndexType index) const {
1397 
1398  ::std::array<IndexType, NumDimensions> pos{};
1399  auto block_coords = _blockspec.coords(index / _blocksize_spec.size());
1400  auto phase_coords = _blocksize_spec.coords(index % _blocksize_spec.size());
1401  for (auto d = 0; d < NumDimensions; ++d) {
1402  pos[d] = block_coords[d]*_blocksize_spec.extent(d) + phase_coords[d];
1403  }
1404  return pos;
1405  }
1406 
1413  std::array<IndexType, NumDimensions> coords(
1415  IndexType index,
1417  const ViewSpec_t & viewspec) const {
1418 
1419  ::std::array<IndexType, NumDimensions> pos;
1420  auto block_coords = _blockspec.coords(index / _blocksize_spec.size(),
1421  viewspec);
1422  auto phase_coords = _blocksize_spec.coords(index % _blocksize_spec.size(),
1423  viewspec);
1424  for (auto d = 0; d < NumDimensions; ++d) {
1425  pos[d] = block_coords[d]*_blocksize_spec.extent(d) + phase_coords[d];
1426  }
1427  return pos;
1428  }
1429 
1433  constexpr static MemArrange memory_order() {
1434  return Arrangement;
1435  }
1436 
1440  constexpr static dim_t ndim() {
1441  return NumDimensions;
1442  }
1443 
1444 private:
1445 
1446  ShiftTilePattern(const PatternArguments_t & arguments)
1447  : _distspec(arguments.distspec()),
1448  _team(&arguments.team()),
1449  _teamspec(arguments.teamspec()),
1450  _memory_layout(arguments.sizespec().extents()),
1451  _nunits(_teamspec.size()),
1452  _major_tiled_dim(initialize_major_tiled_dim(_distspec)),
1453  _minor_tiled_dim((_major_tiled_dim + 1) % NumDimensions),
1454  _blocksize_spec(initialize_blocksizespec(
1455  arguments.sizespec(),
1456  _distspec,
1457  _teamspec)),
1458  _blockspec(initialize_blockspec(
1459  arguments.sizespec(),
1460  _blocksize_spec,
1461  _teamspec)),
1462  _local_blockspec(initialize_local_blockspec(
1463  _blockspec,
1464  _major_tiled_dim,
1465  _nunits)),
1466  _local_memory_layout(
1467  initialize_local_extents(_team->myid())),
1468  _local_capacity(initialize_local_capacity())
1469  {}
1474  BlockSizeSpec_t initialize_blocksizespec(
1475  const SizeSpec_t & sizespec,
1476  const DistributionSpec_t & distspec,
1477  const TeamSpec_t & teamspec) const {
1478  DASH_LOG_TRACE("ShiftTilePattern.init_blocksizespec()");
1479  // Extents of a single block:
1480  std::array<SizeType, NumDimensions> s_blocks{};
1481  for (auto d = 0; d < NumDimensions; ++d) {
1482  const Distribution & dist = distspec[d];
1483  DASH_LOG_TRACE("ShiftTilePattern.init_blocksizespec d",
1484  "sizespec extent[d]:", sizespec.extent(d),
1485  "teamspec extent[d]:", teamspec.extent(d));
1486  SizeType max_blocksize_d = dist.max_blocksize_in_range(
1487  sizespec.extent(d), // size of range (extent)
1488  teamspec.extent(d)); // number of blocks (units)
1489  s_blocks[d] = max_blocksize_d;
1490  }
1491  DASH_LOG_TRACE_VAR("ShiftTilePattern.init_blocksizespec >", s_blocks);
1492  return BlockSizeSpec_t(s_blocks);
1493  }
1494 
1499  BlockSpec_t initialize_blockspec(
1500  const SizeSpec_t & sizespec,
1501  const BlockSizeSpec_t & blocksizespec,
1502  const TeamSpec_t & teamspec) const
1503  {
1504  DASH_LOG_TRACE("ShiftTilePattern.init_blockspec()",
1505  "pattern size:", sizespec.extents(),
1506  "block size:", blocksizespec.extents(),
1507  "team size:", teamspec.extents());
1508  // Number of blocks in all dimensions:
1509  std::array<SizeType, NumDimensions> n_blocks{};
1510  for (auto d = 0; d < NumDimensions; ++d) {
1511  SizeType max_blocksize_d = blocksizespec.extent(d);
1512  SizeType max_blocks_d = dash::math::div_ceil(
1513  sizespec.extent(d),
1514  max_blocksize_d);
1515  n_blocks[d] = max_blocks_d;
1516  }
1517  BlockSpec_t blockspec(n_blocks);
1518  DASH_LOG_TRACE_VAR("ShiftTilePattern.init_blockspec >", n_blocks);
1519  return blockspec;
1520  }
1521 
1526  BlockSpec_t initialize_local_blockspec(
1527  const BlockSpec_t & blockspec,
1528  dim_t major_tiled_dim,
1529  size_t nunits) const
1530  {
1531  DASH_LOG_TRACE_VAR("ShiftTilePattern.init_local_blockspec()",
1532  blockspec.extents());
1533  DASH_LOG_TRACE_VAR("ShiftTilePattern.init_local_blockspec()",
1534  nunits);
1535  // Number of local blocks in all dimensions:
1536  auto l_blocks = blockspec.extents();
1537  l_blocks[major_tiled_dim] /= nunits;
1538  DASH_ASSERT_GT(l_blocks[major_tiled_dim], 0,
1539  "ShiftTilePattern: Size must be divisible by team size");
1540  DASH_LOG_TRACE_VAR("ShiftTilePattern.init_local_blockspec >", l_blocks);
1541  return BlockSpec_t(l_blocks);
1542  }
1543 
1551  SizeType initialize_local_capacity() const
1552  {
1553  // Assumes balanced distribution property, i.e.
1554  // range = k * blocksz * nunits
1555  auto l_capacity = size() / _nunits;
1556  DASH_LOG_TRACE_VAR("ShiftTilePattern.init_local_capacity >", l_capacity);
1557  return l_capacity;
1558  }
1559 
1564  void initialize_local_range() {
1565  auto local_size = _local_memory_layout.size();
1566  DASH_LOG_DEBUG_VAR("ShiftTilePattern.init_local_range()", local_size);
1567  if (local_size == 0) {
1568  _lbegin = 0;
1569  _lend = 0;
1570  } else {
1571  // First local index transformed to global index
1572  _lbegin = global(0);
1573  // Index past last local index transformed to global index
1574  _lend = global(local_size - 1) + 1;
1575  }
1576  DASH_LOG_DEBUG_VAR("ShiftTilePattern.init_local_range >",
1577  _local_memory_layout.extents());
1578  DASH_LOG_DEBUG_VAR("ShiftTilePattern.init_local_range >", _lbegin);
1579  DASH_LOG_DEBUG_VAR("ShiftTilePattern.init_local_range >", _lend);
1580  }
1581 
1586  dim_t initialize_major_tiled_dim(const DistributionSpec_t & ds)
1587  {
1588  DASH_LOG_TRACE("ShiftTilePattern.init_major_tiled_dim()");
1589  if (Arrangement == dash::COL_MAJOR) {
1590  DASH_LOG_TRACE("ShiftTilePattern.init_major_tiled_dim", "column major");
1591  for (auto d = 0; d < NumDimensions; ++d) {
1592  if (ds[d].type == dash::internal::DIST_TILE) {
1593  DASH_LOG_TRACE("ShiftTilePattern.init_major_tiled_dim >", d);
1594  return d;
1595  }
1596  }
1597  } else {
1598  DASH_LOG_TRACE("ShiftTilePattern.init_major_tiled_dim", "row major");
1599  for (auto d = NumDimensions-1; d >= 0; --d) {
1600  if (ds[d].type == dash::internal::DIST_TILE) {
1601  DASH_LOG_TRACE("ShiftTilePattern.init_major_tiled_dim >", d);
1602  return d;
1603  }
1604  }
1605  }
1607  "Distribution is not tiled in any dimension");
1608  }
1609 
1613  std::array<SizeType, NumDimensions> initialize_local_extents(
1614  team_unit_t unit) const {
1615  // Coordinates of local unit id in team spec:
1616 #ifdef DASH_ENABLE_LOGGING
1617  auto unit_ts_coords = _teamspec.coords(unit);
1618  DASH_LOG_DEBUG_VAR("ShiftTilePattern._local_extents()", unit);
1619  DASH_LOG_TRACE_VAR("ShiftTilePattern._local_extents", unit_ts_coords);
1620 #endif
1621  ::std::array<SizeType, NumDimensions> l_extents{};
1622  for (auto d = 0; d < NumDimensions; ++d) {
1623  // Number of units in dimension:
1624  auto num_units_d = _teamspec.extent(d);
1625  // Number of blocks in dimension:
1626  auto num_blocks_d = _blockspec.extent(d);
1627  // Maximum extent of single block in dimension:
1628  auto blocksize_d = _blocksize_spec.extent(d);
1629  // Minimum number of blocks local to every unit in dimension:
1630  auto min_local_blocks_d = num_blocks_d / num_units_d;
1631  // Coordinate of this unit id in teamspec in dimension:
1632 // auto unit_ts_coord = unit_ts_coords[d];
1633  // Possibly there are more blocks than units in dimension and no
1634  // block left for this unit. Local extent in d then becomes 0.
1635  l_extents[d] = min_local_blocks_d * blocksize_d;
1636  }
1637  DASH_LOG_DEBUG_VAR("ShiftTilePattern._local_extents >", l_extents);
1638  return l_extents;
1639  }
1640 };
1641 
1642 } // namespace dash
1643 
1644 #include <dash/pattern/ShiftTilePattern1D.h>
1645 
1646 #endif // DASH__SHIFT_TILE_PATTERN_H_
std::array< IndexType, NumDimensions > coords(IndexType index, const ViewSpec_t &viewspec) const
Convert given global linear offset (index) to global cartesian coordinates using viewspec.
IndexType at(std::array< IndexType, NumDimensions > global_coords) const
Global coordinates to local index.
constexpr team_unit_t UNDEFINED_TEAM_UNIT_ID
Invalid local unit ID.
Definition: Types.h:341
IndexType global_at(const std::array< IndexType, NumDimensions > &global_coords, const ViewSpec_t &viewspec) const
Global coordinates and viewspec to global position in the pattern&#39;s iteration order.
All blocks have identical size.
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.
SizeType 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...
ShiftTilePattern(const SizeSpec_t &sizespec, DistributionSpec_t dist=DistributionSpec_t(), Team &team=dash::Team::All())
Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec and a Team...
const BlockSpec_t & blockspec() const
Cartesian arrangement of pattern blocks.
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
IndexType at(Values ... values) const
Global coordinates to local index.
SizeType extent(dim_t dim) const
extent
SizeType local_size(team_unit_t unit=UNDEFINED_TEAM_UNIT_ID) const
The actual number of elements in this pattern that are local to the calling unit in total...
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
std::array< SizeType, NumDimensions > local_extents() const
The actual number of elements in this pattern that are local to the given unit, by dimension...
Local element order corresponds to a logical linearization within single blocks (if blocked) or withi...
IndexType global_at(const std::array< IndexType, NumDimensions > &global_coords) const
Global coordinates to global position in the pattern&#39;s iteration order.
ShiftTilePattern(self_t &other)
Copy constructor using non-const lvalue reference parameter.
IndexType global(IndexType local_index) const
Resolve an element&#39;s linear global index from the calling unit&#39;s local index of that element...
team_unit_t unit_at(IndexType global_pos, const ViewSpec_t &viewspec) const
Convert given global linear index to its assigned unit id.
Specifies cartesian extents in a specific number of dimensions.
Definition: Cartesian.h:197
ShiftTilePattern(const SizeSpec_t &sizespec, DistributionSpec_t dist, TeamSpec_t teamspec, dash::Team &team=dash::Team::All())
Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec, TeamSpec and a Team.
Specifies view parameters for implementing submat, rows and cols.
Definition: Dimensional.h:430
static constexpr MemArrange memory_order()
Memory order followed by the pattern.
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
IndexType lend() const
Resolves the global index past the last local element in the pattern.
IndexType local_at(const std::array< IndexType, NumDimensions > &local_coords) const
Convert given local coordinates to linear local offset (index).
bool is_local(IndexType index, team_unit_t unit) const
Whether the given global index is local to the specified unit.
index_type block_at(const std::array< index_type, NumDimensions > &g_coords) const
block
SizeType blocksize(dim_t dimension) const
Maximum number of elements in a single block in the given dimension.
The number of blocks assigned to units may differ.
ViewSpec_t local_block(index_type local_block_index) const
View spec (offset and extents) of block at local linear block index in global cartesian element space...
bool operator!=(const self_t &other) const
Inquality comparison operator.
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.
bool operator==(const self_t &other) const
Equality comparison operator.
Block extents are constant for every dimension.
The number of assigned blocks is identical for every unit.
bool has_local_elements(dim_t dim, IndexType dim_offset, team_unit_t unit, const ViewSpec_t &viewspec) const
is_local
Units are mapped to blocks in diagonal chains in all hyperplanes.
IndexType local_at(const std::array< IndexType, NumDimensions > &local_coords, const ViewSpec_t &viewspec) const
local
size_t size() const
The number of units in this team.
Definition: Team.h:498
IndexType size() const
The number of elements arranged in this pattern.
std::array< IndexType, NumDimensions > global(const std::array< IndexType, NumDimensions > &local_coords) const
Converts local coordinates of a active unit to global coordinates.
const DistributionSpec_t & distspec() const
Distribution specification of this pattern.
SizeType local_capacity() const
Maximum number of elements assigned to a single unit in total, equivalent to the local capacity of ev...
internal::default_signed_index default_index_t
Signed integer type used as default for index values.
Definition: Types.h:59
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
A Team instance specifies a subset of all available units.
Definition: Team.h:41
IndexType global_index(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
Resolve an element&#39;s linear global index from a given unit&#39;s local coordinates of that element...
ViewSpec_t block(index_type global_block_index) const
View spec (offset and extents) of block at global linear block index in global cartesian element spac...
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402
IndexType at(const std::array< IndexType, NumDimensions > &global_coords, const ViewSpec_t &viewspec) const
at
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497
Elements are contiguous in local memory within a single block and thus indexed blockwise.
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
Defines how a list of global indices is mapped to single units within a Team.
const BlockSpec_t & local_blockspec() const
Cartesian arrangement of pattern blocks.
Defines a cartesian, totally-ordered index space by mapping linear indices to cartesian coordinates d...
Definition: Cartesian.h:239
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
Specifies how a Pattern distributes elements to units in a specific dimension.
Definition: Distribution.h:24
pattern_partitioning_properties< pattern_partitioning_tag::rectangular, pattern_partitioning_tag::balanced > partitioning_properties
Satisfiable properties in pattern property category Partitioning:
const TeamSpec_t & teamspec() const
Cartesian arrangement of the Team containing the units to which this pattern&#39;s elements are mapped...
const std::array< SizeType, NumDimensions > & extents() const
Size specification of the index space mapped by this pattern.
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
SizeType max_blocksize() const
Maximum number of elements in a single block in all dimensions.
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords) const
Convert given coordinate in pattern to its assigned unit id.
ShiftTilePattern(const self_t &other)
Copy constructor.
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
pattern_mapping_properties< pattern_mapping_tag::balanced, pattern_mapping_tag::unbalanced, pattern_mapping_tag::diagonal > mapping_properties
Satisfiable properties in pattern property category Mapping:
local_index_t local_block_at(const std::array< index_type, NumDimensions > &g_coords) const
Unit and local block index at given global coordinates.
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:181
ShiftTilePattern(SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given global linear offset (index) to global cartesian coordinates.
local_index_t local(IndexType g_index) const
Converts global index to its associated unit and respective local index.
static constexpr dim_t ndim()
Number of dimensions of the cartesian space partitioned by the pattern.
ViewSpec_t local_block_local(index_type local_block_index) const
View spec (offset and extents) of block at local linear block index in local cartesian element space...
team_unit_t unit_at(IndexType global_pos) const
Convert given global linear index to its assigned unit id.
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395
SizeSpec_t sizespec() const
Size specification of the index space mapped by this pattern.
local_coords_t local(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit and its respective local coordinates.
ShiftTilePattern & operator=(const ShiftTilePattern &other)
Assignment operator.
dash::Team & team() const
The Team containing the units to which this pattern&#39;s elements are mapped.
pattern_layout_properties< pattern_layout_tag::blocked, pattern_layout_tag::linear > layout_properties
Satisfiable properties in pattern property category Layout:
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
local_index_t local_index(const std::array< IndexType, NumDimensions > &global_coords) const
Resolves the unit and the local index from global coordinates.
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
IndexType num_units() const
The number of units to which this pattern&#39;s elements are mapped.
IndexType capacity() const
The maximum number of elements arranged in this pattern.
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:171
DistributionSpec describes distribution patterns of all dimensions,.
Definition: Dimensional.h:222
Generic type of mapping properties of a model satisfying the Pattern concept.
bool is_local(IndexType index) const
Whether the given global index is local to the unit that created this pattern instance.
IndexType lbegin() const
Resolves the global index of the first local element in the pattern.