DASH  0.3.0
Pattern Concept

Concept of a distribution pattern of n-dimensional containers to units in a team. More...

Collaboration diagram for Pattern Concept:

Modules

 Pattern Properties
 Property system for specification and deduction of pattern types.
 

Classes

class  dash::BlockPattern< NumDimensions, Arrangement, IndexType >
 Defines how a list of global indices is mapped to single units within a Team. More...
 
class  dash::BlockPattern< 1, Arrangement, IndexType >
 Defines how a list of global indices is mapped to single units within a Team. More...
 
class  dash::CSRPattern< 1, Arrangement, IndexType >
 Irregular Pattern for Compressed Sparse Row Storage. More...
 
class  dash::DynamicPattern< 1, Arrangement, IndexType >
 Irregular dynamic pattern. More...
 
class  dash::LoadBalancePattern< NumDimensions, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >
 Irregular dynamic pattern. More...
 
class  dash::LoadBalancePattern< 1, CompBasedMeasure, MemBasedMeasure, Arrangement, IndexType >
 Irregular dynamic pattern. More...
 
class  dash::PatternIterator< PatternType, IndexType >
 {}Usage: More...
 
class  dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >
 Defines how a list of global indices is mapped to single units within a Team. More...
 
class  dash::ShiftTilePattern< NumDimensions, Arrangement, IndexType >
 Defines how a list of global indices is mapped to single units within a Team. More...
 
class  dash::TilePattern< NumDimensions, Arrangement, IndexType >
 Defines how a list of global indices is mapped to single units within a Team. More...
 

Functions

template<typename PartitioningTags , typename MappingTags , typename LayoutTags , class SizeSpecType >
TeamSpec< SizeSpecType::ndim::value, typename SizeSpecType::index_type > dash::make_team_spec (const SizeSpecType &sizespec, dash::Team &team=dash::Team::All(), typename SizeSpecType::size_type n_nodes=0, typename SizeSpecType::size_type n_numa_dom=0, typename SizeSpecType::size_type n_cores=0)
 {} More...
 
template<typename PartitioningTags , typename MappingTags , typename LayoutTags , class SizeSpecType , class TeamSpecType >
DistributionSpec< SizeSpecType::ndim::value > dash::make_distribution_spec (const SizeSpecType &sizespec, const TeamSpecType &teamspec)
 Generic Abstract Factory for instances of dash::DistributionSpec. More...
 
template<typename PartitioningTags = dash::pattern_partitioning_default_properties, typename MappingTags = dash::pattern_mapping_default_properties, typename LayoutTags = dash::pattern_layout_default_properties, class SizeSpecType , class TeamSpecType >
std::enable_if< !MappingTags::diagonal &&PartitioningTags::rectangular &&PartitioningTags::balanced &&!PartitioningTags::unbalanced &&LayoutTags::blocked, TilePattern< SizeSpecType::ndim::value, dash::ROW_MAJOR, typename SizeSpecType::index_type >>::type dash::make_pattern (const SizeSpecType &sizespec, const TeamSpecType &teamspec)
 Generic Abstract Factory for models of the Pattern concept. More...
 

Detailed Description

Concept of a distribution pattern of n-dimensional containers to units in a team.

Description

A pattern realizes a projection of a global index range to a local view:

Team Spec Container
[ unit 0 : unit 1 ] [ 0 1 2 3 4 5 ]
[ unit 1 : unit 0 ] [ 6 7 8 9 10 11 ]

This pattern would assign local indices to teams like this:

Team Local indices
unit 0 [ 0 1 2 9 10 11 ]
unit 1 [ 3 4 5 6 7 8 ]
Methods
Return Type Method Parameters Description
index local_at index[d] lp Linear local offset of the local point lp in local memory.
index global_at index[d] gp Global offset of the global point gp in the pattern's iteration order.
team_unit_t unit_at index[d] gp Unit id mapped to the element at global point p
global to local      
{unit,index} local index gi Unit and linear local offset at the global index gi
{unit,index[d]} local index[d] gp Unit and local coordinates at the global point gp
{unit,index} local_index index[d] gp Unit and local linear offset at the global point gp
point[d] local_coords index[d] gp Local coordinates at the global point gp
local to global      
index[d] global unit u, index[d] lp Local coordinates lp of unit u to global coordinates
index global_index unit u, index[d] lp Local coordinates lp of unit u to global index
index[d] global index[d] lp Local coordinates lp of active unit to global coordinates
index global unit u, index li Local offset li of unit u to global index
index global index li Local offset li of active unit to global index
blocks      
size[d] blockspec   Number of blocks in all dimensions.
size[d] local_blockspec   Number of local blocks in all dimensions.
index block_at index[d] gp Global index of block at global coordinates gp
viewspec block index gbi Offset and extent in global cartesian space of block at global block index gbi
viewspec local_block index lbi Offset and extent in global cartesian space of block at local block index lbi
viewspec local_block_local index lbi Offset and extent in local cartesian space of block at local block index lbi
locality test      
bool is_local index gi, unit u Whether the global index gi is mapped to unit u
bool is_local dim d, index o, unit u (proposed) Whether any element in dimension d at global offset o is local to unit u
size      
size capacity   Maximum number of elements in the pattern in total
size local_capacity   Maximum number of elements assigned to a single unit
size size   Number of elements indexed in the pattern
size local_size   Number of elements local to the calling unit
size[d] extents   Number of elements in the pattern in all dimension
size extent dim d Number of elements in the pattern in dimension d
size[d] local_extents unit u Number of elements local to the given unit, by dimension
size local_extent dim d Number of elements local to the calling unit in dimension d

Function Documentation

◆ make_distribution_spec()

template<typename PartitioningTags , typename MappingTags , typename LayoutTags , class SizeSpecType , class TeamSpecType >
DistributionSpec<SizeSpecType::ndim::value> dash::make_distribution_spec ( const SizeSpecType &  sizespec,
const TeamSpecType &  teamspec 
)

#include </tmp/tmporruphar/dash/include/dash/pattern/MakePattern.h>

Generic Abstract Factory for instances of dash::DistributionSpec.

Creates a DistributionSpec object from given pattern traits.

{}

Parameters
sizespecSize spec of cartesian space to be distributed by the pattern.
teamspecTeam spec containing layout of units mapped by the pattern.

Definition at line 246 of file MakePattern.h.

References dash::ndim().

Referenced by dash::make_pattern().

251 {
252  typedef typename SizeSpecType::size_type extent_t;
253 
254  DASH_LOG_TRACE("dash::make_distribution_spec()");
255  // Deduce number of dimensions from size spec:
256  const dim_t ndim = SizeSpecType::ndim::value;
257  // Array of distribution specifiers in all dimensions,
258  // e.g. { TILE(10), TILE(120) }:
259  std::array<dash::Distribution, ndim> distributions = {{ }};
260  extent_t min_block_extent = sizespec.size();
261  if (PartitioningTags::minimal) {
262  // Find minimal block size in minimal partitioning, initialize with
263  // pattern size (maximum):
264  for (auto d = 0; d < SizeSpecType::ndim::value; ++d) {
265  auto extent_d = sizespec.extent(d);
266  auto nunits_d = teamspec.extent(d);
267  auto blocksize_d = extent_d / nunits_d;
268  if (blocksize_d < min_block_extent) {
269  min_block_extent = blocksize_d;
270  }
271  }
272  DASH_LOG_TRACE("dash::make_distribution_spec",
273  "minimum block extent for square blocks:",
274  min_block_extent);
275  }
276  // Resolve balanced tile extents from size spec and team spec:
277  for (auto d = 0; d < SizeSpecType::ndim::value; ++d) {
278  auto extent_d = sizespec.extent(d);
279  auto nunits_d = teamspec.extent(d);
280  DASH_LOG_TRACE("dash::make_distribution_spec",
281  "d:", d,
282  "extent[d]:", extent_d,
283  "nunits[d]:", nunits_d);
284  auto nblocks_d = nunits_d;
285  if (MappingTags::diagonal || MappingTags::neighbor) {
286  // Diagonal and neighbor mapping properties require occurrence of every
287  // unit in any hyperplane. Use total number of units in every dimension:
288  nblocks_d = teamspec.size();
289  DASH_LOG_TRACE("dash::make_distribution_spec",
290  "diagonal or neighbor mapping",
291  "d", d, "nblocks_d", nblocks_d);
292  } else if (PartitioningTags::minimal) {
293  // Trying to assign one block per unit:
294  nblocks_d = nunits_d;
295  if (!MappingTags::balanced) {
296  // Unbalanced mapping, trying to use same block extent in all
297  // dimensions:
298  nblocks_d = extent_d / min_block_extent;
299  DASH_LOG_TRACE("dash::make_distribution_spec",
300  "minimal partitioning, mapping not balanced",
301  "d", d, "nblocks_d", nblocks_d);
302  }
303  } else if (MappingTags::balanced) {
304  // Balanced mapping, i.e. same number of blocks for every unit
305  if (nblocks_d % teamspec.extent(d) > 0) {
306  // Extent in this dimension is not a multiple of number of units,
307  // balanced mapping property cannot be satisfied:
309  "dash::make_distribution_spec: cannot distribute " <<
310  nblocks_d << " blocks to " <<
311  nunits_d << " units in dimension " << d);
312  }
313  }
314  auto tilesize_d = extent_d / nblocks_d;
315  DASH_LOG_TRACE("dash::make_distribution_spec",
316  "tile size in dimension", d, ":", tilesize_d);
317  if (PartitioningTags::balanced) {
318  // Balanced partitioning, i.e. same number of elements in every block
319  if (extent_d % tilesize_d > 0) {
320  // Extent in this dimension is not a multiple of tile size,
321  // balanced partitioning property cannot be satisfied:
323  "dash::make_distribution_spec: cannot distribute " <<
324  extent_d << " elements to " <<
325  nblocks_d << " blocks in dimension " << d);
326  }
327  }
328  if (LayoutTags::linear && LayoutTags::blocked) {
329  distributions[d] = dash::TILE(tilesize_d);
330  } else {
331  distributions[d] = dash::BLOCKCYCLIC(tilesize_d);
332  }
333  DASH_LOG_TRACE_VAR("dash::make_distribution_spec", distributions[d]);
334  }
335  // Make distribution spec from template- and run time parameters:
336  DASH_LOG_TRACE_VAR("dash::make_distribution_spec >", distributions);
337  dash::DistributionSpec<ndim> distspec(distributions);
338  DASH_LOG_TRACE_VAR("dash::make_distribution_spec >", distspec);
339  return distspec;
340 }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
constexpr dim_t ndim(const DimensionalType &d)
Definition: Dimensional.h:56
DistributionSpec describes distribution patterns of all dimensions,.
Definition: Dimensional.h:222

◆ make_pattern()

template<typename PartitioningTags = dash::pattern_partitioning_default_properties, typename MappingTags = dash::pattern_mapping_default_properties, typename LayoutTags = dash::pattern_layout_default_properties, class SizeSpecType , class TeamSpecType >
std::enable_if< !MappingTags::diagonal && PartitioningTags::rectangular && PartitioningTags::balanced && !PartitioningTags::unbalanced && LayoutTags::blocked, TilePattern<SizeSpecType::ndim::value, dash::ROW_MAJOR, typename SizeSpecType::index_type>>::type dash::make_pattern ( const SizeSpecType &  sizespec,
const TeamSpecType &  teamspec 
)

#include </tmp/tmporruphar/dash/include/dash/pattern/MakePattern.h>

Generic Abstract Factory for models of the Pattern concept.

Creates an instance of a Pattern model that satisfies the contiguos linearization property from given pattern traits.

{}

Returns
An instance of dash::TilePattern if the following constraints are specified: (Partitioning: minimal) and (Layout: blocked)
Parameters
sizespecSize spec of cartesian space to be distributed by the pattern.
teamspecTeam spec containing layout of units mapped by the pattern.
Examples:
ex.06.pattern-block-visualizer/main.cpp.

Definition at line 373 of file MakePattern.h.

References dash::make_distribution_spec(), and dash::ndim().

378 {
379  // Deduce number of dimensions from size spec:
380  const dim_t ndim = SizeSpecType::ndim::value;
381  // Deduce index type from size spec:
382  typedef typename SizeSpecType::index_type index_t;
384  DASH_LOG_TRACE("dash::make_pattern", PartitioningTags());
385  DASH_LOG_TRACE("dash::make_pattern", MappingTags());
386  DASH_LOG_TRACE("dash::make_pattern", LayoutTags());
387  DASH_LOG_TRACE_VAR("dash::make_pattern", sizespec.extents());
388  DASH_LOG_TRACE_VAR("dash::make_pattern", teamspec.extents());
389  // Make distribution spec from template- and run time parameters:
390  auto distspec =
392  PartitioningTags,
393  MappingTags,
394  LayoutTags,
395  SizeSpecType,
396  TeamSpecType
397  >(sizespec,
398  teamspec);
399  // Make pattern from template- and run time parameters:
400  pattern_t pattern(sizespec,
401  distspec,
402  teamspec);
403  return pattern;
404 }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
Defines how a list of global indices is mapped to single units within a Team.
Definition: TilePattern.h:47
DistributionSpec< SizeSpecType::ndim::value > make_distribution_spec(const SizeSpecType &sizespec, const TeamSpecType &teamspec)
Generic Abstract Factory for instances of dash::DistributionSpec.
Definition: MakePattern.h:246
constexpr dim_t ndim(const DimensionalType &d)
Definition: Dimensional.h:56

◆ make_team_spec()

template<typename PartitioningTags , typename MappingTags , typename LayoutTags , class SizeSpecType >
TeamSpec<SizeSpecType::ndim::value, typename SizeSpecType::index_type> dash::make_team_spec ( const SizeSpecType &  sizespec,
dash::Team team = dash::Team::All(),
typename SizeSpecType::size_type  n_nodes = 0,
typename SizeSpecType::size_type  n_numa_dom = 0,
typename SizeSpecType::size_type  n_cores = 0 
)

#include </tmp/tmporruphar/dash/include/dash/pattern/MakePattern.h>

{}

Parameters
sizespecSize spec of cartesian space to be distributed by the pattern.

Definition at line 185 of file MakePattern.h.

References dash::Team::All(), and dash::make_team_spec().

192 {
193  DASH_LOG_TRACE_VAR("dash::make_team_spec()", sizespec.extents());
194  DASH_LOG_TRACE_VAR("dash::make_team_spec", team.size());
195 
197  if (0 >= n_nodes) {
198  n_nodes = tloc.num_nodes();
199  if (0 >= n_nodes) { n_nodes = 1; }
200  }
201  if (0 >= n_numa_dom) {
202  n_numa_dom = tloc.domain().scope_domains(
203  dash::util::Locality::Scope::NUMA).size() / n_nodes;
204  if (0 >= n_numa_dom) {
205  n_numa_dom = tloc.domain().scope_domains(
206  dash::util::Locality::Scope::Package).size() / n_nodes;
207  }
208  if (0 >= n_numa_dom) { n_numa_dom = 1; }
209  }
210  if (0 >= n_cores) {
211  n_cores = tloc.num_cores();
212  if (0 >= n_cores) { n_cores = 1; }
213  }
214 
215  return make_team_spec<
216  PartitioningTags,
217  MappingTags,
218  LayoutTags,
219  SizeSpecType>(
220  sizespec,
221  team.size(),
222  n_nodes,
223  n_numa_dom,
224  n_cores);
225 }
TeamSpec< SizeSpecType::ndim::value, typename SizeSpecType::index_type > make_team_spec(const SizeSpecType &sizespec, dash::Team &team=dash::Team::All(), typename SizeSpecType::size_type n_nodes=0, typename SizeSpecType::size_type n_numa_dom=0, typename SizeSpecType::size_type n_cores=0)
{}
Definition: MakePattern.h:185
size_t size() const
The number of units in this team.
Definition: Team.h:498
Hierarchical locality domains of a specified team.
Definition: TeamLocality.h:61
static Team & All()
The invariant Team instance containing all available units.
Definition: Team.h:213