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

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

#include <BlockPattern.h>

Classes

struct  local_coords_t
 
struct  local_index_t
 

Public Types

typedef pattern_partitioning_properties< pattern_partitioning_tag::rectangular, pattern_partitioning_tag::balanced, pattern_partitioning_tag::unbalancedpartitioning_properties
 Satisfiable properties in pattern property category Partitioning: More...
 
typedef pattern_mapping_properties< pattern_mapping_tag::unbalancedmapping_properties
 Satisfiable properties in pattern property category Mapping: More...
 
typedef pattern_layout_properties< pattern_layout_tag::canonical, 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>
 BlockPattern (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...
 
 BlockPattern (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...
 
 BlockPattern (const SizeSpec_t &sizespec, DistributionSpec_t dist=DistributionSpec_t(), Team &team=dash::Team::All())
 Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec and a Team. More...
 
 BlockPattern (const self_t &other)
 Copy constructor. More...
 
 BlockPattern (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...
 
BlockPatternoperator= (const BlockPattern &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...
 
IndexType extent (dim_t dim) const
 extent More...
 
IndexType local_extent (dim_t dim) const
 The actual number of elements in this pattern that are local to the calling unit in the given dimension. More...
 
constexpr std::array< SizeType, NumDimensions > local_extents () const noexcept
 The actual number of elements in this pattern that are local to the active unit, by dimension. More...
 
constexpr std::array< SizeType, NumDimensions > local_extents (team_unit_t unit) const noexcept
 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...
 
constexpr 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 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 > &view_coords, const ViewSpec_t &viewspec) const
 Global coordinates and viewspec to global position in the pattern's iteration order. More...
 
IndexType global_at (const std::array< IndexType, NumDimensions > &global_coords) const
 Global coordinates to global position in the pattern's iteration order. More...
 
IndexType at (const std::array< IndexType, NumDimensions > &global_coords) const
 at More...
 
IndexType at (const std::array< IndexType, NumDimensions > &global_coords, const ViewSpec_t &viewspec) const
 Global coordinates and viewspec to local index. More...
 
template<typename ... Values>
IndexType at (IndexType value, 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...
 
constexpr bool is_local (IndexType index) const noexcept
 Whether the given global index is local to the unit that created this pattern instance. More...
 
constexpr const BlockSpec_tblockspec () const noexcept
 block More...
 
constexpr const BlockSpec_tlocal_blockspec () const noexcept
 Cartesian arrangement of local pattern blocks. More...
 
index_type block_at (const std::array< index_type, NumDimensions > &g_coords) const
 Index of block at given global coordinates. More...
 
local_index_t local_block_at (const std::array< index_type, NumDimensions > &g_coords) const
 Unit and local block index at given global coordinates. More...
 
ViewSpec_t block (index_type global_block_index) const
 View spec (offset and extents) of block at global linear block index in 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_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...
 
constexpr SizeType blocksize (dim_t dimension) const noexcept
 Maximum number of elements in a single block in the given dimension. More...
 
constexpr SizeType max_blocksize () const noexcept
 Maximum number of elements in a single block in all dimensions. More...
 
constexpr SizeType local_capacity () const noexcept
 Maximum number of elements assigned to a single unit in total, equivalent to the local capacity of every unit in this pattern. More...
 
constexpr SizeType local_size (team_unit_t unit=UNDEFINED_TEAM_UNIT_ID) const noexcept
 The actual number of elements in this pattern that are local to the calling unit in total. More...
 
constexpr IndexType num_units () const noexcept
 The number of units to which this pattern's elements are mapped. More...
 
constexpr IndexType capacity () const noexcept
 The maximum number of elements arranged in this pattern. More...
 
constexpr IndexType size () const noexcept
 The number of elements arranged in this pattern. More...
 
constexpr dash::Teamteam () const noexcept
 The Team containing the units to which this pattern's elements are mapped. More...
 
constexpr const DistributionSpec_tdistspec () const noexcept
 Distribution specification of this pattern. More...
 
constexpr SizeSpec_t sizespec () const noexcept
 Size specification of the index space mapped by this pattern. More...
 
constexpr const std::array< SizeType, NumDimensions > & extents () const noexcept
 Size specification of the index space mapped by this pattern. More...
 
constexpr const TeamSpec_tteamspec () const noexcept
 Cartesian arrangement of the Team containing the units to which this pattern's elements are mapped. More...
 
constexpr std::array< IndexType, NumDimensions > coords (IndexType index) const noexcept
 Convert given global linear offset (index) to global cartesian coordinates. More...
 
constexpr std::array< IndexType, NumDimensions > coords (IndexType index, const ViewSpec_t &viewspec) const noexcept
 Convert given global linear offset (index) and viewspec to global cartesian coordinates. More...
 
SizeType underfilled_blocksize (dim_t dimension) const
 Number of elements missing in the overflow block of given dimension compared to the regular blocksize (. More...
 

Static Public Member Functions

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

Static Public Attributes

static constexpr const char * PatternName = "BlockPattern"
 

Detailed Description

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

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

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, ex.08.io-hdf5/main.cpp, ex.10.radixsort/main.cpp, ex.11.halo-stencil/main.cpp, and ex.11.simple-stencil/main.cpp.

Definition at line 42 of file BlockPattern.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::canonical, pattern_layout_tag::linear > dash::BlockPattern< NumDimensions, Arrangement, IndexType >::layout_properties

Satisfiable properties in pattern property category Layout:

Definition at line 69 of file BlockPattern.h.

◆ mapping_properties

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

Satisfiable properties in pattern property category Mapping:

Definition at line 61 of file BlockPattern.h.

◆ partitioning_properties

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

Satisfiable properties in pattern property category Partitioning:

Definition at line 56 of file BlockPattern.h.

Constructor & Destructor Documentation

◆ BlockPattern() [1/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
template<typename ... Args>
dash::BlockPattern< NumDimensions, Arrangement, IndexType >::BlockPattern ( 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
Pattern p1(5,3, BLOCKED);
// Same as
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE));
// Same as
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE),
TeamSpec<2>(dash::Team::All(), 1));
// Same as
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE),
// 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:
// A cube with sidelength 3 with blockwise distribution in the first
// dimension
Pattern p2(3,3,3, BLOCKED);
// Same as p2
Pattern p3(3,3,3);
// A cube with sidelength 3 with blockwise distribution in the third
// dimension
Pattern p4(3,3,3, NONE, NONE, BLOCKED);
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 180 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::BlockPattern(), dash::BlockPattern< 1, Arrangement, IndexType >::underfilled_blocksize(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::underfilled_blocksize().

189  : BlockPattern(PatternArguments_t(arg, args...))
190  {
191  DASH_LOG_TRACE("BlockPattern()", "Constructor with argument list");
192  initialize_local_range();
193  DASH_LOG_TRACE("BlockPattern()", "BlockPattern initialized");
194  }
BlockPattern(SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...
Definition: BlockPattern.h:180

◆ BlockPattern() [2/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
dash::BlockPattern< NumDimensions, Arrangement, IndexType >::BlockPattern ( 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
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE),
// 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:
// Same as
Pattern p1(5,3, BLOCKED);
// Same as
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE));
// Same as
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE),
TeamSpec<2>(dash::Team::All(), 1));
Parameters
sizespecPattern size (extent, number of elements) in every dimension
distDistribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of all dimensions.
teamspecCartesian arrangement of units within the team
teamTeam containing units to which this pattern maps its elements

Definition at line 224 of file BlockPattern.h.

234  : _distspec(std::move(dist))
235  , _team(&team)
236  , _teamspec(teamspec, _distspec, *_team)
237  , _nunits(_teamspec.size())
238  , _memory_layout(sizespec.extents())
239  , _blocksize_spec(
240  initialize_blocksizespec(sizespec, _distspec, _teamspec))
241  , _blockspec(initialize_blockspec(sizespec, _distspec, _blocksize_spec))
242  , _local_memory_layout(initialize_local_extents(_team->myid()))
243  , _local_blockspec(
244  initialize_local_blockspec(_blocksize_spec, _local_memory_layout))
245  , _local_capacity(initialize_local_capacity())
246  {
247  DASH_LOG_TRACE("BlockPattern()", "(sizespec, dist, teamspec, team)");
248  initialize_local_range();
249  DASH_LOG_TRACE("BlockPattern()", "BlockPattern initialized");
250  }
constexpr const TeamSpec_t & teamspec() const noexcept
Cartesian arrangement of the Team containing the units to which this pattern&#39;s elements are mapped...
constexpr SizeSpec_t sizespec() const noexcept
Size specification of the index space mapped by this pattern.
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

◆ BlockPattern() [3/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
dash::BlockPattern< NumDimensions, Arrangement, IndexType >::BlockPattern ( const SizeSpec_t sizespec,
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
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE),
// The team containing the units to which the pattern
// maps the global indices. Defaults to all all units:
// Same as
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE),
// 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:
// Same as
Pattern p1(5,3, BLOCKED);
// Same as
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE));
// Same as
Pattern p1(SizeSpec<2>(5,3),
DistributionSpec<2>(BLOCKED, NONE),
TeamSpec<2>(dash::Team::All(), 1));
Parameters
sizespecPattern 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 286 of file BlockPattern.h.

295  : _distspec(std::move(dist))
296  , _team(&team)
297  , _teamspec(_distspec, *_team)
298  , _nunits(_teamspec.size())
299  , _memory_layout(sizespec.extents())
300  , _blocksize_spec(
301  initialize_blocksizespec(sizespec, _distspec, _teamspec))
302  , _blockspec(initialize_blockspec(sizespec, _distspec, _blocksize_spec))
303  , _local_memory_layout(initialize_local_extents(_team->myid()))
304  , _local_blockspec(
305  initialize_local_blockspec(_blocksize_spec, _local_memory_layout))
306  , _local_capacity(initialize_local_capacity())
307  {
308  DASH_LOG_TRACE("BlockPattern()", "(sizespec, dist, team)");
309  initialize_local_range();
310  DASH_LOG_TRACE("BlockPattern()", "BlockPattern initialized");
311  }
constexpr SizeSpec_t sizespec() const noexcept
Size specification of the index space mapped by this pattern.
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
constexpr dash::Team & team() const noexcept
The Team containing the units to which this pattern&#39;s elements are mapped.

◆ BlockPattern() [4/5]

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

Copy constructor.

Definition at line 316 of file BlockPattern.h.

317  : _distspec(other._distspec),
318  _team(other._team),
319  _teamspec(other._teamspec),
320  _nunits(other._nunits),
321  _memory_layout(other._memory_layout),
322  _blocksize_spec(other._blocksize_spec),
323  _blockspec(other._blockspec),
324  _local_memory_layout(other._local_memory_layout),
325  _local_blockspec(other._local_blockspec),
326  _local_capacity(other._local_capacity),
327  _lbegin(other._lbegin),
328  _lend(other._lend)
329  {
330  // No need to copy _arguments as it is just used to
331  // initialize other members.
332  DASH_LOG_TRACE("BlockPattern(other)", "BlockPattern copied");
333  }

◆ BlockPattern() [5/5]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
dash::BlockPattern< NumDimensions, Arrangement, IndexType >::BlockPattern ( 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 341 of file BlockPattern.h.

342  : BlockPattern(static_cast<const self_t &>(other))
343  { }
BlockPattern(SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...
Definition: BlockPattern.h:180

Member Function Documentation

◆ at() [1/3]

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

at

Global coordinates to local index.

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

See also
Pattern Concept

Definition at line 855 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::at(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::at(), and dash::BlockPattern< 1, Arrangement, IndexType >::local_index().

857  {
858  auto unit = unit_at(global_coords);
859  // Global coords to local coords:
860  std::array<IndexType, NumDimensions> l_coords =
861  local_coords(global_coords);
862  DASH_LOG_TRACE_VAR("BlockPattern.at", l_coords);
863  if (unit == _team->myid()) {
864  // Coords are local to this unit, use pre-generated local memory
865  // layout
866  return _local_memory_layout.at(l_coords);
867  } else {
868  // Cannot use _local_memory_layout as it is only defined for the
869  // active unit but does not specify local memory of other units.
870  // Generate local memory layout for unit assigned to coords:
871  auto l_mem_layout =
872  LocalMemoryLayout_t(initialize_local_extents(unit));
873  return l_mem_layout.at(l_coords);
874  }
875  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
Definition: BlockPattern.h:430
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ at() [2/3]

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

Global coordinates and viewspec to local index.

Convert given global coordinate in pattern to its linear local index.

See also
Pattern Concept

Definition at line 884 of file BlockPattern.h.

887  {
888  auto coords = global_coords;
889  for (auto d = 0; d < NumDimensions; ++d) {
890  coords[d] += viewspec.offset(d);
891  }
892  DASH_LOG_TRACE_VAR("BlockPattern.at()", coords);
893  DASH_LOG_TRACE_VAR("BlockPattern.at()", viewspec);
894  return at(coords);
895  }
IndexType at(const std::array< IndexType, NumDimensions > &global_coords) const
at
Definition: BlockPattern.h:855
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const noexcept
Convert given global linear offset (index) to global cartesian coordinates.

◆ at() [3/3]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
template<typename ... Values>
IndexType dash::BlockPattern< NumDimensions, Arrangement, IndexType >::at ( IndexType  value,
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 905 of file BlockPattern.h.

906  {
907  static_assert(
908  sizeof...(values) == NumDimensions-1,
909  "Wrong parameter number");
910  std::array<IndexType, NumDimensions> inputindex = {
911  value, (IndexType)values...
912  };
913  return at(inputindex);
914  }
IndexType at(const std::array< IndexType, NumDimensions > &global_coords) const
at
Definition: BlockPattern.h:855

◆ block()

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

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

Definition at line 1058 of file BlockPattern.h.

1060  {
1061  // block index -> block coords -> offset
1062  auto block_coords = _blockspec.coords(global_block_index);
1063  std::array<index_type, NumDimensions> offsets{};
1064  std::array<size_type, NumDimensions> extents{};
1065 
1066  for (auto d = 0; d < NumDimensions; ++d) {
1067  auto num_blocks_d = _blockspec.extent(d);
1068  extents[d] = _blocksize_spec.extent(d);
1069  if(block_coords[d] == (num_blocks_d - 1)){
1070  extents[d] -= underfilled_blocksize(d);
1071  }
1072  offsets[d] = block_coords[d] * _blocksize_spec.extent(d);
1073  }
1074  return ViewSpec_t(offsets, extents);
1075  }
SizeType underfilled_blocksize(dim_t dimension) const
Number of elements missing in the overflow block of given dimension compared to the regular blocksize...
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 const std::array< SizeType, NumDimensions > & extents() const noexcept
Size specification of the index space mapped by this pattern.

◆ block_at()

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

Index of block at given global coordinates.

See also
Pattern Concept
Parameters
g_coordsGlobal coordinates of element

Definition at line 1007 of file BlockPattern.h.

1010  {
1011  std::array<index_type, NumDimensions> block_coords{};
1012  // Coord to block coord to unit coord:
1013  for (auto d = 0; d < NumDimensions; ++d) {
1014  block_coords[d] = g_coords[d] / _blocksize_spec.extent(d);
1015  }
1016  // Block coord to block index:
1017  auto block_idx = _blockspec.at(block_coords);
1018  DASH_LOG_TRACE("BlockPattern.block_at",
1019  "coords", g_coords,
1020  "> block index", block_idx);
1021  return block_idx;
1022  }
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>
constexpr SizeType dash::BlockPattern< NumDimensions, Arrangement, IndexType >::blocksize ( dim_t  dimension) const
inlinenoexcept

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 1163 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::underfilled_blocksize(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::underfilled_blocksize().

1166  {
1167  return _blocksize_spec.extent(dimension);
1168  }
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>
constexpr const BlockSpec_t& dash::BlockPattern< NumDimensions, Arrangement, IndexType >::blockspec ( ) const
inlinenoexcept

block

Cartesian arrangement of pattern blocks.

Definition at line 989 of file BlockPattern.h.

990  {
991  return _blockspec;
992  }

◆ capacity()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
constexpr IndexType dash::BlockPattern< NumDimensions, Arrangement, IndexType >::capacity ( ) const
inlinenoexcept

The maximum number of elements arranged in this pattern.

See also
Pattern Concept

Definition at line 1227 of file BlockPattern.h.

1228  {
1229  return _memory_layout.size();
1230  }
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>
constexpr std::array<IndexType, NumDimensions> dash::BlockPattern< NumDimensions, Arrangement, IndexType >::coords ( IndexType  index) const
inlinenoexcept

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

See also
Pattern Concept

Definition at line 1297 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::at(), dash::BlockPattern< 1, Arrangement, IndexType >::local(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local_at().

1299  {
1300  return _memory_layout.coords(index);
1301  }
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>
constexpr std::array<IndexType, NumDimensions> dash::BlockPattern< NumDimensions, Arrangement, IndexType >::coords ( IndexType  index,
const ViewSpec_t viewspec 
) const
inlinenoexcept

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

See also
Pattern Concept
Parameters
indexGlobal index (offset) to convert
viewspecView specification (offsets) to apply on coords

Definition at line 1309 of file BlockPattern.h.

1314  {
1315  return _memory_layout.coords(index, viewspec);
1316  }
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>
constexpr const DistributionSpec_t& dash::BlockPattern< NumDimensions, Arrangement, IndexType >::distspec ( ) const
inlinenoexcept

Distribution specification of this pattern.

Definition at line 1254 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::underfilled_blocksize(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::underfilled_blocksize().

1255  {
1256  return _distspec;
1257  }

◆ extent()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::BlockPattern< 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 511 of file BlockPattern.h.

512  {
513  if (dim >= NumDimensions || dim < 0) {
514  DASH_THROW(
516  "Wrong dimension for Pattern::local_extent. "
517  << "Expected dimension between 0 and " << NumDimensions-1 << ", "
518  << "got " << dim);
519  }
520  return _memory_layout.extent(dim);
521  }
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>
constexpr const std::array<SizeType, NumDimensions>& dash::BlockPattern< NumDimensions, Arrangement, IndexType >::extents ( ) const
inlinenoexcept

Size specification of the index space mapped by this pattern.

See also
Pattern Concept

Definition at line 1275 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::block(), dash::BlockPattern< 1, Arrangement, IndexType >::local_block_local(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local_block_local().

1276  {
1277  return _memory_layout.extents();
1278  }
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::BlockPattern< 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 710 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::global(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::global(), dash::BlockPattern< 1, Arrangement, IndexType >::local_block(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local_block(), dash::BlockPattern< 1, Arrangement, IndexType >::underfilled_blocksize(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::underfilled_blocksize().

713  {
714  DASH_LOG_DEBUG_VAR("BlockPattern.global()", local_coords);
715  if (_teamspec.size() < 2) {
716  return local_coords;
717  }
718  // Coordinates of the unit within the team spec:
719  std::array<IndexType, NumDimensions> unit_ts_coord =
720  _teamspec.coords(unit);
721  // Index of the element:
722  std::array<IndexType, NumDimensions> glob_index{};
723  for (auto d = 0; d < NumDimensions; ++d) {
724  const Distribution & dist = _distspec[d];
725  auto num_units_d = _teamspec.extent(d);
726  auto blocksize_d = _blocksize_spec.extent(d);
727  auto local_index_d = local_coords[d];
728  // TOOD: Use % (blocksize_d - underfill_d)
729  auto elem_block_offset_d = local_index_d % blocksize_d;
730  // Global coords of the element's block within all blocks:
731  auto block_index_d = dist.local_index_to_block_coord(
732  unit_ts_coord[d], // unit ts offset in d
733  local_index_d,
734  num_units_d
735  );
736  glob_index[d] = (block_index_d * blocksize_d) + elem_block_offset_d;
737  }
738  DASH_LOG_DEBUG_VAR("BlockPattern.global >", glob_index);
739  return glob_index;
740  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
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 SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:395

◆ global() [2/3]

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

Converts local coordinates of active unit to global coordinates.

See also
Pattern Concept

Definition at line 747 of file BlockPattern.h.

749  {
750  return global(_team->myid(), local_coords);
751  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
Definition: BlockPattern.h:710

◆ global() [3/3]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::BlockPattern< 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.

See also
at Inverse of global()
Pattern Concept

Definition at line 761 of file BlockPattern.h.

763  {
764  std::array<IndexType, NumDimensions> local_coords =
765  _local_memory_layout.coords(local_index);
766  DASH_LOG_TRACE_VAR("BlockPattern.local_to_global_idx()", local_coords);
767  std::array<IndexType, NumDimensions> global_coords =
768  global(_team->myid(), local_coords);
769  DASH_LOG_TRACE_VAR("BlockPattern.local_to_global_idx >", global_coords);
770  return _memory_layout.at(global_coords);
771  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
local_index_t local_index(const std::array< IndexType, NumDimensions > &global_coords) const
Resolves the unit and the local index from global coordinates.
Definition: BlockPattern.h:677
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
Definition: BlockPattern.h:710
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given linear offset (index) to cartesian coordinates.
Definition: Cartesian.h:497
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ global_at() [1/2]

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

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

See also
at
local_at
Pattern Concept

Definition at line 800 of file BlockPattern.h.

803  {
804  DASH_LOG_TRACE("BlockPattern.global_at()",
805  "view coords:",view_coords,
806  "view:", viewspec);
807  // Global coordinates of the element referenced in the view:
808  std::array<IndexType, NumDimensions> global_coords{};
809  for (auto d = 0; d < NumDimensions; ++d) {
810  global_coords[d] = view_coords[d] + viewspec.offset(d);
811  }
812  DASH_LOG_TRACE("BlockPattern.global_at",
813  "global coords:", global_coords);
814  // Offset in iteration order is identical to offset in canonical order:
815  auto offset = _memory_layout.at(global_coords);
816  DASH_LOG_TRACE_VAR("BlockPattern.global_at >", offset);
817  return offset;
818  }
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ global_at() [2/2]

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

Global coordinates to global position in the pattern's 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 832 of file BlockPattern.h.

834  {
835  DASH_LOG_TRACE("BlockPattern.global_at()",
836  "gcoords:", global_coords);
837  // Offset in iteration order is identical to offset in canonical order:
838  auto offset = _memory_layout.at(global_coords);
839  DASH_LOG_TRACE_VAR("BlockPattern.global_at >", offset);
840  return offset;
841  }
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ global_index()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::BlockPattern< 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
Pattern Concept

Definition at line 781 of file BlockPattern.h.

784  {
785  std::array<IndexType, NumDimensions> global_coords =
786  global(unit, local_coords);
787  DASH_LOG_TRACE_VAR("BlockPattern.local_to_global_idx", global_coords);
788  return _memory_layout.at(global_coords);
789  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
Definition: BlockPattern.h:710
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::BlockPattern< 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
unitlocal id of the unit
viewspecViewspec to apply

Definition at line 926 of file BlockPattern.h.

935  {
936  DASH_LOG_TRACE_VAR("BlockPattern.has_local_elements()", dim);
937  DASH_LOG_TRACE_VAR("BlockPattern.has_local_elements()", dim_offset);
938  DASH_LOG_TRACE_VAR("BlockPattern.has_local_elements()", unit);
939  // Apply viewspec offset in dimension to given position
940  dim_offset += viewspec.offset(dim);
941  // Offset to block offset
942  IndexType block_coord_d = dim_offset / _blocksize_spec.extent(dim);
943  DASH_LOG_TRACE_VAR("BlockPattern.has_local_elements", block_coord_d);
944  // Coordinate of unit in team spec in given dimension
945  IndexType teamspec_coord_d = block_coord_d % _teamspec.extent(dim);
946  DASH_LOG_TRACE_VAR("BlockPattern.has_local_elements()",
947  teamspec_coord_d);
948  // Check if unit id lies in cartesian sub-space of team spec
949  return _teamspec.includes_index(
950  teamspec_coord_d,
951  dim,
952  dim_offset);
953  }
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::BlockPattern< 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 960 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::is_local(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::is_local().

963  {
964  auto glob_coords = coords(index);
965  auto coords_unit = unit_at(glob_coords);
966  DASH_LOG_TRACE_VAR("BlockPattern.is_local >", (coords_unit == unit));
967  return coords_unit == unit;
968  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
Definition: BlockPattern.h:430
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const noexcept
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>
constexpr bool dash::BlockPattern< NumDimensions, Arrangement, IndexType >::is_local ( IndexType  index) const
inlinenoexcept

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

See also
Pattern Concept

Definition at line 976 of file BlockPattern.h.

978  {
979  return is_local(index, team().myid());
980  }
global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
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.
Definition: BlockPattern.h:960
constexpr dash::Team & team() const noexcept
The Team containing the units to which this pattern&#39;s elements are mapped.

◆ lbegin()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::BlockPattern< 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 406 of file BlockPattern.h.

407  {
408  return _lbegin;
409  }

◆ lend()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
IndexType dash::BlockPattern< 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 416 of file BlockPattern.h.

417  {
418  return _lend;
419  }

◆ local() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
local_coords_t dash::BlockPattern< 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.

TODO: Unoptimized

See also
Pattern Concept

Definition at line 625 of file BlockPattern.h.

627  {
628  local_coords_t l_coords;
629  l_coords.coords = local_coords(global_coords);
630  l_coords.unit = unit_at(global_coords);
631  return l_coords;
632  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
Definition: BlockPattern.h:430

◆ local() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
local_index_t dash::BlockPattern< 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 641 of file BlockPattern.h.

643  {
644  DASH_LOG_TRACE_VAR("BlockPattern.local()", g_index);
645  // TODO: Implement dedicated method for this, conversion to/from
646  // global coordinates is expensive.
647  auto l_coords = coords(g_index);
648  return local_index(l_coords);
649  }
local_index_t local_index(const std::array< IndexType, NumDimensions > &global_coords) const
Resolves the unit and the local index from global coordinates.
Definition: BlockPattern.h:677
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const noexcept
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::BlockPattern< 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 (offsets) to apply on coords

Definition at line 592 of file BlockPattern.h.

597  {
598  auto coords = local_coords;
599  for (auto d = 0; d < NumDimensions; ++d) {
600  coords[d] += viewspec.offset(d);
601  }
602  return _local_memory_layout.at(coords);
603  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const noexcept
Convert given global linear offset (index) to global cartesian coordinates.

◆ local_at() [2/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
constexpr IndexType dash::BlockPattern< 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 610 of file BlockPattern.h.

613  {
614  return _local_memory_layout.at(local_coords);
615  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ local_block()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
ViewSpec_t dash::BlockPattern< 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.

Definition at line 1081 of file BlockPattern.h.

1083  {
1084  // Initialize viewspec result with block extents:
1085  std::array<SizeType, NumDimensions> block_vs_extents =
1086  _blocksize_spec.extents();
1087  std::array<IndexType, NumDimensions> block_vs_offsets {{ }};
1088  // Local block index to local block coords:
1089  auto l_block_coords = _local_blockspec.coords(local_block_index);
1090  auto l_elem_coords = l_block_coords;
1091  // TODO: This is convenient but less efficient:
1092  // Translate local coordinates of first element in local block to global
1093  // coordinates:
1094  for (auto d = 0; d < NumDimensions; ++d) {
1095  auto num_blocks_d =_local_blockspec.extent(d);
1096  if(l_block_coords[d] == (num_blocks_d - 1)){
1097  size_type remaining = local_extent(d) % block_vs_extents[d];
1098  block_vs_extents[d] = (remaining == 0)
1099  ? block_vs_extents[d]
1100  : remaining;
1101  // to calculate offset, extent of fully filled blocks are needed
1102  l_elem_coords[d] *= _blocksize_spec.extent(d);
1103  } else {
1104  l_elem_coords[d] *= block_vs_extents[d];
1105  }
1106  }
1107  // Global coordinates of first element in block:
1108  auto g_elem_coords = global(l_elem_coords);
1109  for (auto d = 0; d < NumDimensions; ++d) {
1110  block_vs_offsets[d] = g_elem_coords[d];
1111  }
1112 #ifdef __TODO__
1113  // Coordinates of the unit within the team spec:
1114  std::array<IndexType, NumDimensions> unit_ts_coord =
1115  _teamspec.coords(unit);
1116  for (auto d = 0; d < NumDimensions; ++d) {
1117  const Distribution & dist = _distspec[d];
1118  auto blocksize_d = block_vs_extents[d];
1119  auto num_units_d = _teamspec.extent(d);
1120  auto num_blocks_d = _blockspec.extent(d);
1121  // Local to global block coords:
1122  auto g_block_coord_d = (l_block_coords[d] + _myid) *
1123  _teamspec.extent(d);
1124  block_vs_offsets[d] = g_block_coord_d * blocksize_d;
1125  }
1126 #endif
1127  ViewSpec_t block_vs(block_vs_offsets, block_vs_extents);
1128  return block_vs;
1129  }
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
Definition: BlockPattern.h:710
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
IndexType local_extent(dim_t dim) const
The actual number of elements in this pattern that are local to the calling unit in the given dimensi...
Definition: BlockPattern.h:534

◆ local_block_at()

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

Unit and local block index at given global coordinates.

See also
Pattern Concept
Parameters
g_coordsGlobal coordinates of element

Definition at line 1029 of file BlockPattern.h.

1032  {
1033  local_index_t l_pos;
1034 
1035  std::array<IndexType, NumDimensions> l_block_coords{};
1036  std::array<IndexType, NumDimensions> unit_ts_coords{};
1037  for (dim_t d = 0; d < NumDimensions; ++d) {
1038  auto nunits_d = _teamspec.extent(d);
1039  auto blocksize_d = _blocksize_spec.extent(d);
1040  auto block_coord_d = g_coords[d] / blocksize_d;
1041  l_block_coords[d] = block_coord_d / nunits_d;
1042  unit_ts_coords[d] = block_coord_d % nunits_d;
1043  }
1044  l_pos.unit = _teamspec.at(unit_ts_coords);
1045  l_pos.index = _local_blockspec.at(l_block_coords);
1046 
1047  DASH_LOG_TRACE("BlockPattern.local_block_at >",
1048  "coords", g_coords,
1049  "unit:", l_pos.unit,
1050  "local block index:", l_pos.index);
1051  return l_pos;
1052  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
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_block_local()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
ViewSpec_t dash::BlockPattern< 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.

Definition at line 1135 of file BlockPattern.h.

1137  {
1138  // Local block index to local block coords:
1139  auto l_block_coords = _local_blockspec.coords(local_block_index);
1140  std::array<index_type, NumDimensions> offsets;
1141  std::array<size_type, NumDimensions> extents = _blocksize_spec.extents();
1142  // last block in at least one dimension
1143  for(dim_t d=0; d<NumDimensions; ++d){
1144  if(l_block_coords[d] == (_local_blockspec.extent(d)-1)){
1145  size_type remaining = local_extent(d) % extents[d];
1146  extents[d] = (remaining == 0) ? extents[d] : remaining;
1147  // to calculate offset, extent of fully filled blocks are needed
1148  offsets[d] = l_block_coords[d] * _blocksize_spec.extent(d);
1149  } else {
1150  offsets[d] = l_block_coords[d] * extents[d];
1151  }
1152  }
1153  return ViewSpec_t(offsets, extents);
1154  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
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
IndexType local_extent(dim_t dim) const
The actual number of elements in this pattern that are local to the calling unit in the given dimensi...
Definition: BlockPattern.h:534
constexpr const std::array< SizeType, NumDimensions > & extents() const noexcept
Size specification of the index space mapped by this pattern.

◆ local_blockspec()

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

Cartesian arrangement of local pattern blocks.

Definition at line 997 of file BlockPattern.h.

998  {
999  return _local_blockspec;
1000  }

◆ local_capacity()

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

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 1189 of file BlockPattern.h.

1190  {
1191  return _local_capacity;
1192  }

◆ local_coords()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
std::array<IndexType, NumDimensions> dash::BlockPattern< 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 657 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::at(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::global(), dash::BlockPattern< 1, Arrangement, IndexType >::local(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local_at(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local_coords().

659  {
660  std::array<IndexType, NumDimensions> local_coords{};
661  for (auto d = 0; d < NumDimensions; ++d) {
662  auto block_size_d = _blocksize_spec.extent(d);
663  auto b_offset_d = global_coords[d] % block_size_d;
664  auto g_block_offset_d = global_coords[d] / block_size_d;
665  auto l_block_offset_d = g_block_offset_d / _teamspec.extent(d);
666  local_coords[d] = b_offset_d +
667  (l_block_offset_d * block_size_d);
668  }
669  return local_coords;
670  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
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>
IndexType dash::BlockPattern< 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 534 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local_block(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local_block_local().

535  {
536  if (dim >= NumDimensions || dim < 0) {
537  DASH_THROW(
539  "Wrong dimension for Pattern::local_extent. "
540  << "Expected dimension between 0 and " << NumDimensions-1 << ", "
541  << "got " << dim);
542  }
543  return _local_memory_layout.extent(dim);
544  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ local_extents() [1/2]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
constexpr std::array<SizeType, NumDimensions> dash::BlockPattern< NumDimensions, Arrangement, IndexType >::local_extents ( ) const
inlinenoexcept

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

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

Definition at line 557 of file BlockPattern.h.

558  {
559  return _local_memory_layout.extents();
560  }
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:402

◆ local_extents() [2/2]

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

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 573 of file BlockPattern.h.

575  {
576  return ( unit == _team->myid()
577  ? _local_memory_layout.extents()
578  : initialize_local_extents(unit)
579  );
580  }
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::BlockPattern< 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 677 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::local(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local().

679  {
680  DASH_LOG_TRACE_VAR("BlockPattern.local_index()", global_coords);
681  auto unit = unit_at(global_coords);
682  DASH_LOG_TRACE_VAR("BlockPattern.local_index", unit);
683  // Global coords to local coords:
684  std::array<IndexType, NumDimensions> l_coords =
685  local_coords(global_coords);
686  DASH_LOG_TRACE_VAR("BlockPattern.local_index", l_coords);
687  if (unit == _team->myid()) {
688  // Coords are local to this unit, use pre-generated local memory
689  // layout
690  return local_index_t { unit, _local_memory_layout.at(l_coords) };
691  } else {
692  // Cannot use _local_memory_layout as it is only defined for the
693  // active unit but does not specify local memory of other units.
694  // Generate local memory layout for unit assigned to coords:
695  auto l_mem_layout =
696  LocalMemoryLayout_t(initialize_local_extents(unit));
697  return local_index_t { unit, l_mem_layout.at(l_coords) };
698  }
699  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &global_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.
Definition: BlockPattern.h:657
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
Definition: BlockPattern.h:430
constexpr IndexType at(IndexType arg, Args... args) const
Convert the given coordinates to their respective linear index.
Definition: Cartesian.h:429

◆ local_size()

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

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 1204 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::underfilled_blocksize().

1206  {
1207  return (unit == UNDEFINED_TEAM_UNIT_ID)
1208  ? _local_memory_layout.size()
1209  : initialize_local_extents(unit).size();
1210  }
constexpr team_unit_t UNDEFINED_TEAM_UNIT_ID
Invalid local unit ID.
Definition: Types.h:341
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>
constexpr SizeType dash::BlockPattern< NumDimensions, Arrangement, IndexType >::max_blocksize ( ) const
inlinenoexcept

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 1178 of file BlockPattern.h.

1179  {
1180  return _blocksize_spec.size();
1181  }
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::BlockPattern< NumDimensions, Arrangement, IndexType >::memory_order ( )
inlinestaticnoexcept

Memory order followed by the pattern.

Definition at line 1321 of file BlockPattern.h.

Referenced by dash::halo::StencilOperatorBoundary< Self_t >::update().

1322  {
1323  return Arrangement;
1324  }

◆ ndim()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
static constexpr dim_t dash::BlockPattern< NumDimensions, Arrangement, IndexType >::ndim ( )
inlinestaticnoexcept

Number of dimensions of the cartesian space partitioned by the pattern.

Definition at line 1329 of file BlockPattern.h.

Referenced by dash::halo::StencilOperatorBoundary< Self_t >::update().

1330  {
1331  return NumDimensions;
1332  }

◆ num_units()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
constexpr IndexType dash::BlockPattern< NumDimensions, Arrangement, IndexType >::num_units ( ) const
inlinenoexcept

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

See also
Pattern Concept

Definition at line 1217 of file BlockPattern.h.

1218  {
1219  return _nunits;
1220  }

◆ operator!=()

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

Inquality comparison operator.

Parameters
otherPattern instance to compare for inequality

Definition at line 370 of file BlockPattern.h.

373  {
374  return !(*this == other);
375  }

◆ operator=()

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

Assignment operator.

Definition at line 380 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::BlockPattern().

381  {
382  DASH_LOG_TRACE("BlockPattern.=(other)");
383  if (this != &other) {
384  _distspec = other._distspec;
385  _team = other._team;
386  _teamspec = other._teamspec;
387  _memory_layout = other._memory_layout;
388  _local_memory_layout = other._local_memory_layout;
389  _blocksize_spec = other._blocksize_spec;
390  _blockspec = other._blockspec;
391  _local_blockspec = other._local_blockspec;
392  _local_capacity = other._local_capacity;
393  _nunits = other._nunits;
394  _lbegin = other._lbegin;
395  _lend = other._lend;
396  DASH_LOG_TRACE("BlockPattern.=(other)", "BlockPattern assigned");
397  }
398  return *this;
399  }

◆ operator==()

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

Equality comparison operator.

Parameters
otherPattern instance to compare for equality

Definition at line 348 of file BlockPattern.h.

351  {
352  if (this == &other) {
353  return true;
354  }
355  // no need to compare all members as most are derived from
356  // constructor arguments.
357  return(
358  _distspec == other._distspec &&
359  _teamspec == other._teamspec &&
360  _memory_layout == other._memory_layout &&
361  _blockspec == other._blockspec &&
362  _blocksize_spec == other._blocksize_spec &&
363  _nunits == other._nunits
364  );
365  }

◆ size()

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
constexpr IndexType dash::BlockPattern< NumDimensions, Arrangement, IndexType >::size ( ) const
inlinenoexcept

The number of elements arranged in this pattern.

See also
Pattern Concept

Definition at line 1237 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::underfilled_blocksize().

1238  {
1239  return _memory_layout.size();
1240  }
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>
constexpr SizeSpec_t dash::BlockPattern< NumDimensions, Arrangement, IndexType >::sizespec ( ) const
inlinenoexcept

Size specification of the index space mapped by this pattern.

See also
Pattern Concept

Definition at line 1264 of file BlockPattern.h.

1265  {
1266  return SizeSpec_t(_memory_layout.extents());
1267  }
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>
constexpr dash::Team& dash::BlockPattern< NumDimensions, Arrangement, IndexType >::team ( ) const
inlinenoexcept

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

Definition at line 1246 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::BlockPattern(), dash::BlockPattern< 1, Arrangement, IndexType >::is_local(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::is_local().

1247  {
1248  return *_team;
1249  }

◆ teamspec()

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

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

See also
Pattern Concept

Definition at line 1286 of file BlockPattern.h.

1287  {
1288  return _teamspec;
1289  }

◆ underfilled_blocksize()

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

Number of elements missing in the overflow block of given dimension compared to the regular blocksize (.

See also
blocksize(d)), with 0 <= underfilled_blocksize(d) < blocksize(d).

Definition at line 1339 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::block(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::block().

1341  {
1342  // Underflow blocksize = regular blocksize - overflow blocksize:
1343  auto ovf_blocksize = _memory_layout.extent(dimension) %
1344  blocksize(dimension);
1345  if (ovf_blocksize == 0) {
1346  return 0;
1347  } else {
1348  auto reg_blocksize = blocksize(dimension);
1349  return reg_blocksize - ovf_blocksize;
1350  }
1351  }
constexpr SizeType blocksize(dim_t dimension) const noexcept
Maximum number of elements in a single block in the given dimension.
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:412

◆ unit_at() [1/4]

template<dim_t NumDimensions, MemArrange Arrangement = ROW_MAJOR, typename IndexType = dash::default_index_t>
team_unit_t dash::BlockPattern< 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
viewspecView specification (offsets) to apply on coords

Definition at line 430 of file BlockPattern.h.

Referenced by dash::BlockPattern< 1, Arrangement, IndexType >::local(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::local(), dash::BlockPattern< 1, Arrangement, IndexType >::local_index(), and dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::unit_at().

435  {
436  // Apply viewspec offsets to coordinates:
437  std::array<IndexType, NumDimensions> vs_coords;
438  for (auto d = 0; d < NumDimensions; ++d) {
439  vs_coords[d] = coords[d] + viewspec.offset(0);
440  }
441  return unit_at(vs_coords);
442  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
Definition: BlockPattern.h:430
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const noexcept
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::BlockPattern< 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 449 of file BlockPattern.h.

451  {
452  std::array<IndexType, NumDimensions> unit_coords{};
453  // Coord to block coord to unit coord:
454  for (auto d = 0; d < NumDimensions; ++d) {
455  unit_coords[d] = (coords[d] / _blocksize_spec.extent(d))
456  % _teamspec.extent(d);
457  }
458  // Unit coord to unit id:
459  team_unit_t unit_id(_teamspec.at(unit_coords));
460  DASH_LOG_TRACE("BlockPattern.unit_at",
461  "coords", coords,
462  "> unit id", 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
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const noexcept
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::BlockPattern< 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 471 of file BlockPattern.h.

476  {
477  auto global_coords = _memory_layout.coords(global_pos);
478  return unit_at(global_coords, viewspec);
479  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
Definition: BlockPattern.h:430
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::BlockPattern< NumDimensions, Arrangement, IndexType >::unit_at ( IndexType  global_pos) const
inline

Convert given global linear index to its assigned unit id.

See also
blocksize()
blockspec()
blocksizespec()
Pattern Concept
Parameters
global_posGlobal linear element offset

Definition at line 490 of file BlockPattern.h.

493  {
494  auto global_coords = _memory_layout.coords(global_pos);
495  return unit_at(global_coords);
496  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
Definition: BlockPattern.h:430
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: