DASH  0.3.0
dash::SeqTilePattern< NumDimensions, Arrangement, IndexType > Class Template Reference

Defines how a list of global indices is mapped to single units within a Team. More...

#include <SeqTilePattern.h>

Classes

struct  local_coords_t
 
struct  local_index_t
 

Public Types

typedef pattern_partitioning_properties< pattern_partitioning_tag::minimal, pattern_partitioning_tag::rectangular, pattern_partitioning_tag::balancedpartitioning_properties
 Satisfiable properties in pattern property category Partitioning: More...
 
typedef pattern_mapping_properties< pattern_mapping_tag::balanced, pattern_mapping_tag::unbalanced, pattern_mapping_tag::diagonalmapping_properties
 Satisfiable properties in pattern property category Mapping: More...
 
typedef pattern_layout_properties< pattern_layout_tag::blocked, pattern_layout_tag::linearlayout_properties
 Satisfiable properties in pattern property category Layout: More...
 
typedef IndexType index_type
 
typedef SizeType size_type
 
typedef ViewSpec_t viewspec_type
 

Public Member Functions

template<typename ... Args>
 SeqTilePattern (SizeType arg, Args &&... args)
 Constructor, initializes a pattern from an argument list consisting of the pattern size (extent, number of elements) in every dimension followed by optional distribution types. More...
 
 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. More...
 
 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. More...
 
 SeqTilePattern (const self_t &other)
 Copy constructor. More...
 
 SeqTilePattern (self_t &other)
 Copy constructor using non-const lvalue reference parameter. More...
 
bool operator== (const self_t &other) const
 Equality comparison operator. More...
 
bool operator!= (const self_t &other) const
 Inquality comparison operator. More...
 
SeqTilePatternoperator= (const SeqTilePattern &other)
 Assignment operator. More...
 
IndexType lbegin () const
 Resolves the global index of the first local element in the pattern. More...
 
IndexType lend () const
 Resolves the global index past the last local element in the pattern. More...
 
team_unit_t unit_at (const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
 unit_at More...
 
team_unit_t unit_at (const std::array< IndexType, NumDimensions > &coords) const
 Convert given coordinate in pattern to its assigned unit id. More...
 
team_unit_t unit_at (IndexType global_pos, const ViewSpec_t &viewspec) const
 Convert given global linear index to its assigned unit id. More...
 
team_unit_t unit_at (IndexType global_pos) const
 Convert given global linear index to its assigned unit id. More...
 
SizeType extent (dim_t dim) const
 extent More...
 
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 dimension. More...
 
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. More...
 
IndexType local_at (const std::array< IndexType, NumDimensions > &local_coords, const ViewSpec_t &viewspec) const
 local More...
 
IndexType local_at (const std::array< IndexType, NumDimensions > &local_coords) const
 Convert given local coordinates to linear local offset (index). More...
 
local_coords_t local (const std::array< IndexType, NumDimensions > &global_coords) const
 Converts global coordinates to their associated unit and its respective local coordinates. More...
 
local_index_t local (IndexType g_index) const
 Converts global index to its associated unit and respective local index. More...
 
std::array< IndexType, NumDimensions > local_coords (const std::array< IndexType, NumDimensions > &global_coords) const
 Converts global coordinates to their associated unit's respective local coordinates. More...
 
local_index_t local_index (const std::array< IndexType, NumDimensions > &global_coords) const
 Resolves the unit and the local index from global coordinates. More...
 
std::array< IndexType, NumDimensions > global (team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
 global More...
 
std::array< IndexType, NumDimensions > global (const std::array< IndexType, NumDimensions > &local_coords) const
 Converts local coordinates of a active unit to global coordinates. More...
 
IndexType global (IndexType local_index) const
 Resolve an element's linear global index from the calling unit's local index of that element. More...
 
IndexType global_index (team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
 Resolve an element's linear global index from a given unit's local coordinates of that element. More...
 
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's block-wise iteration order. More...
 
IndexType global_at (const std::array< IndexType, NumDimensions > &global_coords) const
 Global coordinates to global position in the pattern's block-wise iteration order. More...
 
IndexType at (const std::array< IndexType, NumDimensions > &global_coords, const ViewSpec_t &viewspec) const
 at More...
 
IndexType at (std::array< IndexType, NumDimensions > global_coords) const
 Global coordinates to local index. More...
 
template<typename ... Values>
IndexType at (Values ... values) const
 Global coordinates to local index. More...
 
bool has_local_elements (dim_t dim, IndexType dim_offset, team_unit_t unit, const ViewSpec_t &viewspec) const
 is_local More...
 
bool is_local (IndexType index, team_unit_t unit) const
 Whether the given global index is local to the specified unit. More...
 
bool is_local (IndexType index) const
 Whether the given global index is local to the unit that created this pattern instance. More...
 
index_type block_at (const std::array< index_type, NumDimensions > &g_coords) const
 block More...
 
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 space. More...
 
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. More...
 
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. More...
 
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. More...
 
const BlockSpec_tblockspec () const
 Cartesian arrangement of pattern blocks. More...
 
const BlockSpec_tlocal_blockspec () const
 Cartesian arrangement of pattern blocks. More...
 
BlockSpec_t local_blockspec (team_unit_t unit) const
 Cartesian arrangement of pattern blocks. More...
 
SizeType blocksize (dim_t dimension) const
 Maximum number of elements in a single block in the given dimension. More...
 
SizeType max_blocksize () const
 Maximum number of elements in a single block in all dimensions. More...
 
SizeType local_capacity () const
 Maximum number of elements assigned to a single unit in total, equivalent to the local capacity of every unit in this pattern. More...
 
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. More...
 
IndexType num_units () const
 The number of units to which this pattern's elements are mapped. More...
 
IndexType capacity () const
 The maximum number of elements arranged in this pattern. More...
 
IndexType size () const
 The number of elements arranged in this pattern. More...
 
dash::Teamteam () const
 The Team containing the units to which this pattern's elements are mapped. More...
 
const DistributionSpec_tdistspec () const
 Distribution specification of this pattern. More...
 
SizeSpec_t sizespec () const
 Size specification of the index space mapped by this pattern. More...
 
const std::array< SizeType, NumDimensions > & extents () const
 Size specification of the index space mapped by this pattern. More...
 
const TeamSpec_tteamspec () const
 Cartesian arrangement of the Team containing the units to which this pattern's elements are mapped. More...
 
std::array< IndexType, NumDimensions > coords (IndexType index) const
 Convert given global linear offset (index) to global cartesian coordinates. More...
 
std::array< IndexType, NumDimensions > coords (IndexType index, const ViewSpec_t &viewspec) const
 Convert given global linear offset (index) to global cartesian coordinates using viewspec. More...
 

Static Public Member Functions

static constexpr MemArrange memory_order ()
 Memory order followed by the pattern. More...
 
static constexpr dim_t ndim ()
 Number of dimensions of the cartesian space partitioned by the pattern. More...
 

Static Public Attributes

static constexpr char const * PatternName = "SeqTilePattern"
 

Detailed Description

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
class dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >

Defines how a list of global indices is mapped to single units within a Team.

Expects extent[d] to be a multiple of (blocksize[d] * nunits[d]) to ensure the balanced property.

Template Parameters
NumDimensionsThe number of dimensions of the pattern
ArrangementThe memory order of the pattern (ROW_MAJOR or COL_MAJOR), defaults to ROW_MAJOR. Memory order defines how elements in the pattern will be iterated predominantly
See also
MemArrange
Implemented concept:
Pattern Concept
Examples:
ex.06.pattern-block-visualizer/main.cpp.

Definition at line 48 of file SeqTilePattern.h.

Member Typedef Documentation

◆ layout_properties

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
typedef pattern_layout_properties< pattern_layout_tag::blocked, pattern_layout_tag::linear > dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::layout_properties

Satisfiable properties in pattern property category Layout:

Definition at line 81 of file SeqTilePattern.h.

◆ mapping_properties

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
typedef pattern_mapping_properties< pattern_mapping_tag::balanced, pattern_mapping_tag::unbalanced, pattern_mapping_tag::diagonal > dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::mapping_properties

Satisfiable properties in pattern property category Mapping:

Definition at line 72 of file SeqTilePattern.h.

◆ partitioning_properties

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
typedef pattern_partitioning_properties< pattern_partitioning_tag::minimal, pattern_partitioning_tag::rectangular, pattern_partitioning_tag::balanced > dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::partitioning_properties

Satisfiable properties in pattern property category Partitioning:

Definition at line 63 of file SeqTilePattern.h.

Constructor & Destructor Documentation

◆ SeqTilePattern() [1/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
template<typename ... Args>
dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::SeqTilePattern ( SizeType  arg,
Args &&...  args 
)
inline

Constructor, initializes a pattern from an argument list consisting of the pattern size (extent, number of elements) in every dimension followed by optional distribution types.

Examples:

// A 5x3 rectangle with blocked distribution in the first dimension
SeqTilePattern p1(10,20);
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20,
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20),
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
TeamSpec<2>(dash::Team::All(), 1));
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20),
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
// How teams are arranged in all dimensions, default
// is an extent of all units in first, and 1 in all
// higher dimensions:
TeamSpec<2>(dash::Team::All(), 1),
// The team containing the units to which the
// pattern maps the global indices. Defaults to all
// all units:
Parameters
argArgument list consisting of the pattern size (extent, number of elements) in every dimension followed by optional distribution types.
argsArgument list consisting of the pattern size (extent, number of elements) in every dimension followed by optional distribution types.

Definition at line 191 of file SeqTilePattern.h.

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::ndim().

200  : SeqTilePattern(PatternArguments_t(arg, args...))
201  {
202  DASH_LOG_TRACE("SeqTilePattern()", "Constructor with Argument list");
203  initialize_local_range();
204  }
SeqTilePattern(SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...

◆ SeqTilePattern() [2/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::SeqTilePattern ( const SizeSpec_t sizespec,
DistributionSpec_t  dist,
const TeamSpec_t teamspec,
dash::Team team = dash::Team::All() 
)
inline

Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec, TeamSpec and a Team.

Examples:

// A 5x3 rectangle with blocked distribution in the first dimension
SeqTilePattern p1(10,20);
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20,
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20),
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
TeamSpec<2>(dash::Team::All(), 1));
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20),
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
// How teams are arranged in all dimensions, default
// is an extent of all units in first, and 1 in all
// higher dimensions:
TeamSpec<2>(dash::Team::All(), 1),
// The team containing the units to which the
// pattern maps the global indices. Defaults to all
// all units:
Parameters
sizespecSeqTilePattern size (extent, number of elements) in every dimension
distDistribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of all dimensions. Defaults to BLOCKED in first, and NONE in higher dimensions
teamspecCartesian arrangement of units within the team
teamTeam containing units to which this pattern maps its elements

Definition at line 239 of file SeqTilePattern.h.

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  }
SizeSpec_t sizespec() const
Size specification of the index space mapped by this pattern.
const TeamSpec_t & teamspec() const
Cartesian arrangement of the Team containing the units to which this pattern&#39;s elements are mapped...
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:171

◆ SeqTilePattern() [3/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::SeqTilePattern ( const SizeSpec_t sizespec,
const DistributionSpec_t dist = DistributionSpec_t(),
Team team = dash::Team::All() 
)
inline

Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec and a Team.

Examples:

// A 5x3 rectangle with blocked distribution in the first dimension
SeqTilePattern p1(10,20);
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20,
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20),
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
TeamSpec<2>(dash::Team::All(), 1));
// Same as
SeqTilePattern p1(SizeSpec<2>(10,20),
DistributionSpec<2>(TILE(10/num_units),
TILE(20/num_units)));
// How teams are arranged in all dimensions, default
// is an extent of all units in first, and 1 in all
// higher dimensions:
TeamSpec<2>(dash::Team::All(), 1),
// The team containing the units to which the
// pattern maps the global indices. Defaults to all
// all units:
Parameters
sizespecSeqTilePattern size (extent, number of elements) in every dimension
distDistribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of all dimensions. Defaults to BLOCKED in first, and NONE in higher dimensions
teamTeam containing units to which this pattern maps its elements

Definition at line 300 of file SeqTilePattern.h.

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  }
SizeSpec_t sizespec() const
Size specification of the index space mapped by this pattern.
dash::Team & team() const
The Team containing the units to which this pattern&#39;s elements are mapped.
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:171

◆ SeqTilePattern() [4/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::SeqTilePattern ( const self_t other)
inline

Copy constructor.

Definition at line 336 of file SeqTilePattern.h.

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  }

◆ SeqTilePattern() [5/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::SeqTilePattern ( self_t other)
inline

Copy constructor using non-const lvalue reference parameter.

Introduced so variadic constructor is not a better match for copy-construction.

Definition at line 358 of file SeqTilePattern.h.

359  : SeqTilePattern(static_cast<const self_t &>(other))
360  { }
SeqTilePattern(SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...

Member Function Documentation

◆ at() [1/3]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::at ( const std::array< IndexType, NumDimensions > &  global_coords,
const ViewSpec_t viewspec 
) const
inline

at

Global coordinates and viewspec to local index.

See also
global_at
Pattern Concept

Definition at line 982 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::at().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ at() [2/3]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::at ( std::array< IndexType, NumDimensions >  global_coords) const
inline

Global coordinates to local index.

Convert given global coordinates in pattern to their respective linear local index.

See also
Pattern Concept

Definition at line 1021 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ at() [3/3]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
template<typename ... Values>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::at ( Values ...  values) const
inline

Global coordinates to local index.

Convert given coordinate in pattern to its linear local index.

See also
Pattern Concept

Definition at line 1058 of file SeqTilePattern.h.

References dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::at().

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  }
IndexType at(const std::array< IndexType, NumDimensions > &global_coords, const ViewSpec_t &viewspec) const
at

◆ block()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
ViewSpec_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::block ( index_type  global_block_index) const
inline

View spec (offset and extents) of block at global linear block index in global cartesian element space.

See also
Pattern Concept

Definition at line 1168 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::coords(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extents(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::extents().

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  }
const std::array< SizeType, NumDimensions > & extents() const
Size specification of the index space mapped by this pattern.
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ block_at()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
index_type dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::block_at ( const std::array< index_type, NumDimensions > &  g_coords) const
inline

block

Index of block at given global coordinates.

See also
Pattern Concept
Parameters
g_coordsGlobal coordinates of element

Definition at line 1145 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ blocksize()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
SizeType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::blocksize ( dim_t  dimension) const
inline

Maximum number of elements in a single block in the given dimension.

Returns
The blocksize in the given dimension
See also
Pattern Concept
Parameters
dimensionThe dimension in the pattern

Definition at line 1292 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent().

1295  {
1296  return _blocksize_spec.extent(dimension);
1297  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ blockspec()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
const BlockSpec_t& dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::blockspec ( ) const
inline

Cartesian arrangement of pattern blocks.

Definition at line 1261 of file SeqTilePattern.h.

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::ndim().

1262  {
1263  return _blockspec;
1264  }

◆ capacity()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::capacity ( ) const
inline

The maximum number of elements arranged in this pattern.

See also
Pattern Concept

Definition at line 1354 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

1354  {
1355  return _memory_layout.size();
1356  }
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ coords() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
std::array<IndexType, NumDimensions> dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::coords ( IndexType  index) const
inline

Convert given global linear offset (index) to global cartesian coordinates.

See also
Pattern Concept

Definition at line 1416 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::coords().

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local().

1417  {
1418  return _memory_layout.coords(index);
1419  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497

◆ coords() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
std::array<IndexType, NumDimensions> dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::coords ( IndexType  index,
const ViewSpec_t viewspec 
) const
inline

Convert given global linear offset (index) to global cartesian coordinates using viewspec.

See also
Pattern Concept

Definition at line 1427 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::coords().

1429  {
1430  return _memory_layout.coords(index, viewspec);
1431  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497

◆ distspec()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
const DistributionSpec_t& dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::distspec ( ) const
inline

Distribution specification of this pattern.

Definition at line 1378 of file SeqTilePattern.h.

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::ndim().

1378  {
1379  return _distspec;
1380  }

◆ extent()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
SizeType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::extent ( dim_t  dim) const
inline

extent

The number of elements in this pattern in the given dimension.

See also
blocksize()
local_size()
local_extent()
Pattern Concept

Definition at line 532 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent().

532  {
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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ extents()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
const std::array<SizeType, NumDimensions>& dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::extents ( ) const
inline

Size specification of the index space mapped by this pattern.

See also
Pattern Concept

Definition at line 1396 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extents().

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::block(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_block_local().

1396  {
1397  return _memory_layout.extents();
1398  }
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402

◆ global() [1/3]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
std::array<IndexType, NumDimensions> dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global ( team_unit_t  unit,
const std::array< IndexType, NumDimensions > &  local_coords 
) const
inline

global

Converts local coordinates of a given unit to global coordinates.

See also
Pattern Concept

Definition at line 786 of file SeqTilePattern.h.

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::ndim().

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  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
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.
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ global() [2/3]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
std::array<IndexType, NumDimensions> dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global ( const std::array< IndexType, NumDimensions > &  local_coords) const
inline

Converts local coordinates of a active unit to global coordinates.

See also
Pattern Concept

Definition at line 819 of file SeqTilePattern.h.

References dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global().

820  {
821  return global(_myid, local_coords);
822  }
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
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.

◆ global() [3/3]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global ( IndexType  local_index) const
inline

Resolve an element's linear global index from the calling unit's local index of that element.

TODO: Optmize

See also
at Inverse of global()
Pattern Concept

Definition at line 834 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::coords(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

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  }
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
local_index_t local_index(const std::array< IndexType, NumDimensions > &global_coords) const
Resolves the unit and the local index from global coordinates.
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ global_at() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global_at ( const std::array< IndexType, NumDimensions > &  global_coords,
const ViewSpec_t viewspec 
) const
inline

Global coordinates and viewspec to global position in the pattern's block-wise iteration order.

NOTE: Expects extent[d] to be a multiple of blocksize[d] * nunits[d] to ensure the balanced property.

See also
at
local_at
Pattern Concept

Definition at line 900 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ global_at() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global_at ( const std::array< IndexType, NumDimensions > &  global_coords) const
inline

Global coordinates to global position in the pattern's block-wise iteration order.

NOTE: Expects extent[d] to be a multiple of blocksize[d] * nunits[d] to ensure the balanced property.

See also
at
local_at
Pattern Concept

Definition at line 943 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ global_index()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::global_index ( team_unit_t  unit,
const std::array< IndexType, NumDimensions > &  local_coords 
) const
inline

Resolve an element's linear global index from a given unit's local coordinates of that element.

See also
at
global_at
Pattern Concept

Definition at line 873 of file SeqTilePattern.h.

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  }
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
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.
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ has_local_elements()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
bool dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::has_local_elements ( dim_t  dim,
IndexType  dim_offset,
team_unit_t  unit,
const ViewSpec_t viewspec 
) const
inline

is_local

Whether there are local elements in a dimension at a given offset, e.g. in a specific row or column.

See also
Pattern Concept
Parameters
dimDimension to check
dim_offsetOffset in dimension
unitDART id of the unit
viewspecViewspec to apply

Definition at line 1079 of file SeqTilePattern.h.

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  }
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
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ is_local() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
bool dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::is_local ( IndexType  index,
team_unit_t  unit 
) const
inline

Whether the given global index is local to the specified unit.

See also
Pattern Concept

Definition at line 1114 of file SeqTilePattern.h.

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::is_local().

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  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given global linear offset (index) to global cartesian coordinates.

◆ is_local() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
bool dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::is_local ( IndexType  index) const
inline

Whether the given global index is local to the unit that created this pattern instance.

See also
Pattern Concept

Definition at line 1130 of file SeqTilePattern.h.

References dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::is_local().

1132  {
1133  return is_local(index, _myid);
1134  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
bool is_local(IndexType index, team_unit_t unit) const
Whether the given global index is local to the specified unit.

◆ lbegin()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::lbegin ( ) const
inline

Resolves the global index of the first local element in the pattern.

See also
Pattern Concept

Definition at line 420 of file SeqTilePattern.h.

420  {
421  return _lbegin;
422  }

◆ lend()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::lend ( ) const
inline

Resolves the global index past the last local element in the pattern.

See also
Pattern Concept

Definition at line 429 of file SeqTilePattern.h.

429  {
430  return _lend;
431  }

◆ local() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
local_coords_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local ( const std::array< IndexType, NumDimensions > &  global_coords) const
inline

Converts global coordinates to their associated unit and its respective local coordinates.

See also
Pattern Concept

Definition at line 678 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_coords().

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  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
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.
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ local() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
local_index_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local ( IndexType  g_index) const
inline

Converts global index to its associated unit and respective local index.

TODO: Unoptimized

See also
Pattern Concept

Definition at line 710 of file SeqTilePattern.h.

References dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::coords(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_index().

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  }
local_index_t local_index(const std::array< IndexType, NumDimensions > &global_coords) const
Resolves the unit and the local index from global coordinates.
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given global linear offset (index) to global cartesian coordinates.

◆ local_at() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_at ( const std::array< IndexType, NumDimensions > &  local_coords,
const ViewSpec_t viewspec 
) const
inline

local

Convert given local coordinates and viewspec to linear local offset (index).

See also
Pattern Concept
Parameters
local_coordsPoint in local memory
viewspecView specification (local offsets) to apply on local_coords

Definition at line 599 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extents(), dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_index(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

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  }
local_index_t local_index(const std::array< IndexType, NumDimensions > &global_coords) const
Resolves the unit and the local index from global coordinates.
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ local_at() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_at ( const std::array< IndexType, NumDimensions > &  local_coords) const
inline

Convert given local coordinates to linear local offset (index).

See also
Pattern Concept
Parameters
local_coordsPoint in local memory

Definition at line 640 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extents(), dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_index(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

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  }
local_index_t local_index(const std::array< IndexType, NumDimensions > &global_coords) const
Resolves the unit and the local index from global coordinates.
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ local_block() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
ViewSpec_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_block ( index_type  local_block_index) const
inline

View spec (offset and extents) of block at local linear block index in global cartesian element space.

See also
Pattern Concept

Definition at line 1197 of file SeqTilePattern.h.

1199  {
1200  return local_block(_myid, local_block_index);
1201  }
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...

◆ local_block() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
ViewSpec_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_block ( team_unit_t  unit,
index_type  local_block_index 
) const
inline

View spec (offset and extents) of block at local linear block index in global cartesian element space.

See also
Pattern Concept

Definition at line 1209 of file SeqTilePattern.h.

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  }
const std::array< SizeType, NumDimensions > & extents() const
Size specification of the index space mapped by this pattern.
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ local_block_local()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
ViewSpec_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_block_local ( index_type  local_block_index) const
inline

View spec (offset and extents) of block at local linear block index in local cartesian element space.

See also
Pattern Concept

Definition at line 1238 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::coords(), dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extents(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::extents().

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  }
const std::array< SizeType, NumDimensions > & extents() const
Size specification of the index space mapped by this pattern.
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497

◆ local_blockspec() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
const BlockSpec_t& dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_blockspec ( ) const
inline

Cartesian arrangement of pattern blocks.

Definition at line 1269 of file SeqTilePattern.h.

1270  {
1271  return _local_blockspec;
1272  }

◆ local_blockspec() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
BlockSpec_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_blockspec ( team_unit_t  unit) const
inline

Cartesian arrangement of pattern blocks.

Definition at line 1277 of file SeqTilePattern.h.

1278  {
1279  if (unit == _myid) {
1280  return local_blockspec();
1281  }
1282  return initialize_local_blockspec( _blockspec, unit);
1283  }
const BlockSpec_t & local_blockspec() const
Cartesian arrangement of pattern blocks.

◆ local_capacity()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
SizeType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_capacity ( ) const
inline

Maximum number of elements assigned to a single unit in total, equivalent to the local capacity of every unit in this pattern.

See also
Pattern Concept

Definition at line 1317 of file SeqTilePattern.h.

References dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_size().

1317  {
1318  return local_size();
1319  }
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...

◆ local_coords()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
std::array<IndexType, NumDimensions> dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_coords ( const std::array< IndexType, NumDimensions > &  global_coords) const
inline

Converts global coordinates to their associated unit's respective local coordinates.

See also
Pattern Concept

Definition at line 725 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent().

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local().

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  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
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.
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ local_extent()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
SizeType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_extent ( dim_t  dim) const
inline

The actual number of elements in this pattern that are local to the calling unit in the given dimension.

See also
local_extents()
blocksize()
local_size()
extent()
Pattern Concept

Definition at line 554 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ local_extents()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
std::array<SizeType, NumDimensions> dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_extents ( team_unit_t  unit = UNDEFINED_TEAM_UNIT_ID) const
inline

The actual number of elements in this pattern that are local to the given unit, by dimension.

See also
local_extent()
blocksize()
local_size()
extent()
Pattern Concept

Definition at line 577 of file SeqTilePattern.h.

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::ndim().

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  }
constexpr team_unit_t UNDEFINED_TEAM_UNIT_ID
Invalid local unit ID.
Definition: Types.h:341
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402

◆ local_index()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
local_index_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_index ( const std::array< IndexType, NumDimensions > &  global_coords) const
inline

Resolves the unit and the local index from global coordinates.

See also
Pattern Concept

Definition at line 745 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent().

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_at().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
Definition: Types.h:319
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ local_size()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
SizeType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_size ( team_unit_t  unit = UNDEFINED_TEAM_UNIT_ID) const
inline

The actual number of elements in this pattern that are local to the calling unit in total.

See also
blocksize()
local_extent()
local_capacity()
Pattern Concept

Definition at line 1331 of file SeqTilePattern.h.

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::local_capacity(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::ndim().

1331  {
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  }
#define DART_UNDEFINED_UNIT_ID
Undefined unit ID.
Definition: dart_types.h:160
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ max_blocksize()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
SizeType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::max_blocksize ( ) const
inline

Maximum number of elements in a single block in all dimensions.

Returns
The maximum number of elements in a single block assigned to a unit.
See also
Pattern Concept

Definition at line 1307 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

1307  {
1308  return _blocksize_spec.size();
1309  }
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ memory_order()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
static constexpr MemArrange dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::memory_order ( )
inlinestatic

Memory order followed by the pattern.

Definition at line 1436 of file SeqTilePattern.h.

1436  {
1437  return Arrangement;
1438  }

◆ ndim()

◆ num_units()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::num_units ( ) const
inline

The number of units to which this pattern's elements are mapped.

See also
Pattern Concept

Definition at line 1345 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

1345  {
1346  return _teamspec.size();
1347  }
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ operator!=()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
bool dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::operator!= ( const self_t other) const
inline

Inquality comparison operator.

Parameters
otherSeqTilePattern instance to compare for inequality

Definition at line 387 of file SeqTilePattern.h.

390  {
391  return !(*this == other);
392  }

◆ operator=()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
SeqTilePattern& dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::operator= ( const SeqTilePattern< NumDimensions, Arrangement, IndexType > &  other)
inline

Assignment operator.

Definition at line 397 of file SeqTilePattern.h.

397  {
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  }

◆ operator==()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
bool dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::operator== ( const self_t other) const
inline

Equality comparison operator.

Parameters
otherSeqTilePattern instance to compare for equality

Definition at line 365 of file SeqTilePattern.h.

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  }

◆ size()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::size ( ) const
inline

The number of elements arranged in this pattern.

See also
Pattern Concept

Definition at line 1363 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::size().

1363  {
1364  return _memory_layout.size();
1365  }
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ sizespec()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
SizeSpec_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::sizespec ( ) const
inline

Size specification of the index space mapped by this pattern.

See also
Pattern Concept

Definition at line 1387 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extents().

1387  {
1388  return SizeSpec_t(_memory_layout.extents());
1389  }
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402

◆ team()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
dash::Team& dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::team ( ) const
inline

The Team containing the units to which this pattern's elements are mapped.

Definition at line 1371 of file SeqTilePattern.h.

1371  {
1372  return *_team;
1373  }

◆ teamspec()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
const TeamSpec_t& dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::teamspec ( ) const
inline

Cartesian arrangement of the Team containing the units to which this pattern's elements are mapped.

See also
Pattern Concept

Definition at line 1406 of file SeqTilePattern.h.

1406  {
1407  return _teamspec;
1408  }

◆ unit_at() [1/4]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
team_unit_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::unit_at ( const std::array< IndexType, NumDimensions > &  coords,
const ViewSpec_t viewspec 
) const
inline

unit_at

Convert given point in pattern to its assigned unit id.

See also
Pattern Concept
Parameters
coordsAbsolute coordinates of the point relative to the given view.
viewspecView specification (offsets) of the coordinates.

Definition at line 442 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent().

Referenced by dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::unit_at().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
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
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given global linear offset (index) to global cartesian coordinates.

◆ unit_at() [2/4]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
team_unit_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::unit_at ( const std::array< IndexType, NumDimensions > &  coords) const
inline

Convert given coordinate in pattern to its assigned unit id.

See also
Pattern Concept

Definition at line 471 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::at(), and dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::extent().

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  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
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
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given global linear offset (index) to global cartesian coordinates.

◆ unit_at() [3/4]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
team_unit_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::unit_at ( IndexType  global_pos,
const ViewSpec_t viewspec 
) const
inline

Convert given global linear index to its assigned unit id.

See also
Pattern Concept
Parameters
global_posGlobal linear element offset
viewspecView to apply global position

Definition at line 496 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::coords(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::unit_at().

501  {
502  auto global_coords = _memory_layout.coords(global_pos);
503  return unit_at(global_coords, viewspec);
504  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497

◆ unit_at() [4/4]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
team_unit_t dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::unit_at ( IndexType  global_pos) const
inline

Convert given global linear index to its assigned unit id.

See also
Pattern Concept
Parameters
global_posGlobal linear element offset

Definition at line 511 of file SeqTilePattern.h.

References dash::CartesianIndexSpace< NumDimensions, Arrangement, IndexType >::coords(), and dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::unit_at().

514  {
515  auto global_coords = _memory_layout.coords(global_pos);
516  return unit_at(global_coords);
517  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497

The documentation for this class was generated from the following file: