DASH  0.3.0
SeqTilePattern.h
1 #ifndef DASH__SEQ_TILE_PATTERN_H_
2 #define DASH__SEQ_TILE_PATTERN_H_
3 
4 #include <cassert>
5 #include <functional>
6 #include <cstring>
7 #include <array>
8 #include <type_traits>
9 #include <iostream>
10 #include <sstream>
11 #include <utility>
12 
13 #include <dash/Types.h>
14 #include <dash/Distribution.h>
15 #include <dash/Exception.h>
16 #include <dash/Dimensional.h>
17 #include <dash/Cartesian.h>
18 #include <dash/Team.h>
19 
20 #include <dash/pattern/PatternProperties.h>
21 #include <dash/pattern/internal/PatternArguments.h>
22 
23 #include <dash/internal/Math.h>
24 #include <dash/internal/Logging.h>
25 
26 namespace dash {
27 
44 template<
45  dim_t NumDimensions,
46  MemArrange Arrangement = ROW_MAJOR,
47  typename IndexType = dash::default_index_t>
49 {
50 public:
51  static constexpr char const * PatternName = "SeqTilePattern";
52 
53 public:
56  // Minimal number of blocks in every dimension, i.e. one
57  // block per unit.
59  // Block extents are constant for every dimension.
61  // Identical number of elements in every block.
66  // Same number of blocks assigned to every unit.
68  // Number of blocks assigned to a unit may differ.
70  // Every unit mapped in any single slice in every dimension.
75  // Elements are contiguous in local memory within single
76  // block.
78  // Local element order corresponds to a logical
79  // linearization within single blocks.
82 
83 private:
86  self_t;
88  typedef typename std::make_unsigned<IndexType>::type
89  SizeType;
101  TeamSpec_t;
103  SizeSpec_t;
105  ViewSpec_t;
106  typedef internal::PatternArguments<NumDimensions, IndexType>
107  PatternArguments_t;
108 
109 public:
110  typedef IndexType index_type;
111  typedef SizeType size_type;
112  typedef ViewSpec_t viewspec_type;
113  typedef struct {
114  team_unit_t unit;
115  IndexType index{};
116  } local_index_t;
117  typedef struct {
118  team_unit_t unit;
119  std::array<index_type, NumDimensions> coords;
120  } local_coords_t;
121 
122 private:
126  DistributionSpec_t _distspec;
128  dash::Team * _team = nullptr;
130  team_unit_t _myid;
132  TeamSpec_t _teamspec;
135  MemoryLayout_t _memory_layout;
137  SizeType _nunits = dash::Team::All().size();
139  BlockSizeSpec_t _blocksize_spec;
141  BlockSpec_t _blockspec;
143  BlockSpec_t _local_blockspec;
147  LocalMemoryLayout_t _local_memory_layout;
149  SizeType _local_capacity;
151  IndexType _lbegin;
153  IndexType _lend;
154 
155 public:
190  template<typename ... Args>
195  SizeType arg,
199  Args && ... args)
200  : SeqTilePattern(PatternArguments_t(arg, args...))
201  {
202  DASH_LOG_TRACE("SeqTilePattern()", "Constructor with Argument list");
203  initialize_local_range();
204  }
205 
241  const SizeSpec_t &sizespec,
245  DistributionSpec_t dist,
247  const TeamSpec_t &teamspec,
250  : _distspec(std::move(dist))
251  , _team(&team)
252  , _myid(_team->myid())
253  , _teamspec(teamspec, _distspec, *_team)
254  , _memory_layout(sizespec.extents())
255  , _nunits(_teamspec.size())
256  , _blocksize_spec(
257  initialize_blocksizespec(sizespec, _distspec, _teamspec))
258  , _blockspec(initialize_blockspec(sizespec, _blocksize_spec, _teamspec))
259  , _local_blockspec(initialize_local_blockspec(_blockspec))
260  , _local_memory_layout(initialize_local_extents(_myid))
261  , _local_capacity(initialize_local_capacity(_local_memory_layout))
262  {
263  DASH_LOG_TRACE("SeqTilePattern()", "(sizespec, dist, teamspec, team)");
264  initialize_local_range();
265  }
266 
302  const SizeSpec_t & sizespec,
306  const DistributionSpec_t & dist = DistributionSpec_t(),
308  Team & team = dash::Team::All())
309  : _distspec(dist),
310  _team(&team),
311  _myid(_team->myid()),
312  _teamspec(_distspec, *_team),
313  _memory_layout(sizespec.extents()),
314  _nunits(_teamspec.size()),
315  _blocksize_spec(initialize_blocksizespec(
316  sizespec,
317  _distspec,
318  _teamspec)),
319  _blockspec(initialize_blockspec(
320  sizespec,
321  _blocksize_spec,
322  _teamspec)),
323  _local_blockspec(initialize_local_blockspec(
324  _blockspec)),
325  _local_memory_layout(
326  initialize_local_extents(_myid)),
327  _local_capacity(
328  initialize_local_capacity(_local_memory_layout)) {
329  DASH_LOG_TRACE("SeqTilePattern()", "(sizespec, dist, team)");
330  initialize_local_range();
331  }
332 
336  SeqTilePattern(const self_t & other)
337  : _distspec(other._distspec),
338  _team(other._team),
339  _myid(_team->myid()),
340  _teamspec(other._teamspec),
341  _memory_layout(other._memory_layout),
342  _nunits(other._nunits),
343  _blocksize_spec(other._blocksize_spec),
344  _blockspec(other._blockspec),
345  _local_blockspec(other._local_blockspec),
346  _local_memory_layout(other._local_memory_layout),
347  _local_capacity(other._local_capacity),
348  _lbegin(other._lbegin),
349  _lend(other._lend) {
350  }
351 
358  SeqTilePattern(self_t & other)
359  : SeqTilePattern(static_cast<const self_t &>(other))
360  { }
361 
367  const self_t & other) const
368  {
369  if (this == &other) {
370  return true;
371  }
372  // no need to compare all members as most are derived from
373  // constructor arguments.
374  return(
375  _distspec == other._distspec &&
376  _teamspec == other._teamspec &&
377  _memory_layout == other._memory_layout &&
378  _blockspec == other._blockspec &&
379  _blocksize_spec == other._blocksize_spec &&
380  _nunits == other._nunits
381  );
382  }
383 
389  const self_t & other
390  ) const {
391  return !(*this == other);
392  }
393 
398  if (this != &other) {
399  _distspec = other._distspec;
400  _team = other._team;
401  _teamspec = other._teamspec;
402  _memory_layout = other._memory_layout;
403  _local_memory_layout = other._local_memory_layout;
404  _blocksize_spec = other._blocksize_spec;
405  _blockspec = other._blockspec;
406  _local_blockspec = other._local_blockspec;
407  _local_capacity = other._local_capacity;
408  _nunits = other._nunits;
409  _lbegin = other._lbegin;
410  _lend = other._lend;
411  }
412  return *this;
413  }
414 
420  IndexType lbegin() const {
421  return _lbegin;
422  }
423 
429  IndexType lend() const {
430  return _lend;
431  }
432 
436 
444  const std::array<IndexType, NumDimensions> & coords,
446  const ViewSpec_t & viewspec) const
447  {
448  DASH_LOG_TRACE("SeqTilePattern.unit_at()",
449  "coords:", coords,
450  "viewspec:", viewspec);
451  std::array<IndexType, NumDimensions> block_coords;
452  for (auto d = 0; d < NumDimensions; ++d) {
453  auto vs_coord = coords[d] + viewspec.offset(d);
454  // Global block coordinate:
455  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
456  }
457  auto block_idx = _blockspec.at(block_coords);
458 
459  team_unit_t unit_id(block_idx % _nunits);
460  DASH_LOG_TRACE_VAR("SeqTilePattern.unit_at", block_coords);
461  DASH_LOG_TRACE_VAR("SeqTilePattern.unit_at", block_idx);
462  DASH_LOG_TRACE_VAR("SeqTilePattern.unit_at >", unit_id);
463  return unit_id;
464  }
465 
472  const std::array<IndexType, NumDimensions> & coords) const
473  {
474  DASH_LOG_TRACE("SeqTilePattern.unit_at()",
475  "coords:", coords);
476  std::array<IndexType, NumDimensions> block_coords{};
477  // Unit id from diagonals in cartesian index space,
478  // e.g (x + y + z) % nunits
479  for (auto d = 0; d < NumDimensions; ++d) {
480  // Global block coordinate:
481  block_coords[d] = coords[d] / _blocksize_spec.extent(d);
482  }
483  auto block_idx = _blockspec.at(block_coords);
484  team_unit_t unit_id(block_idx % _nunits);
485  DASH_LOG_TRACE_VAR("SeqTilePattern.unit_at", block_coords);
486  DASH_LOG_TRACE_VAR("SeqTilePattern.unit_at", block_idx);
487  DASH_LOG_TRACE_VAR("SeqTilePattern.unit_at >", unit_id);
488  return unit_id;
489  }
490 
498  IndexType global_pos,
500  const ViewSpec_t & viewspec) const
501  {
502  auto global_coords = _memory_layout.coords(global_pos);
503  return unit_at(global_coords, viewspec);
504  }
505 
513  IndexType global_pos) const
514  {
515  auto global_coords = _memory_layout.coords(global_pos);
516  return unit_at(global_coords);
517  }
518 
522 
532  SizeType extent(dim_t dim) const {
533  if (dim >= NumDimensions || dim < 0) {
534  DASH_THROW(
536  "Wrong dimension for SeqTilePattern::local_extent. "
537  << "Expected dimension between 0 and " << NumDimensions-1 << ", "
538  << "got " << dim);
539  }
540  return _memory_layout.extent(dim);
541  }
542 
554  SizeType local_extent(dim_t dim) const
555  {
556  if (dim >= NumDimensions || dim < 0) {
557  DASH_THROW(
559  "Wrong dimension for SeqTilePattern::local_extent. "
560  << "Expected dimension between 0 and " << NumDimensions-1 << ", "
561  << "got " << dim);
562  }
563  return _local_memory_layout.extent(dim);
564  }
565 
577  std::array<SizeType, NumDimensions> local_extents(
578  team_unit_t unit = UNDEFINED_TEAM_UNIT_ID) const
579  {
580  if (unit == UNDEFINED_TEAM_UNIT_ID) {
581  unit = _myid;
582  }
583  if (unit == _myid) {
584  return _local_memory_layout.extents();
585  }
586  return initialize_local_extents(unit);
587  }
588 
592 
599  IndexType local_at(
601  const std::array<IndexType, NumDimensions> & local_coords,
603  const ViewSpec_t & viewspec) const
604  {
605  DASH_LOG_TRACE("SeqTilePattern.local_at()",
606  "local_coords:", local_coords,
607  "view:", viewspec,
608  "local blocks:", _local_blockspec.extents());
609  // Phase coordinates of element:
610  std::array<IndexType, NumDimensions> phase_coords{};
611  // Coordinates of the local block containing the element:
612  std::array<IndexType, NumDimensions> block_coords_l{};
613  for (auto d = 0; d < NumDimensions; ++d) {
614  auto vs_offset_d = viewspec.offset(d);
615  auto vs_coord_d = local_coords[d] + vs_offset_d;
616  auto block_size_d = _blocksize_spec.extent(d);
617  phase_coords[d] = vs_coord_d % block_size_d;
618  block_coords_l[d] = vs_coord_d / block_size_d;
619  }
620  DASH_LOG_TRACE("SeqTilePattern.local_at",
621  "local_coords:", local_coords,
622  "view:", viewspec,
623  "local blocks:", _local_blockspec.extents(),
624  "local block coords:", block_coords_l,
625  "phase coords:", phase_coords);
626  // Number of blocks preceeding the coordinates' block:
627  auto block_offset_l = _local_blockspec.at(block_coords_l);
628  auto local_index =
629  block_offset_l * _blocksize_spec.size() + // preceeding blocks
630  _blocksize_spec.at(phase_coords); // element phase
631  DASH_LOG_TRACE_VAR("SeqTilePattern.local_at >", local_index);
632  return local_index;
633  }
634 
640  IndexType local_at(
642  const std::array<IndexType, NumDimensions> & local_coords) const
643  {
644  DASH_LOG_TRACE("SeqTilePattern.local_at()",
645  "local coords:", local_coords,
646  "local blocks:", _local_blockspec.extents());
647  // Phase coordinates of element:
648  std::array<IndexType, NumDimensions> phase_coords;
649  // Coordinates of the local block containing the element:
650  std::array<IndexType, NumDimensions> block_coords_l;
651  for (auto d = 0; d < NumDimensions; ++d) {
652  auto gcoord_d = local_coords[d];
653  auto block_size_d = _blocksize_spec.extent(d);
654  phase_coords[d] = gcoord_d % block_size_d;
655  block_coords_l[d] = gcoord_d / block_size_d;
656  }
657  DASH_LOG_TRACE("SeqTilePattern.local_at",
658  "local_coords:", local_coords,
659  "local blocks:", _local_blockspec.extents(),
660  "local block coords:", block_coords_l,
661  "block size:", _blocksize_spec.extents(),
662  "phase coords:", phase_coords);
663  // Number of blocks preceeding the coordinates' block:
664  auto block_offset_l = _local_blockspec.at(block_coords_l);
665  auto local_index =
666  block_offset_l * _blocksize_spec.size() + // preceeding blocks
667  _blocksize_spec.at(phase_coords); // element phase
668  DASH_LOG_TRACE_VAR("SeqTilePattern.local_at >", local_index);
669  return local_index;
670  }
671 
679  const std::array<IndexType, NumDimensions> & global_coords) const
680  {
681  local_coords_t l_coords;
682  std::array<IndexType, NumDimensions> local_coords;
683  std::array<IndexType, NumDimensions> g_block_coords;
684  std::array<IndexType, NumDimensions> phase;
685  for (dim_t d = 0; d < NumDimensions; ++d) {
686  auto blocksize_d = _blocksize_spec.extent(d);
687  g_block_coords[d] = global_coords[d] / blocksize_d;
688  phase[d] = global_coords[d] % blocksize_d;
689  }
690  auto g_block_index = _blockspec.at(g_block_coords);
691  l_coords.unit = g_block_index % _nunits;
692  auto l_block_index = g_block_index / _nunits;
693  local_coords[0] = l_block_index * _blocksize_spec.extent(0) +
694  phase[0];
695  for (dim_t d = 1; d < NumDimensions; ++d) {
696  local_coords[d] = phase[d];
697  }
698  l_coords.coords = local_coords;
699  return l_coords;
700  }
701 
711  IndexType g_index) const
712  {
713  DASH_LOG_TRACE_VAR("SeqTilePattern.local()", g_index);
714  // TODO: Implement dedicated method for this, conversion to/from
715  // global coordinates is expensive.
716  return local_index(coords(g_index));
717  }
718 
725  std::array<IndexType, NumDimensions> local_coords(
726  const std::array<IndexType, NumDimensions> & global_coords) const
727  {
728  std::array<IndexType, NumDimensions> local_coords{};
729  for (dim_t d = 0; d < NumDimensions; ++d) {
730  auto nunits_d = _teamspec.extent(d);
731  auto blocksize_d = _blocksize_spec.extent(d);
732  auto block_coord_d = global_coords[d] / blocksize_d;
733  auto phase_d = global_coords[d] % blocksize_d;
734  auto l_block_coord_d = block_coord_d / nunits_d;
735  local_coords[d] = (l_block_coord_d * blocksize_d) + phase_d;
736  }
737  return local_coords;
738  }
739 
746  const std::array<IndexType, NumDimensions> & global_coords) const
747  {
748  DASH_LOG_TRACE_VAR("SeqTilePattern.local_index()", global_coords);
749  // Global coordinates to unit and local offset:
750  // Phase coordinates of element:
751  std::array<IndexType, NumDimensions> phase_coords{};
752  // Coordinates of the block containing the element:
753  std::array<IndexType, NumDimensions> block_coords{};
754  // Local coordinates of the block containing the element:
755  std::array<IndexType, NumDimensions> l_block_coords{};
756  for (auto d = 0; d < NumDimensions; ++d) {
757  auto vs_coord = global_coords[d];
758  phase_coords[d] = vs_coord % _blocksize_spec.extent(d);
759  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
760  }
761  index_type g_block_index = _blockspec.at(block_coords);
762  team_unit_t unit(g_block_index % _nunits);
763  auto l_block_index = g_block_index / _nunits;
764  DASH_LOG_TRACE("SeqTilePattern.at",
765  "block_coords:", block_coords,
766  "g_block_index:", g_block_index,
767  "phase_coords:", phase_coords,
768  "l_block_index:", l_block_index,
769  "unit:", unit);
770  index_type l_index = l_block_index * _blocksize_spec.size() + // prec. blocks
771  _blocksize_spec.at(phase_coords); // elem. phase
772  DASH_LOG_TRACE_VAR("SeqTilePattern.local_index >", l_index);
773 
774  return local_index_t { unit, l_index };
775  }
776 
780 
786  std::array<IndexType, NumDimensions> global(
787  team_unit_t unit,
788  const std::array<IndexType, NumDimensions> & local_coords) const
789  {
790  // Blocks in local memory are arranged in a one-dimensional sequence.
791  // Local blockspec has extents { n_local_blocks, 1, 1, ... }.
792  DASH_LOG_DEBUG("SeqTilePattern.global()",
793  "unit:", unit,
794  "lcoords:", local_coords);
795  auto l_block_index = local_coords[0] / _blocksize_spec.extent(0);
796  auto g_block_index = l_block_index * _nunits + unit;
797  auto g_block_coords = _blockspec.coords(g_block_index);
798  DASH_LOG_DEBUG("SeqTilePattern.global()",
799  "l_block_index:", l_block_index,
800  "g_block_index:", g_block_index,
801  "g_block_coords:", g_block_coords);
802  // Global coordinate of local element:
803  std::array<IndexType, NumDimensions> global_coords{};
804  for (dim_t d = 0; d < NumDimensions; ++d) {
805  auto blocksize_d = _blocksize_spec.extent(d);
806  auto phase = local_coords[d] % blocksize_d;
807  auto g_block_coord_d = g_block_coords[d];
808  global_coords[d] = (g_block_coord_d * blocksize_d) + phase;
809  }
810  DASH_LOG_DEBUG_VAR("SeqTilePattern.global >", global_coords);
811  return global_coords;
812  }
813 
819  std::array<IndexType, NumDimensions> global(
820  const std::array<IndexType, NumDimensions> & local_coords) const {
821  return global(_myid, local_coords);
822  }
823 
834  IndexType global(
835  IndexType local_index) const
836  {
837  DASH_LOG_TRACE("SeqTilePattern.global()",
838  "local_index:", local_index,
839  "unit:", _myid);
840  auto block_size = _blocksize_spec.size();
841  auto phase = local_index % block_size;
842  auto l_block_index = local_index / block_size;
843  // Block coordinate in local memory:
844  auto l_block_coord = _local_blockspec.coords(l_block_index);
845  // Coordinate of element in block:
846  auto phase_coord = _blocksize_spec.coords(phase);
847  DASH_LOG_TRACE("SeqTilePattern.global",
848  "local block index:", l_block_index,
849  "local block coords:", l_block_coord,
850  "phase coords:", phase_coord);
851  // Coordinate of element in local memory:
852  std::array<IndexType, NumDimensions> l_coords{};
853  for (auto d = 0; d < NumDimensions; ++d) {
854  l_coords[d] = l_block_coord[d] * _blocksize_spec.extent(d) +
855  phase_coord[d];
856  }
857  std::array<IndexType, NumDimensions> g_coords =
858  global(_myid, l_coords);
859  auto offset = _memory_layout.at(g_coords);
860  DASH_LOG_TRACE_VAR("SeqTilePattern.global >", offset);
861  return offset;
862  }
863 
873  IndexType global_index(
874  team_unit_t unit,
875  const std::array<IndexType, NumDimensions> & local_coords) const
876  {
877  DASH_LOG_TRACE("SeqTilePattern.global_index()",
878  "unit:", unit,
879  "local_coords:", local_coords);
880  std::array<IndexType, NumDimensions> global_coords =
881  global(unit, local_coords);
882  auto g_index = _memory_layout.at(global_coords);
883  DASH_LOG_TRACE_VAR("SeqTilePattern.global_index >", g_index);
884  return g_index;
885  }
886 
900  IndexType global_at(
901  const std::array<IndexType, NumDimensions> & global_coords,
902  const ViewSpec_t & viewspec) const
903  {
904  DASH_LOG_TRACE("SeqTilePattern.global_at()",
905  "gcoords:", global_coords,
906  "viewspec:", viewspec);
907  // Phase coordinates of element:
908  std::array<IndexType, NumDimensions> phase_coords{};
909  // Coordinates of the block containing the element:
910  std::array<IndexType, NumDimensions> block_coords{};
911  for (auto d = 0; d < NumDimensions; ++d) {
912  auto vs_coord = global_coords[d] + viewspec.offset(d);
913  phase_coords[d] = vs_coord % _blocksize_spec.extent(d);
914  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
915  }
916  DASH_LOG_TRACE("SeqTilePattern.global_at",
917  "block coords:", block_coords,
918  "phase coords:", phase_coords);
919  // Number of blocks preceeding the coordinates' block, equivalent
920  // to linear global block offset:
921  auto block_index = _blockspec.at(block_coords);
922  DASH_LOG_TRACE("SeqTilePattern.global_at",
923  "block index:", block_index);
924  auto offset = block_index * _blocksize_spec.size() + // preceed. blocks
925  _blocksize_spec.at(phase_coords); // element phase
926  DASH_LOG_TRACE_VAR("SeqTilePattern.global_at >", offset);
927  return offset;
928  }
929 
943  IndexType global_at(
944  const std::array<IndexType, NumDimensions> & global_coords) const
945  {
946  DASH_LOG_TRACE("SeqTilePattern.global_at()",
947  "gcoords:", global_coords);
948  // Phase coordinates of element:
949  std::array<IndexType, NumDimensions> phase_coords;
950  // Coordinates of the block containing the element:
951  std::array<IndexType, NumDimensions> block_coords;
952  for (auto d = 0; d < NumDimensions; ++d) {
953  auto vs_coord = global_coords[d];
954  phase_coords[d] = vs_coord % _blocksize_spec.extent(d);
955  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
956  }
957  DASH_LOG_TRACE("SeqTilePattern.global_at",
958  "block coords:", block_coords,
959  "phase coords:", phase_coords);
960  // Number of blocks preceeding the coordinates' block, equivalent
961  // to linear global block offset:
962  auto block_index = _blockspec.at(block_coords);
963  DASH_LOG_TRACE("SeqTilePattern.global_at",
964  "block index:", block_index);
965  auto offset = block_index * _blocksize_spec.size() + // preceed. blocks
966  _blocksize_spec.at(phase_coords); // element phase
967  DASH_LOG_TRACE_VAR("SeqTilePattern.global_at >", offset);
968  return offset;
969  }
970 
974 
982  IndexType at(
983  const std::array<IndexType, NumDimensions> & global_coords,
984  const ViewSpec_t & viewspec) const
985  {
986  DASH_LOG_TRACE("SeqTilePattern.at()",
987  "gcoords:", global_coords,
988  "viewspec:", viewspec);
989  // Phase coordinates of element:
990  std::array<IndexType, NumDimensions> phase_coords;
991  // Coordinates of the block containing the element:
992  std::array<IndexType, NumDimensions> block_coords;
993  // Local coordinates of the block containing the element:
994  std::array<IndexType, NumDimensions> l_block_coords;
995  for (auto d = 0; d < NumDimensions; ++d) {
996  auto vs_coord = global_coords[d] + viewspec.offset(d);
997  phase_coords[d] = vs_coord % _blocksize_spec.extent(d);
998  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
999  }
1000  index_type g_block_index = _blockspec.at(block_coords);
1001  auto l_block_index = g_block_index / _nunits;
1002  DASH_LOG_TRACE("SeqTilePattern.at",
1003  "block_coords:", block_coords,
1004  "g_block_index:", g_block_index,
1005  "phase_coords:", phase_coords,
1006  "l_block_index:", l_block_index);
1007  auto offset = l_block_index * _blocksize_spec.size() + // prec. blocks
1008  _blocksize_spec.at(phase_coords); // elem. phase
1009  DASH_LOG_TRACE_VAR("SeqTilePattern.at >", offset);
1010  return offset;
1011  }
1012 
1021  IndexType at(
1022  std::array<IndexType, NumDimensions> global_coords) const
1023  {
1024  DASH_LOG_TRACE("SeqTilePattern.at()",
1025  "gcoords:", global_coords);
1026  // Phase coordinates of element:
1027  std::array<IndexType, NumDimensions> phase_coords{};
1028  // Coordinates of the block containing the element:
1029  std::array<IndexType, NumDimensions> block_coords{};
1030  // Local coordinates of the block containing the element:
1031  std::array<IndexType, NumDimensions> l_block_coords{};
1032  for (auto d = 0; d < NumDimensions; ++d) {
1033  auto vs_coord = global_coords[d];
1034  phase_coords[d] = vs_coord % _blocksize_spec.extent(d);
1035  block_coords[d] = vs_coord / _blocksize_spec.extent(d);
1036  }
1037  index_type g_block_index = _blockspec.at(block_coords);
1038  auto l_block_index = g_block_index / _nunits;
1039  DASH_LOG_TRACE("SeqTilePattern.at",
1040  "block_coords:", block_coords,
1041  "g_block_index:", g_block_index,
1042  "phase_coords:", phase_coords,
1043  "l_block_index:", l_block_index);
1044  auto offset = l_block_index * _blocksize_spec.size() + // prec. blocks
1045  _blocksize_spec.at(phase_coords); // elem. phase
1046  DASH_LOG_TRACE_VAR("SeqTilePattern.at >", offset);
1047  return offset;
1048  }
1049 
1057  template<typename ... Values>
1058  IndexType at(Values ... values) const
1059  {
1060  static_assert(
1061  sizeof...(values) == NumDimensions,
1062  "Wrong parameter number");
1063  std::array<IndexType, NumDimensions> inputindex = {
1064  (IndexType)values...
1065  };
1066  return at(inputindex);
1067  }
1068 
1072 
1081  dim_t dim,
1083  IndexType dim_offset,
1085  team_unit_t unit,
1087  const ViewSpec_t & viewspec) const
1088  {
1089  DASH_LOG_TRACE_VAR("SeqTilePattern.has_local_elements()", dim);
1090  DASH_LOG_TRACE_VAR("SeqTilePattern.has_local_elements()", dim_offset);
1091  DASH_LOG_TRACE_VAR("SeqTilePattern.has_local_elements()", unit);
1092  DASH_LOG_TRACE_VAR("SeqTilePattern.has_local_elements()", viewspec);
1093  // Apply viewspec offset in dimension to given position
1094  dim_offset += viewspec.offset(dim);
1095  // Offset to block offset
1096  IndexType block_coord_d = dim_offset / _blocksize_spec.extent(dim);
1097  DASH_LOG_TRACE_VAR("SeqTilePattern.has_local_elements", block_coord_d);
1098  // Coordinate of unit in team spec in given dimension
1099  IndexType teamspec_coord_d = block_coord_d % _teamspec.extent(dim);
1100  DASH_LOG_TRACE_VAR("SeqTilePattern.has_local_elements",
1101  teamspec_coord_d);
1102  // Check if unit id lies in cartesian sub-space of team spec
1103  return _teamspec.includes_index(
1104  teamspec_coord_d,
1105  dim,
1106  dim_offset);
1107  }
1108 
1114  bool is_local(
1115  IndexType index,
1116  team_unit_t unit) const
1117  {
1118  auto glob_coords = coords(index);
1119  auto coords_unit = unit_at(glob_coords);
1120  DASH_LOG_TRACE_VAR("SeqTilePattern.is_local >", (coords_unit == unit));
1121  return coords_unit == unit;
1122  }
1123 
1130  bool is_local(
1131  IndexType index) const
1132  {
1133  return is_local(index, _myid);
1134  }
1135 
1139 
1145  index_type block_at(
1147  const std::array<index_type, NumDimensions> & g_coords) const
1148  {
1149  std::array<index_type, NumDimensions> block_coords;
1150  // Coord to block coord to unit coord:
1151  for (auto d = 0; d < NumDimensions; ++d) {
1152  block_coords[d] = g_coords[d] / _blocksize_spec.extent(d);
1153  }
1154  // Block coord to block index:
1155  auto block_idx = _blockspec.at(block_coords);
1156  DASH_LOG_TRACE("SeqTilePattern.block_at",
1157  "coords", g_coords,
1158  "> block index", block_idx);
1159  return block_idx;
1160  }
1161 
1168  ViewSpec_t block(
1169  index_type global_block_index) const
1170  {
1171  DASH_LOG_TRACE_VAR("SeqTilePattern.block()", global_block_index);
1172  // block index -> block coords -> offset
1173  auto g_block_coords = _blockspec.coords(global_block_index);
1174  DASH_LOG_TRACE_VAR("SeqTilePattern.block", g_block_coords);
1175  DASH_LOG_TRACE_VAR("SeqTilePattern.block", _blocksize_spec.extents());
1176  std::array<index_type, NumDimensions> offsets{};
1177  std::array<size_type, NumDimensions> extents{};
1178  for (auto d = 0; d < NumDimensions; ++d) {
1179  auto blocksize_d = _blocksize_spec.extent(d);
1180  extents[d] = blocksize_d;
1181  offsets[d] = g_block_coords[d] * blocksize_d;
1182  }
1183  DASH_LOG_TRACE("SeqTilePattern.block",
1184  "offsets:", offsets,
1185  "extents:", extents);
1186  auto block_vs = ViewSpec_t(offsets, extents);
1187  DASH_LOG_TRACE_VAR("SeqTilePattern.block >", block_vs);
1188  return block_vs;
1189  }
1190 
1197  ViewSpec_t local_block(
1198  index_type local_block_index) const
1199  {
1200  return local_block(_myid, local_block_index);
1201  }
1202 
1209  ViewSpec_t local_block(
1210  team_unit_t unit,
1211  index_type local_block_index) const
1212  {
1213  DASH_LOG_TRACE("SeqTilePattern.local_block()",
1214  "unit:", unit,
1215  "lblock_idx:", local_block_index);
1216  auto g_block_index = local_block_index * _nunits + unit;
1217  auto g_block_coords = _blockspec.coords(g_block_index);
1218 
1219  DASH_LOG_TRACE_VAR("SeqTilePattern.local_block", g_block_coords);
1220  std::array<index_type, NumDimensions> offsets{};
1221  std::array<size_type, NumDimensions> extents{};
1222  for (auto d = 0; d < NumDimensions; ++d) {
1223  auto blocksize_d = _blocksize_spec.extent(d);
1224  offsets[d] = g_block_coords[d] * blocksize_d;
1225  extents[d] = blocksize_d;
1226  }
1227  ViewSpec_t block_vs(offsets, extents);
1228  DASH_LOG_TRACE_VAR("SeqTilePattern.local_block >", block_vs);
1229  return block_vs;
1230  }
1231 
1238  ViewSpec_t local_block_local(
1239  index_type local_block_index) const
1240  {
1241  DASH_LOG_TRACE_VAR("SeqTilePattern.local_block_local()",
1242  local_block_index);
1243  // Initialize viewspec result with block extents:
1244  std::array<index_type, NumDimensions> offsets{};
1245  std::array<size_type, NumDimensions> extents =
1246  _blocksize_spec.extents();
1247  // Local block index to local block coords:
1248  auto l_block_coords = _local_blockspec.coords(local_block_index);
1249  // Local block coords to local element offset:
1250  for (auto d = 0; d < NumDimensions; ++d) {
1251  offsets[d] = l_block_coords[d] * extents[d];
1252  }
1253  ViewSpec_t block_vs(offsets, extents);
1254  DASH_LOG_TRACE_VAR("SeqTilePattern.local_block_local >", block_vs);
1255  return block_vs;
1256  }
1257 
1261  const BlockSpec_t & blockspec() const
1262  {
1263  return _blockspec;
1264  }
1265 
1269  const BlockSpec_t & local_blockspec() const
1270  {
1271  return _local_blockspec;
1272  }
1273 
1277  BlockSpec_t local_blockspec(team_unit_t unit) const
1278  {
1279  if (unit == _myid) {
1280  return local_blockspec();
1281  }
1282  return initialize_local_blockspec( _blockspec, unit);
1283  }
1284 
1292  SizeType blocksize(
1294  dim_t dimension) const
1295  {
1296  return _blocksize_spec.extent(dimension);
1297  }
1298 
1307  SizeType max_blocksize() const {
1308  return _blocksize_spec.size();
1309  }
1310 
1317  SizeType local_capacity() const {
1318  return local_size();
1319  }
1320 
1332  if (unit == DART_UNDEFINED_UNIT_ID) {
1333  return _local_memory_layout.size();
1334  }
1335  // Non-local query, requires to construct local memory layout of
1336  // remote unit:
1337  return LocalMemoryLayout_t(initialize_local_extents(unit)).size();
1338  }
1339 
1345  IndexType num_units() const {
1346  return _teamspec.size();
1347  }
1348 
1354  IndexType capacity() const {
1355  return _memory_layout.size();
1356  }
1357 
1363  IndexType size() const {
1364  return _memory_layout.size();
1365  }
1366 
1371  dash::Team & team() const {
1372  return *_team;
1373  }
1374 
1378  const DistributionSpec_t & distspec() const {
1379  return _distspec;
1380  }
1381 
1387  SizeSpec_t sizespec() const {
1388  return SizeSpec_t(_memory_layout.extents());
1389  }
1390 
1396  const std::array<SizeType, NumDimensions> & extents() const {
1397  return _memory_layout.extents();
1398  }
1399 
1406  const TeamSpec_t & teamspec() const {
1407  return _teamspec;
1408  }
1409 
1416  std::array<IndexType, NumDimensions> coords(
1417  IndexType index) const {
1418  return _memory_layout.coords(index);
1419  }
1420 
1427  std::array<IndexType, NumDimensions> coords(
1428  IndexType index,
1429  const ViewSpec_t & viewspec) const {
1430  return _memory_layout.coords(index, viewspec);
1431  }
1432 
1436  constexpr static MemArrange memory_order() {
1437  return Arrangement;
1438  }
1439 
1444  constexpr static dim_t ndim() {
1445  return NumDimensions;
1446  }
1447 
1448 private:
1449 
1450  SeqTilePattern(const PatternArguments_t & arguments)
1451  : _distspec(arguments.distspec()),
1452  _team(&arguments.team()),
1453  _myid(_team->myid()),
1454  _teamspec(arguments.teamspec()),
1455  _memory_layout(arguments.sizespec().extents()),
1456  _nunits(_teamspec.size()),
1457  _blocksize_spec(initialize_blocksizespec(
1458  arguments.sizespec(),
1459  _distspec,
1460  _teamspec)),
1461  _blockspec(initialize_blockspec(
1462  arguments.sizespec(),
1463  _blocksize_spec,
1464  _teamspec)),
1465  _local_blockspec(initialize_local_blockspec(
1466  _blockspec)),
1467  _local_memory_layout(
1468  initialize_local_extents(_myid)),
1469  _local_capacity(
1470  initialize_local_capacity(_local_memory_layout))
1471  {}
1472 
1477  BlockSizeSpec_t initialize_blocksizespec(
1478  const SizeSpec_t & sizespec,
1479  const DistributionSpec_t & distspec,
1480  const TeamSpec_t & teamspec) const {
1481  DASH_LOG_TRACE("SeqTilePattern.init_blocksizespec()");
1482  // Extents of a single block:
1483  std::array<SizeType, NumDimensions> s_blocks{};
1484  for (auto d = 0; d < NumDimensions; ++d) {
1485  const Distribution & dist = distspec[d];
1486  DASH_LOG_TRACE("SeqTilePattern.init_blocksizespec d",
1487  "sizespec extent[d]:", sizespec.extent(d),
1488  "teamspec extent[d]:", teamspec.extent(d));
1489  SizeType max_blocksize_d = dist.max_blocksize_in_range(
1490  sizespec.extent(d), // size of range (extent)
1491  teamspec.extent(d)); // number of blocks (units)
1492  s_blocks[d] = max_blocksize_d;
1493  }
1494  DASH_LOG_TRACE_VAR("SeqTilePattern.init_blocksizespec >", s_blocks);
1495  return BlockSizeSpec_t(s_blocks);
1496  }
1497 
1502  BlockSpec_t initialize_blockspec(
1503  const SizeSpec_t & sizespec,
1504  const BlockSizeSpec_t & blocksizespec,
1505  const TeamSpec_t & teamspec) const
1506  {
1507  DASH_LOG_TRACE("SeqTilePattern.init_blockspec()",
1508  "pattern size:", sizespec.extents(),
1509  "block size:", blocksizespec.extents(),
1510  "team size:", teamspec.extents());
1511  // Number of blocks in all dimensions:
1512  std::array<SizeType, NumDimensions> n_blocks{};
1513  for (auto d = 0; d < NumDimensions; ++d) {
1514  SizeType max_blocksize_d = blocksizespec.extent(d);
1515  SizeType max_blocks_d = dash::math::div_ceil(
1516  sizespec.extent(d),
1517  max_blocksize_d);
1518  n_blocks[d] = max_blocks_d;
1519  }
1520  BlockSpec_t blockspec(n_blocks);
1521  DASH_LOG_TRACE_VAR("SeqTilePattern.init_blockspec >", n_blocks);
1522  return blockspec;
1523  }
1524 
1532  BlockSpec_t initialize_local_blockspec(
1533  const BlockSpec_t & blockspec,
1534  team_unit_t unit_id = UNDEFINED_TEAM_UNIT_ID) const
1535  {
1536  DASH_LOG_TRACE_VAR("SeqTilePattern.init_local_blockspec()",
1537  blockspec.extents());
1538  if (unit_id == UNDEFINED_TEAM_UNIT_ID) {
1539  unit_id = _myid;
1540  }
1541  // Number of blocks in total:
1542  auto num_blocks_total = blockspec.size();
1543  // Number of local blocks in all dimensions:
1544  std::array<SizeType, NumDimensions> l_blocks{};
1545  auto min_local_blocks = num_blocks_total / _nunits;
1546  l_blocks[0] = min_local_blocks;
1547  if (unit_id < num_blocks_total % _nunits) {
1548  l_blocks[0]++;
1549  }
1550  for (auto d = 1; d < NumDimensions; ++d) {
1551  l_blocks[d] = 1;
1552  }
1553  DASH_LOG_TRACE_VAR("SeqTilePattern.init_local_blockspec >", l_blocks);
1554  return BlockSpec_t(l_blocks);
1555  }
1556 
1564  SizeType initialize_local_capacity(
1565  const LocalMemoryLayout_t & local_extents) const
1566  {
1567  auto l_capacity = local_extents.size();
1568  DASH_LOG_TRACE_VAR("SeqTilePattern.init_local_capacity >", l_capacity);
1569  return l_capacity;
1570  }
1571 
1575  void initialize_local_range()
1576  {
1577  auto local_size = _local_memory_layout.size();
1578  DASH_LOG_DEBUG_VAR("SeqTilePattern.init_local_range()", local_size);
1579  if (local_size == 0) {
1580  _lbegin = 0;
1581  _lend = 0;
1582  } else {
1583  // First local index transformed to global index
1584  _lbegin = global(0);
1585  // Index past last local index transformed to global index
1586  _lend = global(local_size - 1) + 1;
1587  }
1588  DASH_LOG_DEBUG_VAR("SeqTilePattern.init_local_range >",
1589  _local_memory_layout.extents());
1590  DASH_LOG_DEBUG_VAR("SeqTilePattern.init_local_range >", _lbegin);
1591  DASH_LOG_DEBUG_VAR("SeqTilePattern.init_local_range >", _lend);
1592  }
1593 
1597  std::array<SizeType, NumDimensions> initialize_local_extents(
1598  team_unit_t unit) const
1599  {
1600  DASH_LOG_DEBUG_VAR("SeqTilePattern.init_local_extents()", unit);
1601  auto l_blockspec = initialize_local_blockspec(
1602  _blockspec, unit);
1603 
1604  DASH_LOG_DEBUG_VAR("SeqTilePattern.init_local_extents()",
1605  l_blockspec.extents());
1606  ::std::array<SizeType, NumDimensions> l_extents{};
1607  for (auto d = 0; d < NumDimensions; ++d) {
1608  l_extents[d] = _blocksize_spec.extent(d) * l_blockspec.extent(d);
1609  }
1610  DASH_LOG_DEBUG_VAR("SeqTilePattern.init_local_extents >", l_extents);
1611  return l_extents;
1612  }
1613 };
1614 
1615 template<
1616  dim_t ND,
1617  MemArrange Ar,
1618  typename Index>
1619 std::ostream & operator<<(
1620  std::ostream & os,
1621  const SeqTilePattern<ND,Ar,Index> & pattern)
1622 {
1623  typedef Index index_t;
1624 
1625  dim_t ndim = pattern.ndim();
1626 
1627  std::string storage_order = pattern.memory_order() == ROW_MAJOR
1628  ? "ROW_MAJOR"
1629  : "COL_MAJOR";
1630 
1631  std::array<index_t, 2> blocksize;
1632  blocksize[0] = pattern.blocksize(0);
1633  blocksize[1] = pattern.blocksize(1);
1634 
1635  std::ostringstream ss;
1636  ss << "dash::"
1638  << "<"
1639  << ndim << ","
1640  << storage_order << ","
1641  << typeid(index_t).name()
1642  << ">"
1643  << "("
1644  << "SizeSpec:" << pattern.sizespec().extents() << ", "
1645  << "TeamSpec:" << pattern.teamspec().extents() << ", "
1646  << "BlockSpec:" << pattern.blockspec().extents() << ", "
1647  << "BlockSize:" << blocksize
1648  << ")";
1649 
1650  return operator<<(os, ss.str());
1651 }
1652 
1653 } // namespace dash
1654 
1655 // #include <dash/pattern/SeqTilePattern1D.h>
1656 
1657 #endif // DASH__SEQ_TILE_PATTERN_H_
constexpr team_unit_t UNDEFINED_TEAM_UNIT_ID
Invalid local unit ID.
Definition: Types.h:341
All blocks have identical size.
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
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.
IndexType capacity() const
The maximum number of elements arranged in this pattern.
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
IndexType size() const
The number of elements arranged in this pattern.
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...
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...
pattern_mapping_properties< pattern_mapping_tag::balanced, pattern_mapping_tag::unbalanced, pattern_mapping_tag::diagonal > mapping_properties
Satisfiable properties in pattern property category Mapping:
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...
Specifies cartesian extents in a specific number of dimensions.
Definition: Cartesian.h:197
Specifies view parameters for implementing submat, rows and cols.
Definition: Dimensional.h:430
SizeType blocksize(dim_t dimension) const
Maximum number of elements in a single block in the given dimension.
bool operator!=(const self_t &other) const
Inquality comparison operator.
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
IndexType lend() const
Resolves the global index past the last local element in the pattern.
bool operator==(const self_t &other) const
Equality comparison operator.
ViewSpec_t local_block(team_unit_t unit, index_type local_block_index) const
View spec (offset and extents) of block at local linear block index in global cartesian element space...
bool has_local_elements(dim_t dim, IndexType dim_offset, team_unit_t unit, const ViewSpec_t &viewspec) const
is_local
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...
SizeSpec_t sizespec() const
Size specification of the index space mapped by this pattern.
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(IndexType global_pos) const
Convert given global linear index to its assigned unit id.
The number of blocks assigned to units may differ.
local_coords_t local(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit and its respective local coordinates.
SeqTilePattern(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...
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...
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...
dash::Team & team() const
The Team containing the units to which this pattern&#39;s elements are mapped.
Minimal number of blocks in every dimension, typically at most one block per unit.
Block extents are constant for every dimension.
The number of assigned blocks is identical for every unit.
Units are mapped to blocks in diagonal chains in all hyperplanes.
size_t size() const
The number of units in this team.
Definition: Team.h:498
IndexType num_units() const
The number of units to which this pattern&#39;s elements are mapped.
SeqTilePattern(const SizeSpec_t &sizespec, 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.
pattern_layout_properties< pattern_layout_tag::blocked, pattern_layout_tag::linear > layout_properties
Satisfiable properties in pattern property category Layout:
const std::array< SizeType, NumDimensions > & extents() const
Size specification of the index space mapped by this pattern.
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.
IndexType at(const std::array< IndexType, NumDimensions > &global_coords, const ViewSpec_t &viewspec) const
at
internal::default_signed_index default_index_t
Signed integer type used as default for index values.
Definition: Types.h:59
A Team instance specifies a subset of all available units.
Definition: Team.h:41
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402
const BlockSpec_t & blockspec() const
Cartesian arrangement of pattern blocks.
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
SeqTilePattern(const self_t &other)
Copy constructor.
IndexType local_at(const std::array< IndexType, NumDimensions > &local_coords) const
Convert given local coordinates to linear local offset (index).
Defines a cartesian, totally-ordered index space by mapping linear indices to cartesian coordinates d...
Definition: Cartesian.h:239
Defines how a list of global indices is mapped to single units within a Team.
BlockSpec_t local_blockspec(team_unit_t unit) const
Cartesian arrangement of pattern blocks.
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
const TeamSpec_t & teamspec() const
Cartesian arrangement of the Team containing the units to which this pattern&#39;s elements are mapped...
static constexpr MemArrange memory_order()
Memory order followed by the pattern.
SeqTilePattern(self_t &other)
Copy constructor using non-const lvalue reference parameter.
IndexType at(Values ... values) const
Global coordinates to local index.
std::array< SizeType, NumDimensions > local_extents(team_unit_t unit=UNDEFINED_TEAM_UNIT_ID) const
The actual number of elements in this pattern that are local to the given unit, by dimension...
local_index_t local(IndexType g_index) const
Converts global index to its associated unit and respective local index.
IndexType lbegin() const
Resolves the global index of the first local element in the 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.
pattern_partitioning_properties< pattern_partitioning_tag::minimal, pattern_partitioning_tag::rectangular, pattern_partitioning_tag::balanced > partitioning_properties
Satisfiable properties in pattern property category Partitioning:
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 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
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:181
SeqTilePattern(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.
bool is_local(IndexType index, team_unit_t unit) const
Whether the given global index is local to the specified unit.
team_unit_t unit_at(IndexType global_pos, const ViewSpec_t &viewspec) const
Convert given global linear index to its assigned unit id.
const BlockSpec_t & local_blockspec() const
Cartesian arrangement of pattern blocks.
#define DART_UNDEFINED_UNIT_ID
Undefined unit ID.
Definition: dart_types.h:160
SizeType extent(dim_t dim) const
extent
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395
IndexType at(std::array< IndexType, NumDimensions > global_coords) const
Global coordinates to local index.
const DistributionSpec_t & distspec() const
Distribution specification of this pattern.
static constexpr dim_t ndim()
Number of dimensions of the cartesian space partitioned by the pattern.
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
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords) const
Convert given coordinate in pattern to its assigned unit id.
IndexType local_at(const std::array< IndexType, NumDimensions > &local_coords, const ViewSpec_t &viewspec) const
local
bool is_local(IndexType index) const
Whether the given global index is local to the unit that created this pattern instance.
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 block-wise iteration order...
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...
SizeType local_capacity() const
Maximum number of elements assigned to a single unit in total, equivalent to the local capacity of ev...
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...
index_type block_at(const std::array< index_type, NumDimensions > &g_coords) const
block
std::array< IndexType, NumDimensions > global(const std::array< IndexType, NumDimensions > &local_coords) const
Converts local coordinates of a active unit to global coordinates.
IndexType global_at(const std::array< IndexType, NumDimensions > &global_coords) const
Global coordinates to global position in the pattern&#39;s block-wise iteration order.
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.
SeqTilePattern & operator=(const SeqTilePattern &other)
Assignment operator.