DASH  0.3.0
dash::halo::HaloBlock< ElementT, PatternT, GlobMemT > Class Template Reference

Takes the local part of the NArray and builds halo and boundary regions. More...

#include <Halo.h>

Public Types

using Element_t = ElementT
 
using Pattern_t = PatternT
 
using GlobMem_t = GlobMemT
 
using GlobBoundSpec_t = GlobalBoundarySpec< NumDimensions >
 
using pattern_size_t = typename PatternT::size_type
 
using ViewSpec_t = typename PatternT::viewspec_type
 
using BoundaryViews_t = std::vector< ViewSpec_t >
 
using HaloSpec_t = HaloSpec< NumDimensions >
 
using RegionVector_t = std::vector< Region_t >
 
using ElementCoords_t = std::array< pattern_index_t, NumDimensions >
 
using HaloExtsMax_t = typename HaloSpec_t::HaloExtsMax_t
 
using RegIndDepVec_t = typename RegionCoords_t::RegIndDepVec_t
 
using BlockEnv_t = BlockEnvironment< Pattern_t >
 

Public Member Functions

 HaloBlock (GlobMem_t &globmem, const PatternT &pattern, const ViewSpec_t &view, const HaloSpec_t &halo_reg_spec, const GlobBoundSpec_t &bound_spec)
 Constructor. More...
 
 HaloBlock (const Self_t &other)=default
 Copy constructor. More...
 
Self_toperator= (const Self_t &other)=default
 Assignment operator. More...
 
const Pattern_t & pattern () const
 The pattern instance that created the encapsulated block. More...
 
const GlobMem_t & globmem () const
 The global memory instance that created the encapsulated block. More...
 
const GlobBoundSpec_tglobal_boundary_spec () const
 Returns the GlobalBoundarySpec used by the HaloBlock instance. More...
 
const HaloSpec_thalo_spec () const
 Returns used HaloSpec. More...
 
BlockEnv_t block_env ()
 Returns the environment information object BlockEnvironment. More...
 
const BlockEnv_tblock_env () const
 Returns the environment information object BlockEnvironment. More...
 
const Region_thalo_region (const region_index_t index) const
 Returns a specific halo region and nullptr if no region exists. More...
 
const RegionVector_t & halo_regions () const
 Returns all halo regions. More...
 
const Region_tboundary_region (const region_index_t index) const
 Returns a specific region and nullptr if no region exists. More...
 
const RegionVector_t & boundary_regions () const
 Returns all boundary regions. More...
 
RegIndDepVec_t boundary_dependencies (region_index_t index) const
 
const ViewSpec_t & view () const
 Returns the initial global ViewSpec. More...
 
const ViewSpec_t & view_local () const
 Returns the initial local ViewSpec. More...
 
const ViewSpec_t & view_inner_with_boundaries () const
 Returns a local ViewSpec that combines the boundary and inner view. More...
 
const ViewSpec_t & view_inner () const
 Returns the inner ViewSpec with local offsets depending on the used HaloSpec. More...
 
const BoundaryViews_t & boundary_views () const
 Returns a set of local views that contains all boundary elements. More...
 
pattern_size_t halo_size () const
 Number of halo elements. More...
 
pattern_size_t boundary_size () const
 Number of boundary elements (no duplicates) More...
 
region_index_t index_at (const ViewSpec_t &view, const ElementCoords_t &coords) const
 Returns the region index belonging to the given coordinates and ViewSpec. More...
 

Static Public Member Functions

static constexpr dim_t ndim ()
 

Detailed Description

template<typename ElementT, typename PatternT, typename GlobMemT>
class dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >

Takes the local part of the NArray and builds halo and boundary regions.

Definition at line 827 of file Halo.h.

Constructor & Destructor Documentation

◆ HaloBlock() [1/2]

template<typename ElementT, typename PatternT, typename GlobMemT>
dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::HaloBlock ( GlobMem_t &  globmem,
const PatternT &  pattern,
const ViewSpec_t &  view,
const HaloSpec_t halo_reg_spec,
const GlobBoundSpec_t bound_spec 
)
inline

Constructor.

Definition at line 859 of file Halo.h.

References dash::ndim().

862  : _globmem(globmem), _pattern(pattern), _view(view),
863  _halo_reg_spec(halo_reg_spec), _view_local(_view.extents()),
864  _glob_bound_spec(bound_spec),
865  _block_env(pattern, _halo_reg_spec, _view, _glob_bound_spec) {
866 
867  // TODO put functionallity to HaloSpec
868  _halo_regions.reserve(_halo_reg_spec.num_regions());
869  _boundary_regions.reserve(_halo_reg_spec.num_regions());
870 
871  _view_inner = _block_env.view_inner();
872  _view_inner_with_boundaries = _block_env.view_inner_boundary();
873 
874  /*
875  * Setup for all halo and boundary regions and properties like:
876  * is the region a global boundary region and is the region custom or not
877  */
878 
879  auto bnd_check = _block_env.boundary_region_check(halo_reg_spec);
880  for(region_index_t r = 0; r < RegionsMax; ++r) {
881  const auto& env_reg_info = _block_env.info(r);
882  const auto& spec = _halo_reg_spec.specs()[r];
883 
884  _boundary_views.push_back(env_reg_info.bnd_reg_data.view);
885  _size_bnd_elems += env_reg_info.bnd_reg_data.view.size();
886 
887  auto halo_extent = spec.extent();
888  if(!halo_extent) {
889  continue;
890  }
891 
892  if(env_reg_info.halo_reg_data.valid) {
893  _halo_regions.push_back(
894  Region_t(spec, env_reg_info.halo_reg_data.view,
895  _globmem, _pattern, env_reg_info));
896  _halo_reg_mapping[r] = &_halo_regions.back();
897  _size_halo_elems += env_reg_info.halo_reg_data.view.size();
898  } else {
899  _halo_regions.push_back(
900  Region_t(spec, ViewSpec_t(),
901  _globmem, _pattern, env_reg_info));
902  _halo_reg_mapping[r] = &_halo_regions.back();
903  }
904  auto bnd_reg_data = bnd_check.region_data_duplicate(spec, false);
905  _boundary_regions.push_back(
906  Region_t(spec, bnd_reg_data.view,
907  _globmem, _pattern, env_reg_info));
908  _boundary_reg_mapping[r] = &_boundary_regions.back();
909  }
910  }
const Pattern_t & pattern() const
The pattern instance that created the encapsulated block.
Definition: Halo.h:929
const ViewSpec_t & view() const
Returns the initial global ViewSpec.
Definition: Halo.h:999
constexpr region_size_t num_regions() const
Number of specified regions.
Definition: Halo.h:136
const Specs_t & specs() const
Used RegionSpec instance.
Definition: Halo.h:141
const GlobMem_t & globmem() const
The global memory instance that created the encapsulated block.
Definition: Halo.h:934

◆ HaloBlock() [2/2]

template<typename ElementT, typename PatternT, typename GlobMemT>
dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::HaloBlock ( const Self_t other)
default

Copy constructor.

Member Function Documentation

◆ block_env() [1/2]

template<typename ElementT, typename PatternT, typename GlobMemT>
BlockEnv_t dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::block_env ( )
inline

Returns the environment information object BlockEnvironment.

Definition at line 951 of file Halo.h.

951 { return _block_env; }

◆ block_env() [2/2]

template<typename ElementT, typename PatternT, typename GlobMemT>
const BlockEnv_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::block_env ( ) const
inline

Returns the environment information object BlockEnvironment.

Definition at line 956 of file Halo.h.

956 { return _block_env; }

◆ boundary_region()

template<typename ElementT, typename PatternT, typename GlobMemT>
const Region_t* dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::boundary_region ( const region_index_t  index) const
inline

Returns a specific region and nullptr if no region exists.

Definition at line 974 of file Halo.h.

References dash::index().

974  {
975  return _boundary_reg_mapping[index];
976  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60

◆ boundary_regions()

template<typename ElementT, typename PatternT, typename GlobMemT>
const RegionVector_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::boundary_regions ( ) const
inline

Returns all boundary regions.

Between regions element reoccurences are possible.

Definition at line 982 of file Halo.h.

References dash::index().

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at(), and dash::halo::HaloMatrixWrapper< MatrixT, SigReady >::set_custom_halos().

982 { return _boundary_regions; }

◆ boundary_size()

template<typename ElementT, typename PatternT, typename GlobMemT>
pattern_size_t dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::boundary_size ( ) const
inline

Number of boundary elements (no duplicates)

Definition at line 1033 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

1033 { return _size_bnd_elems; }

◆ boundary_views()

template<typename ElementT, typename PatternT, typename GlobMemT>
const BoundaryViews_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::boundary_views ( ) const
inline

Returns a set of local views that contains all boundary elements.

No duplicated elements included.

Definition at line 1023 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

1023 { return _boundary_views; }

◆ global_boundary_spec()

template<typename ElementT, typename PatternT, typename GlobMemT>
const GlobBoundSpec_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::global_boundary_spec ( ) const
inline

Returns the GlobalBoundarySpec used by the HaloBlock instance.

Definition at line 939 of file Halo.h.

939  {
940  return _glob_bound_spec;
941  }

◆ globmem()

template<typename ElementT, typename PatternT, typename GlobMemT>
const GlobMem_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::globmem ( ) const
inline

The global memory instance that created the encapsulated block.

Definition at line 934 of file Halo.h.

934 { return _globmem; }

◆ halo_region()

template<typename ElementT, typename PatternT, typename GlobMemT>
const Region_t* dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::halo_region ( const region_index_t  index) const
inline

Returns a specific halo region and nullptr if no region exists.

Definition at line 962 of file Halo.h.

References dash::index().

962  {
963  return _halo_reg_mapping[index];
964  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60

◆ halo_regions()

template<typename ElementT, typename PatternT, typename GlobMemT>
const RegionVector_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::halo_regions ( ) const
inline

Returns all halo regions.

Definition at line 969 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

969 { return _halo_regions; }

◆ halo_size()

template<typename ElementT, typename PatternT, typename GlobMemT>
pattern_size_t dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::halo_size ( ) const
inline

Number of halo elements.

Definition at line 1028 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

1028 { return _size_halo_elems; }

◆ halo_spec()

template<typename ElementT, typename PatternT, typename GlobMemT>
const HaloSpec_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::halo_spec ( ) const
inline

Returns used HaloSpec.

Definition at line 946 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

946 { return _halo_reg_spec; }

◆ index_at()

template<typename ElementT, typename PatternT, typename GlobMemT>
region_index_t dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at ( const ViewSpec_t &  view,
const ElementCoords_t &  coords 
) const
inline

Returns the region index belonging to the given coordinates and ViewSpec.

Definition at line 1038 of file Halo.h.

References dash::begin(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::boundary_regions(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::boundary_size(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::boundary_views(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::halo_regions(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::halo_size(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::halo_spec(), dash::index(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::view(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::view_inner(), dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::view_inner_with_boundaries(), and dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::view_local().

Referenced by dash::halo::HaloMatrixWrapper< MatrixT, SigReady >::stencil_operator().

1039  {
1040  using signed_extent_t = typename std::make_signed<pattern_size_t>::type;
1041  const auto& extents = view.extents();
1042  const auto& offsets = view.offsets();
1043 
1044  region_index_t index = 0;
1045  if(coords[0] >= offsets[0]
1046  && coords[0] < static_cast<signed_extent_t>(extents[0]))
1047  index = 1;
1048  else if(coords[0] >= static_cast<signed_extent_t>(extents[0]))
1049  index = 2;
1050  for(auto d = 1; d < NumDimensions; ++d) {
1051  if(coords[d] < offsets[d])
1052  index *= REGION_INDEX_BASE;
1053  else if(coords[d] < static_cast<signed_extent_t>(extents[d]))
1054  index = 1 + index * REGION_INDEX_BASE;
1055  else
1056  index = 2 + index * REGION_INDEX_BASE;
1057  }
1058 
1059  return index;
1060  }
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
Definition: Iterator.h:60
const ViewSpec_t & view() const
Returns the initial global ViewSpec.
Definition: Halo.h:999

◆ operator=()

template<typename ElementT, typename PatternT, typename GlobMemT>
Self_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::operator= ( const Self_t other)
default

Assignment operator.

◆ pattern()

template<typename ElementT, typename PatternT, typename GlobMemT>
const Pattern_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::pattern ( ) const
inline

The pattern instance that created the encapsulated block.

Definition at line 929 of file Halo.h.

929 { return _pattern; }

◆ view()

template<typename ElementT, typename PatternT, typename GlobMemT>
const ViewSpec_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::view ( ) const
inline

Returns the initial global ViewSpec.

Definition at line 999 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

999 { return _view; }

◆ view_inner()

template<typename ElementT, typename PatternT, typename GlobMemT>
const ViewSpec_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::view_inner ( ) const
inline

Returns the inner ViewSpec with local offsets depending on the used HaloSpec.

Definition at line 1017 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

1017 { return _view_inner; }

◆ view_inner_with_boundaries()

template<typename ElementT, typename PatternT, typename GlobMemT>
const ViewSpec_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::view_inner_with_boundaries ( ) const
inline

Returns a local ViewSpec that combines the boundary and inner view.

Definition at line 1009 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

1009  {
1010  return _view_inner_with_boundaries;
1011  }

◆ view_local()

template<typename ElementT, typename PatternT, typename GlobMemT>
const ViewSpec_t& dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::view_local ( ) const
inline

Returns the initial local ViewSpec.

Definition at line 1004 of file Halo.h.

Referenced by dash::halo::HaloBlock< ElementT, PatternT, GlobMemT >::index_at().

1004 { return _view_local; }

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