DASH  0.3.0
dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType > Class Template Reference

Irregular dynamic pattern. More...

#include <LoadBalancePattern.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::balanced, pattern_partitioning_tag::unbalanced, pattern_partitioning_tag::dynamicpartitioning_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::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

 LoadBalancePattern (const SizeSpec_t &sizespec, TeamLocality_t &team_loc)
 Constructor. More...
 
 LoadBalancePattern (const SizeSpec_t &sizespec, dash::Team &team=dash::Team::All())
 Constructor. More...
 
 LoadBalancePattern (const self_t &other)=default
 
 LoadBalancePattern (self_t &&other)=default
 
self_toperator= (const self_t &other)=default
 
self_toperator= (self_t &&other)=default
 
 LoadBalancePattern (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...
 
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 > &g_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 g_index) 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...
 
std::array< SizeType, NumDimensions > local_extents (team_unit_t unit) const
 The actual number of elements in this pattern that are local to the given unit, by dimension. 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 > &g_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 > &g_coords) const
 Converts global coordinates to their associated unit's respective local coordinates. More...
 
local_index_t local_index (const std::array< IndexType, NumDimensions > &g_coords) const
 Converts global coordinates to their associated unit and their respective local index. 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 > &l_coords) const
 Converts local coordinates of active unit to global coordinates. More...
 
IndexType global (team_unit_t unit, IndexType l_index) const
 Resolve an element's linear global index from the given unit's local index of that element. More...
 
IndexType global (IndexType l_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 > &l_coords) const
 Resolve an element's linear global index from a given unit's local coordinates of that element. More...
 
IndexType at (const std::array< IndexType, NumDimensions > &g_coords) const
 at More...
 
IndexType at (const std::array< IndexType, NumDimensions > &g_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 is_local (IndexType index, team_unit_t unit) const
 is_local More...
 
bool is_local (IndexType index) const
 Whether the given global index is local to the unit that created this pattern instance. More...
 
const BlockSpec_tblockspec () const
 block More...
 
index_type block_at (const std::array< index_type, NumDimensions > &g_coords) const
 Index of block at given global coordinates. More...
 
ViewSpec_t block (index_type g_block_index) const
 View spec (offset and extents) of block at global linear block index in cartesian element space. More...
 
ViewSpec_t local_block (index_type l_block_index) const
 View spec (offset and extents) of block at local linear block index in global cartesian element space. More...
 
ViewSpec_t local_block_local (index_type l_block_index) const
 View spec (offset and extents) of block at local linear block index in local cartesian element space. 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. 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...
 
const std::vector< double > & unit_cpu_weights () const
 
const std::vector< double > & unit_membw_weights () const
 
const std::vector< double > & unit_load_weights () const
 

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 = "LoadBalancePattern1D"
 

Detailed Description

template<typename CompBasedMeasure, typename MemBasedMeasure, MemArrange Arrangement, typename IndexType>
class dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >

Irregular dynamic pattern.

Specialization for 1-dimensional data.

Todo:
Should subclass or delegate to dash::CSRPattern as implementation is identical apart from comptation of _local_sizes.
Todo:
Performance measures used for load balance weights (CPU capacity, memory bandwidth, ...) should be policies, template parameters implementing well-defined concepts, so this class does not have to be re-implemented for every load-balance scheme. Using CompBasedMeasure, MemBasedMeasure for now.
Implemented concept:
Pattern Concept

Definition at line 203 of file LoadBalancePattern.h.

Member Typedef Documentation

◆ layout_properties

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
typedef pattern_layout_properties< pattern_layout_tag::blocked, pattern_layout_tag::linear > dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::layout_properties

Satisfiable properties in pattern property category Layout:

Definition at line 241 of file LoadBalancePattern.h.

◆ mapping_properties

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
typedef pattern_mapping_properties< pattern_mapping_tag::unbalanced > dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::mapping_properties

Satisfiable properties in pattern property category Mapping:

Definition at line 233 of file LoadBalancePattern.h.

◆ partitioning_properties

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
typedef pattern_partitioning_properties< pattern_partitioning_tag::minimal, pattern_partitioning_tag::rectangular, pattern_partitioning_tag::balanced, pattern_partitioning_tag::unbalanced, pattern_partitioning_tag::dynamic > dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::partitioning_properties

Satisfiable properties in pattern property category Partitioning:

Definition at line 228 of file LoadBalancePattern.h.

Constructor & Destructor Documentation

◆ LoadBalancePattern() [1/3]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::LoadBalancePattern ( const SizeSpec_t sizespec,
TeamLocality_t team_loc 
)
inline

Constructor.

Parameters
sizespecSize spec of the pattern.
team_locLocality hierarchy of the team.

Definition at line 293 of file LoadBalancePattern.h.

298  : _size(sizespec.size()),
299  _unit_cpu_weights(
300  CompBasedMeasure::unit_weights(team_loc)),
301  _unit_membw_weights(
302  MemBasedMeasure::unit_weights(team_loc)),
303  _unit_load_weights(
304  initialize_load_weights(
305  _unit_cpu_weights,
306  _unit_membw_weights)),
307  _local_sizes(
308  initialize_local_sizes(
309  sizespec.size(),
310  team_loc)),
311  _block_offsets(
312  initialize_block_offsets(
313  _local_sizes)),
314  _memory_layout(
315  std::array<SizeType, 1> {{ _size }}),
316  _blockspec(
317  initialize_blockspec(
318  _local_sizes)),
319  _distspec(dash::BLOCKED),
320  _team(&team_loc.team()),
321  _myid(_team->myid()),
322  _teamspec(*_team),
323  _nunits(_team->size()),
324  _local_size(
325  initialize_local_extent(
326  _team->myid(),
327  _local_sizes)),
328  _local_memory_layout(
329  std::array<SizeType, 1> {{ _local_size }}),
330  _local_capacity(
331  initialize_local_capacity(
332  _local_sizes))
333  {
334  DASH_LOG_TRACE("LoadBalancePattern()", "(sizespec, dist, team)");
335  DASH_ASSERT_EQ(
336  _local_sizes.size(), _nunits,
337  "Number of given local sizes " << _local_sizes.size() << " " <<
338  "does not match number of units" << _nunits);
339  initialize_local_range();
340  DASH_LOG_TRACE("LoadBalancePattern()", "LoadBalancePattern initialized");
341  }
SizeSpec_t sizespec() const
Size specification of the index space mapped by this pattern.
size_t size() const
The number of units in this team.
Definition: Team.h:498
constexpr SizeType size() const noexcept
The number of discrete elements within the space spanned by the coordinate.
Definition: Cartesian.h:164

◆ LoadBalancePattern() [2/3]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::LoadBalancePattern ( const SizeSpec_t sizespec,
dash::Team team = dash::Team::All() 
)
inline

Constructor.

Parameters
sizespecSize spec of the pattern.
teamTeam containing units to which this pattern maps its elements.

Definition at line 346 of file LoadBalancePattern.h.

351  : LoadBalancePattern(sizespec, TeamLocality_t(team))
352  { }
SizeSpec_t sizespec() const
Size specification of the index space mapped by this pattern.
LoadBalancePattern(const SizeSpec_t &sizespec, TeamLocality_t &team_loc)
Constructor.

◆ LoadBalancePattern() [3/3]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::LoadBalancePattern ( 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 366 of file LoadBalancePattern.h.

367  : LoadBalancePattern(static_cast<const self_t &>(other))
368  { }
LoadBalancePattern(const SizeSpec_t &sizespec, TeamLocality_t &team_loc)
Constructor.

Member Function Documentation

◆ at() [1/3]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::at ( const std::array< IndexType, NumDimensions > &  g_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 745 of file LoadBalancePattern.h.

747  {
748  return local_coords(g_coords)[0];
749  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.

◆ at() [2/3]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::at ( const std::array< IndexType, NumDimensions > &  g_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 758 of file LoadBalancePattern.h.

761  {
762  auto vs_coords = g_coords;
763  vs_coords[0] += viewspec.offset(0);
764  return local_coords(vs_coords)[0];
765  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.

◆ at() [3/3]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
template<typename ... Values>
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 775 of file LoadBalancePattern.h.

776  {
777  static_assert(
778  sizeof...(values) == NumDimensions-1,
779  "Wrong parameter number");
780  std::array<IndexType, NumDimensions> inputindex = {
781  value, (IndexType)values...
782  };
783  return at(inputindex);
784  }
IndexType at(const std::array< IndexType, NumDimensions > &g_coords) const
at

◆ block()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
ViewSpec_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::block ( index_type  g_block_index) const
inline

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

Definition at line 860 of file LoadBalancePattern.h.

862  {
863  DASH_LOG_DEBUG_VAR("LoadBalancePattern<1>.block >", g_block_index);
864  index_type offset = _block_offsets[g_block_index];
865  auto block_size = _local_sizes[g_block_index];
866  std::array<index_type, NumDimensions> offsets = {{ offset }};
867  std::array<size_type, NumDimensions> extents = {{ block_size }};
868  ViewSpec_t block_vs(offsets, extents);
869  DASH_LOG_DEBUG_VAR("LoadBalancePattern<1>.block >", block_vs);
870  return block_vs;
871  }
const std::array< SizeType, NumDimensions > & extents() const
Size specification of the index space mapped by this pattern.

◆ block_at()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
index_type dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 844 of file LoadBalancePattern.h.

847  {
848  DASH_LOG_TRACE_VAR("LoadBalancePattern.block_at()", g_coords);
849 
850  auto block_idx = static_cast<index_type>(unit_at(g_coords[0]));
851 
852  DASH_LOG_TRACE_VAR("LoadBalancePattern.block_at >", block_idx);
853  return block_idx;
854  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at

◆ blocksize()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
SizeType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 917 of file LoadBalancePattern.h.

920  {
921  return _local_capacity;
922  }

◆ blockspec()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
const BlockSpec_t& dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::blockspec ( ) const
inline

block

Cartesian arrangement of pattern blocks.

Definition at line 834 of file LoadBalancePattern.h.

835  {
836  return _blockspec;
837  }

◆ capacity()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::capacity ( ) const
inline

The maximum number of elements arranged in this pattern.

See also
Pattern Concept

Definition at line 981 of file LoadBalancePattern.h.

982  {
983  return _size;
984  }

◆ coords() [1/2]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
std::array<IndexType, NumDimensions> dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::coords ( IndexType  index) const
inline

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

See also
Pattern Concept

Definition at line 1050 of file LoadBalancePattern.h.

1052  {
1053  return std::array<IndexType, 1> {{ index }};
1054  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60

◆ coords() [2/2]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
std::array<IndexType, NumDimensions> dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 1062 of file LoadBalancePattern.h.

1065  {
1066  return std::array<IndexType, 1> {{ index + viewspec.offset(0) }};
1067  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60

◆ distspec()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
const DistributionSpec_t& dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::distspec ( ) const
inline

Distribution specification of this pattern.

Definition at line 1008 of file LoadBalancePattern.h.

1009  {
1010  return _distspec;
1011  }

◆ extent()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 499 of file LoadBalancePattern.h.

500  {
501  DASH_ASSERT_EQ(
502  0, dim,
503  "Wrong dimension for Pattern::local_extent. " <<
504  "Expected dimension = 0, got " << dim);
505  return _size;
506  }

◆ extents()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
const std::array<SizeType, NumDimensions>& dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::extents ( ) const
inline

Size specification of the index space mapped by this pattern.

See also
Pattern Concept

Definition at line 1028 of file LoadBalancePattern.h.

1029  {
1030  return std::array<SizeType, 1> {{ _size }};
1031  }

◆ global() [1/4]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
std::array<IndexType, NumDimensions> dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 661 of file LoadBalancePattern.h.

664  {
665  DASH_LOG_DEBUG_VAR("LoadBalancePattern.global()", unit);
666  DASH_LOG_DEBUG_VAR("LoadBalancePattern.global()", local_coords);
667  DASH_LOG_TRACE_VAR("LoadBalancePattern.global", _nunits);
668  if (_nunits < 2) {
669  return local_coords;
670  }
671  // Initialize global index with element phase (= local coords):
672  index_type glob_index = _block_offsets[unit] + local_coords[0];
673  DASH_LOG_TRACE_VAR("LoadBalancePattern.global >", glob_index);
674  return std::array<IndexType, 1> {{ glob_index }};
675  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.

◆ global() [2/4]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
std::array<IndexType, NumDimensions> dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::global ( const std::array< IndexType, NumDimensions > &  l_coords) const
inline

Converts local coordinates of active unit to global coordinates.

See also
Pattern Concept

Definition at line 682 of file LoadBalancePattern.h.

References dash::global().

684  {
685  return global(_team->myid(), l_coords);
686  }
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global

◆ global() [3/4]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::global ( team_unit_t  unit,
IndexType  l_index 
) const
inline

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

See also
at Inverse of local()
Pattern Concept

Definition at line 696 of file LoadBalancePattern.h.

699  {
700  return global(unit, std::array<IndexType, 1> {{ l_index }})[0];
701  }
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global

◆ global() [4/4]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::global ( IndexType  l_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 local()
Pattern Concept

Definition at line 711 of file LoadBalancePattern.h.

References dash::global().

713  {
714  return global(_team->myid(), std::array<IndexType, 1> {{ l_index }})[0];
715  }
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global

◆ global_index()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::global_index ( team_unit_t  unit,
const std::array< IndexType, NumDimensions > &  l_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 725 of file LoadBalancePattern.h.

728  {
729  auto g_index = global(unit, l_coords[0]);
730  return g_index;
731  }
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global

◆ is_local() [1/2]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
bool dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::is_local ( IndexType  index,
team_unit_t  unit 
) const
inline

is_local

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

See also
Pattern Concept

Definition at line 795 of file LoadBalancePattern.h.

798  {
799  DASH_LOG_TRACE_VAR("LoadBalancePattern.is_local()", index);
800  DASH_LOG_TRACE_VAR("LoadBalancePattern.is_local()", unit);
801  bool is_loc = index >= _block_offsets[unit] &&
802  (unit == _nunits-1 ||
803  index < _block_offsets[unit+1]);
804  DASH_LOG_TRACE_VAR("LoadBalancePattern.is_local >", is_loc);
805  return is_loc;
806  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60

◆ is_local() [2/2]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
bool dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 814 of file LoadBalancePattern.h.

816  {
817  auto unit = team().myid();
818  DASH_LOG_TRACE_VAR("LoadBalancePattern.is_local()", index);
819  DASH_LOG_TRACE_VAR("LoadBalancePattern.is_local", unit);
820  bool is_loc = index >= _block_offsets[unit] &&
821  (unit == _nunits-1 ||
822  index < _block_offsets[unit+1]);
823  DASH_LOG_TRACE_VAR("LoadBalancePattern.is_local >", is_loc);
824  return is_loc;
825  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
dash::Team & team() const
The Team containing the units to which this pattern&#39;s elements are mapped.

◆ lbegin()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::lbegin ( ) const
inline

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

See also
Pattern Concept

Definition at line 404 of file LoadBalancePattern.h.

405  {
406  return _lbegin;
407  }

◆ lend()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::lend ( ) const
inline

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

See also
Pattern Concept

Definition at line 414 of file LoadBalancePattern.h.

415  {
416  return _lend;
417  }

◆ local() [1/2]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
local_coords_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::local ( const std::array< IndexType, NumDimensions > &  g_coords) const
inline

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

NOTE: Same as local_index.

See also
Pattern Concept

Definition at line 587 of file LoadBalancePattern.h.

References dash::local().

589  {
590  local_index_t l_index = local(g_coords[0]);
591  local_coords_t l_coords;
592  l_coords.unit = l_index.unit;
593  l_coords.coords[0] = l_index.index;
594  return l_coords;
595  }
local_coords_t local(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit and its respective local coordinates.

◆ local() [2/2]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
local_index_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::local ( IndexType  g_index) const
inline

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

NOTE: Same as local_index.

See also
Pattern Concept

Definition at line 604 of file LoadBalancePattern.h.

606  {
607  DASH_LOG_TRACE_VAR("LoadBalancePattern.local()", g_index);
608  local_index_t l_index;
609 
610  for (team_unit_t unit_idx{0}; unit_idx < _nunits; ++unit_idx) {
611  if (g_index < _local_sizes[unit_idx]) {
612  l_index.unit = unit_idx;
613  l_index.index = g_index;
614  DASH_LOG_TRACE("LoadBalancePattern.local >",
615  "unit:", l_index.unit,
616  "index:", l_index.index);
617  return l_index;
618  }
619  g_index -= _local_sizes[unit_idx];
620  }
621  DASH_THROW(
623  "LoadBalancePattern.local: " <<
624  "global index " << g_index << " is out of bounds");
625  }
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

◆ local_at() [1/2]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 558 of file LoadBalancePattern.h.

563  {
564  return local_coords[0] + viewspec.offset(0);
565  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.

◆ local_at() [2/2]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 572 of file LoadBalancePattern.h.

575  {
576  return local_coords[0];
577  }
std::array< IndexType, NumDimensions > local_coords(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit&#39;s respective local coordinates.

◆ local_block()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
ViewSpec_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::local_block ( index_type  l_block_index) const
inline

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

Definition at line 877 of file LoadBalancePattern.h.

879  {
880  DASH_LOG_DEBUG_VAR("LoadBalancePattern<1>.local_block()", l_block_index);
881  DASH_ASSERT_EQ(
882  0, l_block_index,
883  "LoadBalancePattern always assigns exactly 1 block to a single unit");
884  index_type block_offset = _block_offsets[_team->myid()];
885  size_type block_size = _local_sizes[_team->myid()];
886  std::array<index_type, NumDimensions> offsets = {{ block_offset }};
887  std::array<size_type, NumDimensions> extents = {{ block_size }};
888  ViewSpec_t block_vs(offsets, extents);
889  DASH_LOG_DEBUG_VAR("LoadBalancePattern<1>.local_block >", block_vs);
890  return block_vs;
891  }
const std::array< SizeType, NumDimensions > & extents() const
Size specification of the index space mapped by this pattern.

◆ local_block_local()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
ViewSpec_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::local_block_local ( index_type  l_block_index) const
inline

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

Definition at line 897 of file LoadBalancePattern.h.

899  {
900  DASH_LOG_DEBUG_VAR("LoadBalancePattern<1>.local_block_local >",
901  l_block_index);
902  size_type block_size = _local_sizes[_team->myid()];
903  std::array<index_type, NumDimensions> offsets = {{ 0 }};
904  std::array<size_type, NumDimensions> extents = {{ block_size }};
905  ViewSpec_t block_vs(offsets, extents);
906  DASH_LOG_DEBUG_VAR("LoadBalancePattern<1>.local_block_local >", block_vs);
907  return block_vs;
908  }
const std::array< SizeType, NumDimensions > & extents() const
Size specification of the index space mapped by this pattern.

◆ local_capacity()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
SizeType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::local_capacity ( ) const
inline

Maximum number of elements assigned to a single unit.

See also
Pattern Concept

Definition at line 942 of file LoadBalancePattern.h.

943  {
944  return _local_capacity;
945  }

◆ local_coords()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
std::array<IndexType, NumDimensions> dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::local_coords ( const std::array< IndexType, NumDimensions > &  g_coords) const
inline

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

See also
Pattern Concept

Definition at line 633 of file LoadBalancePattern.h.

References dash::local().

635  {
636  local_index_t l_index = local(g_coords[0]);
637  return std::array<IndexType, 1> {{ l_index.index }};
638  }
local_coords_t local(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit and its respective local coordinates.

◆ local_extent()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 519 of file LoadBalancePattern.h.

520  {
521  DASH_ASSERT_EQ(
522  0, dim,
523  "Wrong dimension for Pattern::local_extent. " <<
524  "Expected dimension = 0, got " << dim);
525  return _local_size;
526  }

◆ local_extents()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
std::array<SizeType, NumDimensions> dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::local_extents ( team_unit_t  unit) 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 539 of file LoadBalancePattern.h.

541  {
542  DASH_LOG_DEBUG_VAR("LoadBalancePattern.local_extents()", unit);
543  DASH_LOG_DEBUG_VAR("LoadBalancePattern.local_extents >",
544  _local_sizes[unit]);
545  return std::array<SizeType, 1> {{ _local_sizes[unit] }};
546  }

◆ local_index()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
local_index_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::local_index ( const std::array< IndexType, NumDimensions > &  g_coords) const
inline

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

See also
Pattern Concept

Definition at line 646 of file LoadBalancePattern.h.

References dash::local().

648  {
649  return local(g_coords[0]);
650  }
local_coords_t local(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit and its respective local coordinates.

◆ local_size()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
SizeType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 957 of file LoadBalancePattern.h.

959  {
960  if (unit == UNDEFINED_TEAM_UNIT_ID) {
961  unit = _myid;
962  }
963  return _local_sizes[unit];
964  }
constexpr team_unit_t UNDEFINED_TEAM_UNIT_ID
Invalid local unit ID.
Definition: Types.h:341

◆ max_blocksize()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
SizeType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 932 of file LoadBalancePattern.h.

933  {
934  return _local_capacity;
935  }

◆ memory_order()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
static constexpr MemArrange dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::memory_order ( )
inlinestatic

Memory order followed by the pattern.

Definition at line 1072 of file LoadBalancePattern.h.

1073  {
1074  return Arrangement;
1075  }

◆ ndim()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
static constexpr dim_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::ndim ( )
inlinestatic

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

Definition at line 1080 of file LoadBalancePattern.h.

References dash::global(), dash::max_element(), dash::Team::size(), and dash::transform().

1081  {
1082  return 1;
1083  }

◆ num_units()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 971 of file LoadBalancePattern.h.

972  {
973  return _nunits;
974  }

◆ operator!=()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
bool dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::operator!= ( const self_t other) const
inline

Inquality comparison operator.

Parameters
otherPattern instance to compare for inequality

Definition at line 392 of file LoadBalancePattern.h.

395  {
396  return !(*this == other);
397  }

◆ operator==()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
bool dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::operator== ( const self_t other) const
inline

Equality comparison operator.

Parameters
otherPattern instance to compare for equality

Definition at line 373 of file LoadBalancePattern.h.

376  {
377  if (this == &other) {
378  return true;
379  }
380  // no need to compare all members as most are derived from
381  // constructor arguments.
382  return(
383  _size == other._size &&
384  _local_sizes == other._local_sizes &&
385  _teamspec == other._teamspec
386  );
387  }

◆ size()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
IndexType dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::size ( ) const
inline

The number of elements arranged in this pattern.

See also
Pattern Concept

Definition at line 991 of file LoadBalancePattern.h.

992  {
993  return _size;
994  }

◆ sizespec()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
SizeSpec_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::sizespec ( ) const
inline

Size specification of the index space mapped by this pattern.

See also
Pattern Concept

Definition at line 1018 of file LoadBalancePattern.h.

1019  {
1020  return SizeSpec_t(std::array<SizeType, 1> {{ _size }});
1021  }

◆ team()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
dash::Team& dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::team ( ) const
inline

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

Definition at line 1000 of file LoadBalancePattern.h.

1001  {
1002  return *_team;
1003  }

◆ teamspec()

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
const TeamSpec_t& dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 1039 of file LoadBalancePattern.h.

1040  {
1041  return _teamspec;
1042  }

◆ unit_at() [1/4]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
team_unit_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 428 of file LoadBalancePattern.h.

433  {
434  return unit_at(coords[0] + viewspec.offset(0));
435  }
std::array< IndexType, NumDimensions > coords(IndexType index) const
Convert given global linear offset (index) to global cartesian coordinates.
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at

◆ unit_at() [2/4]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
team_unit_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::unit_at ( const std::array< IndexType, NumDimensions > &  g_coords) const
inline

Convert given coordinate in pattern to its assigned unit id.

See also
Pattern Concept

Definition at line 442 of file LoadBalancePattern.h.

444  {
445  return unit_at(g_coords[0]);
446  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at

◆ unit_at() [3/4]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
team_unit_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, 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 453 of file LoadBalancePattern.h.

458  {
459  return unit_at(global_pos + viewspec.offset(0));
460  }
team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at

◆ unit_at() [4/4]

template<typename CompBasedMeasure , typename MemBasedMeasure , MemArrange Arrangement, typename IndexType >
team_unit_t dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >::unit_at ( IndexType  g_index) const
inline

Convert given global linear index to its assigned unit id.

See also
Pattern Concept
Parameters
g_indexGlobal linear element offset

Definition at line 467 of file LoadBalancePattern.h.

470  {
471  DASH_LOG_TRACE_VAR("LoadBalancePattern.unit_at()", g_index);
472 
473  for (team_unit_t unit_idx{0}; unit_idx < _nunits; ++unit_idx) {
474  if (g_index < _local_sizes[unit_idx]) {
475  DASH_LOG_TRACE_VAR("LoadBalancePattern.unit_at >", unit_idx);
476  return unit_idx;
477  }
478  g_index -= _local_sizes[unit_idx];
479  }
480  DASH_THROW(
482  "LoadBalancePattern.unit_at: " <<
483  "global index " << g_index << " is out of bounds");
484  }
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

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