1 #ifndef DASH__HALO__HALO_H__ 2 #define DASH__HALO__HALO_H__ 4 #include <dash/internal/Logging.h> 7 #include <dash/halo/Types.h> 8 #include <dash/halo/Region.h> 9 #include <dash/halo/Stencil.h> 17 using namespace internal;
22 template <dim_t NumDimensions>
35 for(
dim_t i = 0; i < NumDimensions; ++i) {
36 this->_values[i] = BoundaryProp::NONE;
42 template <
typename... Values>
47 template <dim_t NumDimensions>
48 std::ostream& operator<<(std::ostream& os,
50 os <<
"dash::halo::GlobalBoundarySpec<" << NumDimensions <<
">" 52 for(
auto d = 0; d < NumDimensions; ++d) {
69 template <dim_t NumDimensions>
74 static constexpr
auto RegionsMax = NumRegionsMax<NumDimensions>;
78 using Specs_t = std::array<RegionSpec_t, RegionsMax>;
79 using region_extent_t =
typename RegionSpec_t::region_extent_t;
80 using HaloExtsMaxPair_t = std::pair<region_extent_t, region_extent_t>;
81 using HaloExtsMax_t = std::array<HaloExtsMaxPair_t, NumDimensions>;
84 constexpr
HaloSpec(
const Specs_t& specs) : _specs(specs) {}
86 template <
typename StencilSpecT>
89 read_stencil_points(stencil_spec);
93 HaloSpec(
const StencilSpecT& stencil_spec,
const Args&... stencil_specs)
94 : HaloSpec(stencil_specs...) {
95 read_stencil_points(stencil_spec);
98 template <
typename... ARGS>
99 HaloSpec(
const RegionSpec_t& region_spec,
const ARGS&... args) {
101 std::array<
RegionSpec_t,
sizeof...(ARGS) + 1> tmp{ region_spec, args... };
102 for(
auto& spec : tmp) {
103 auto& current_spec = _specs[spec.index()];
104 if(current_spec.extent() == 0 && spec.extent() > 0) {
108 if(current_spec.extent() < spec.extent()) {
110 set_max_halo_dist(current_spec.coords(), current_spec.extent());
115 HaloSpec(
const Self_t& other) { _specs = other._specs; }
117 static constexpr
dim_t ndim() {
return NumDimensions; }
123 return _specs[
index];
129 constexpr region_extent_t
extent(
const region_index_t
index)
const {
130 return _specs[
index].extent();
136 constexpr region_size_t
num_regions()
const {
return _num_regions; }
141 const Specs_t&
specs()
const {
return _specs; }
147 return _halo_extents_max[dim];
156 void init_region_specs() {
157 for(region_index_t r = 0; r < RegionsMax; ++r) {
166 template <
typename StencilSpecT>
167 void read_stencil_points(
const StencilSpecT& stencil_spec) {
168 for(
const auto& stencil : stencil_spec.
specs()) {
169 auto stencil_combination = stencil;
171 set_region_spec(stencil_combination);
172 while(next_region(stencil, stencil_combination)) {
173 set_region_spec(stencil_combination);
181 template <
typename StencilPo
intT>
182 void set_region_spec(
const StencilPointT& stencil) {
185 auto max = stencil.max();
186 auto reg_extent = _specs[
index].extent();
187 if(reg_extent == 0 &&
max > 0) {
191 if(
max > reg_extent) {
193 set_max_halo_dist(_specs[
index].coords(),
max);
202 template <
typename StencilPo
intT>
203 bool next_region(
const StencilPointT& stencil,
204 StencilPointT& stencil_combination) {
205 for(
dim_t d = 0; d < NumDimensions; ++d) {
208 stencil_combination[d] = (stencil_combination[d] == 0) ? stencil[d] : 0;
209 if(stencil_combination[d] == 0) {
218 for(
dim_t d = 0; d < NumDimensions; ++d) {
219 if(reg_coords[d] == 1) {
223 if(reg_coords[d] < 1) {
224 _halo_extents_max[d].first = std::max(_halo_extents_max[d].
first, extent);
227 _halo_extents_max[d].second = std::max(_halo_extents_max[d].
second, extent);
233 HaloExtsMax_t _halo_extents_max{};
234 region_size_t _num_regions{ 0 };
238 template <dim_t NumDimensions>
239 std::ostream& operator<<(std::ostream& os, const HaloSpec<NumDimensions>& hs) {
240 os <<
"dash::halo::HaloSpec<" << NumDimensions <<
">(";
242 for(
const auto& region_spec : hs.specs()) {
243 if(region_spec.extent() > 0) {
248 os <<
"," << region_spec;
252 os <<
"; number region: " << hs.num_regions();
258 template<
typename ViewSpecT>
264 using EnvRegInfo_t = EnvironmentRegionInfo<ViewSpecT>;
265 using RegionBorders_t =
typename EnvRegInfo_t::RegionBorders_t;
266 using RegionData_t =
typename EnvRegInfo_t::RegionData_t;
268 using MaxDistPair_t = std::pair<region_extent_t, region_extent_t>;
269 using MaxDist_t = std::array<MaxDistPair_t, NumDimensions>;
270 using BlockViewSpec_t = BlockViewSpec<ViewSpecT>;
275 : _view(&view), _max_dist(max_dist) {
276 std::array<BS, NumDimensions> to_small;
278 const auto& view_extents = _view->extents();
280 for(
dim_t d = 0; d < NumDimensions; ++d) {
281 auto minmax_dim = max_dist[d];
282 auto dist = minmax_dim.first + minmax_dim.second;
284 to_small[d] = BS::BIGGER;
285 if(view_extents[d] <= dist) {
286 to_small[d] = (view_extents[d] > minmax_dim.first) ? BS::EQUALS_LESS : BS::PRE_ONLY;
290 for(
int d = 0; d < NumDimensions; ++d) {
291 bool test_small =
false;
292 for(
int d_tmp = 0; d_tmp < d; ++d_tmp) {
293 if(to_small[d_tmp] != BS::BIGGER) {
300 if(borders[d].
first && glob_bnd_spec[d] == BoundaryProp::NONE) {
301 _valid_main[d].first = {
false, REASON::BORDER};
303 _valid_main[d].first = {
false, REASON::TO_SMALL};
306 if(borders[d].
second && glob_bnd_spec[d] == BoundaryProp::NONE) {
307 _valid_main[d].second = {
false, REASON::BORDER};
309 _valid_main[d].second = {
false, REASON::TO_SMALL};
313 if(borders[d].
first && glob_bnd_spec[d] == BoundaryProp::NONE) {
314 _valid_main[d].first = {
false, REASON::BORDER};
316 _valid_main[d].first = {
true, REASON::NONE};
319 if(borders[d].
second && glob_bnd_spec[d] == BoundaryProp::NONE) {
320 _valid_main[d].second = {
false, REASON::BORDER};
322 if(_valid_main[d].
first.valid && to_small[d] == BS::PRE_ONLY) {
323 _valid_main[d].second = {
false, REASON::TO_SMALL};
325 _valid_main[d].second = {
true, REASON::NONE};
331 BlockViewSpec_t block_views() {
333 auto offsets_inner = _view->offsets();
334 auto extents_inner = _view->extents();
335 auto offsets_inner_bnd = _view->offsets();
336 auto extents_inner_bnd = _view->extents();
338 for(
int d = 0; d < NumDimensions; ++d) {
340 offsets_inner[d] = _max_dist[d].first;
341 DASH_ASSERT_MSG(extents_inner[d] >= _max_dist[d].
first,
342 "Inner view to small for the given Stencil.");
343 auto sum_dist = _max_dist[d].first + _max_dist[d].second;
344 extents_inner[d] -= (extents_inner[d] < sum_dist) ? _max_dist[d].first : sum_dist;
346 offsets_inner_bnd[d] = 0;
348 if(!_valid_main[d].first.valid) {
349 offsets_inner_bnd[d] = _max_dist[d].first;
350 extents_inner_bnd[d] -= _max_dist[d].first;
353 if(!_valid_main[d].
second.valid) {
354 if(extents_inner_bnd[d] >= _max_dist[d].
second) {
355 extents_inner_bnd[d] -= _max_dist[d].second;
360 return {ViewSpecT(offsets_inner, extents_inner), ViewSpecT(offsets_inner_bnd, extents_inner_bnd)};
365 auto& coords = region.
coords();
366 for(
int d = 0; d < NumDimensions; ++d) {
367 if(coords[d] == 0 && !_valid_main[d].
first.valid) {
371 if(coords[d] > 1 && !_valid_main[d].
second.valid) {
379 RegionData_t region_data(
const RegionSpec_t& region,
bool local_offsets =
true) {
381 if(region.
index() == CenterIndex) {
382 return {ViewSpecT(),
false};
385 RegionData_t region_data;
386 auto& coords = region.
coords();
387 for(
dim_t d = 0; d < NumDimensions; ++d) {
388 if(coords[d] == 0 && !_valid_main[d].
first.valid) {
389 return {ViewSpecT(),
false};
392 if(coords[d] > 1 && !_valid_main[d].
second.valid) {
393 return {ViewSpecT(),
false};
397 auto offsets = _view->offsets();
398 auto extents = _view->extents();
401 std::fill(offsets.begin(), offsets.end(), 0);
404 for(
dim_t d = 0; d < NumDimensions; ++d) {
412 if(_valid_main[d].
first.valid ||
413 (!_valid_main[d].first.valid && _valid_main[d].first.reason == REASON::BORDER)) {
414 extents[d] -= _max_dist[d].first;
415 offsets[d] += _max_dist[d].first;
418 if(_valid_main[d].
second.valid ||
419 (!_valid_main[d].second.valid && _valid_main[d].second.reason == REASON::BORDER)) {
420 extents[d] -= _max_dist[d].second;
425 offsets[d] = extents[d] - _max_dist[d].second;
429 region_data.valid =
true;
430 region_data.view = ViewSpecT(offsets, extents);
434 RegionData_t region_data_duplicate(
const RegionSpec_t& region,
bool local_offsets =
true) {
435 if(region.
extent() == 0) {
436 return {ViewSpecT(),
false};
439 RegionData_t region_data;
440 auto& coords = region.
coords();
441 for(
dim_t d = 0; d < NumDimensions; ++d) {
442 if(coords[d] == 0 && !_valid_main[d].
first.valid) {
443 return {ViewSpecT(),
false};
446 if(coords[d] > 1 && !_valid_main[d].
second.valid) {
447 return {ViewSpecT(),
false};
451 auto offsets = _view->offsets();
452 auto extents = _view->extents();
455 std::fill(offsets.begin(), offsets.end(), 0);
459 for(
dim_t d = 0; d < NumDimensions; ++d) {
462 extents[d] = region.
extent();
470 offsets[d] = extents[d] - _max_dist[d].second;
471 extents[d] = region.
extent();
474 region_data.valid =
true;
475 region_data.view = ViewSpecT(offsets, extents);
498 struct valid_region {
506 const ViewSpecT* _view;
507 const MaxDist_t _max_dist;
508 std::array<std::pair<valid_region, valid_region>,NumDimensions> _valid_main;
512 template<
typename PatternT>
515 static constexpr
auto RegionsMax = NumRegionsMax<NumDimensions>;
518 using ViewSpec_t =
typename PatternT::viewspec_type;
521 using RegionData_t = RegionData<ViewSpec_t>;
522 using BndInfos_t = std::array<RegionData_t, RegionsMax>;
523 using EnvRegInfo_t = EnvironmentRegionInfo<ViewSpec_t>;
524 using BlockEnv_t = std::array<EnvRegInfo_t, RegionsMax>;
526 using HaloExtsMaxPair_t =
typename HaloSpec_t::HaloExtsMaxPair_t;
527 using HaloExtsMax_t =
typename HaloSpec_t::HaloExtsMax_t;
533 using RegionBorders_t =
typename EnvRegInfo_t::RegionBorders_t;
535 using RegIdxMain_t = std::array<typename RegionCoords_t::RegIndexDim_t, NumDimensions>;
536 using BlockViewSpec_t = BlockViewSpec<ViewSpec_t>;
541 : _view(&view_glob), _glob_bnd_spec(&glob_bound_spec) {
542 set_environment(pattern, halo_spec);
549 template <
typename StencilPo
intT, std::
size_t NumStencilPo
ints>
552 HaloExtsMax_t max_dist{};
553 for(
dim_t d = 0; d < NumDimensions; ++d) {
557 return BndRegCheck_t(*_view, max_dist, *_glob_bnd_spec, _borders);
560 auto info_dim(
dim_t dim)
const {
561 return std::make_pair(std::ref(_block_env[_reg_idx_main[dim].
first]), std::ref(_block_env[_reg_idx_main[dim].
second]));
564 const EnvRegInfo_t& info(region_index_t region_index)
const {
565 return _block_env[region_index];
568 const BlockEnv_t& info()
const {
572 const auto& view_inner()
const {
573 return _block_views.inner;
576 const auto& view_inner_boundary()
const {
577 return _block_views.inner_bound;
580 const auto& views()
const {
586 void set_environment(
const PatternT& pattern,
const HaloSpec_t& halo_spec) {
587 const auto& view_offsets = _view->offsets();
588 const auto& view_extents = _view->extents();
590 const auto& glob_extent = pattern.extents();
591 for(
dim_t d = 0; d < NumDimensions; ++d) {
593 if(view_offsets[d] == 0) {
594 _borders[d].first =
true;
596 if(view_offsets[d] + view_extents[d] == glob_extent[d]) {
597 _borders[d].second =
true;
602 _block_views = bnd_check.block_views();
604 const auto& team_spec = pattern.teamspec();
605 for(
const auto& spec : halo_spec.
specs()) {
606 auto halo_extent = spec.extent();
611 auto& env_md = _block_env[spec.index()];
613 env_md.bnd_reg_data = bnd_check.region_data(spec);
615 std::array<int, NumDimensions> neighbor_coords_rem;
616 std::array<int, NumDimensions> neighbor_coords;
617 auto reg_coords = spec.coords();
618 auto reg_coords_rem = RegionCoords_t::coords(RegionsMax - 1 - spec.index());
620 env_md.boundary_prop = BoundaryProp::CYCLIC;
621 BoundaryProp bnd_prop_to = BoundaryProp::CYCLIC;
625 auto halo_region_offsets = _view->offsets();
626 auto halo_region_extents = _view->extents();
627 for(
dim_t d = 0; d < NumDimensions; ++d) {
630 neighbor_coords[d] =
static_cast<int>(reg_coords[d]) - 1;
631 neighbor_coords_rem[d] =
static_cast<int>(reg_coords_rem[d]) - 1;
638 halo_region_extents[d] = halo_extent;
641 if(_borders[d].
first) {
642 halo_region_offsets[d] = pattern.extent(d) - halo_extent;
643 env_md.boundary_prop = test_bound_prop(env_md.boundary_prop, (*_glob_bnd_spec)[d]);
644 env_md.border_region =
true;
645 env_md.region_borders[d].first =
true;
647 halo_region_offsets[d] -= halo_extent;
651 bnd_prop_to = test_bound_prop(bnd_prop_to, (*_glob_bnd_spec)[d]);
658 halo_region_offsets[d] = 0;
659 env_md.boundary_prop = test_bound_prop(env_md.boundary_prop, (*_glob_bnd_spec)[d]);
660 env_md.border_region =
true;
661 env_md.region_borders[d].second =
true;
663 halo_region_offsets[d] += _view->extent(d);
666 if(_borders[d].
first) {
667 bnd_prop_to = test_bound_prop(bnd_prop_to, (*_glob_bnd_spec)[d]);
671 env_md.halo_reg_data = {ViewSpec_t(halo_region_offsets, halo_region_extents),
true};
672 if(env_md.boundary_prop != BoundaryProp::NONE) {
673 if(env_md.boundary_prop == BoundaryProp::CYCLIC) {
674 env_md.neighbor_id_from =
static_cast<dart_unit_t>(team_spec.periodic_neighbor(neighbor_coords));
676 env_md.neighbor_id_from =
static_cast<dart_unit_t>(team_spec.neighbor(neighbor_coords));
679 env_md.neighbor_id_from =
static_cast<dart_unit_t>(team_spec.neighbor(neighbor_coords));
680 env_md.halo_reg_data.valid =
false;
683 if(bnd_prop_to == BoundaryProp::CYCLIC) {
684 env_md.neighbor_id_to =
static_cast<dart_unit_t>(team_spec.periodic_neighbor(neighbor_coords_rem));
686 env_md.neighbor_id_to =
static_cast<dart_unit_t>(team_spec.neighbor(neighbor_coords_rem));
691 BoundaryProp test_bound_prop(
const BoundaryProp& current_prop,
const BoundaryProp& new_prop) {
692 if(current_prop == BoundaryProp::NONE || new_prop == BoundaryProp::NONE) {
693 return BoundaryProp::NONE;
696 if(current_prop == BoundaryProp::CUSTOM || new_prop == BoundaryProp::CUSTOM) {
697 return BoundaryProp::CUSTOM;
700 return BoundaryProp::CYCLIC;
704 const ViewSpec_t* _view;
706 BlockEnv_t _block_env;
707 RegionBorders_t _borders{};
708 RegIdxMain_t _reg_idx_main;
709 BlockViewSpec_t _block_views;
712 template<
typename PatternT>
713 std::ostream& operator<<(std::ostream& os, const BlockEnvironment<PatternT>& env_info) {
715 static constexpr
auto RegionsMax = NumRegionsMax<NumDimensions>;
717 const auto& env_mds = env_info.info();
719 os <<
"dash::halo::BlockEnvironment { ";
720 for(region_index_t r = 0; r < RegionsMax; ++r) {
721 const auto& env_md = env_mds[r];
723 os <<
"region_index: " << r <<
";" 734 template <
typename HaloBlockT,
typename StencilSpecT>
739 using Pattern_t =
typename HaloBlockT::Pattern_t;
740 using HaloSpec_t =
typename HaloBlockT::HaloSpec_t;
743 using HaloBlock_t = HaloBlockT;
744 using ViewSpec_t =
typename HaloBlockT::ViewSpec_t;
745 using BoundaryViews_t =
typename HaloBlockT::BoundaryViews_t;
746 using pattern_size_t =
typename Pattern_t::size_type;
752 const ViewSpec_t* view_local)
753 : _stencil_spec(&stencil_spec), _view_local(view_local) {
754 HaloSpec_t halo_spec(stencil_spec);
755 auto bnd_region_check = halo_block.block_env().boundary_region_check(halo_spec);
757 auto block_views = bnd_region_check.block_views();
758 _view_inner = block_views.inner;
759 _view_inner_with_boundaries = block_views.inner_bound;
760 for(
const auto& region : halo_spec.specs()) {
761 auto bnd_region_data = bnd_region_check.region_data(region);
762 _size_bnd_elems += bnd_region_data.view.size();
763 _boundary_views.push_back(std::move(bnd_region_data.view));
775 const ViewSpec_t&
view()
const {
return *_view_local; }
780 const ViewSpec_t&
inner()
const {
return _view_inner; }
786 return _view_inner_with_boundaries;
801 const ViewSpec_t* _view_local;
802 ViewSpec_t _view_inner;
803 ViewSpec_t _view_inner_with_boundaries;
804 BoundaryViews_t _boundary_views;
805 pattern_size_t _size_bnd_elems = 0;
808 template <
typename HaloBlockT,
typename StencilSpecT>
809 std::ostream& operator<<(
812 os <<
"dash::halo::StencilSpecificViews" 813 <<
"(local: " << stencil_views.
view()
814 <<
"; inner: " << stencil_views.
inner()
817 <<
"; boundary elems: " << stencil_views.
boundary_size() <<
")";
826 template <
typename ElementT,
typename PatternT,
typename GlobMemT>
830 static constexpr
auto RegionsMax = NumRegionsMax<NumDimensions>;
833 using pattern_index_t =
typename PatternT::index_type;
837 using Coords_t =
typename RegionCoords_t::Coords_t;
838 using region_extent_t =
typename RegionSpec_t::region_extent_t;
841 using Element_t = ElementT;
842 using Pattern_t = PatternT;
843 using GlobMem_t = GlobMemT;
845 using pattern_size_t =
typename PatternT::size_type;
846 using ViewSpec_t =
typename PatternT::viewspec_type;
847 using BoundaryViews_t = std::vector<ViewSpec_t>;
849 using RegionVector_t = std::vector<Region_t>;
850 using ElementCoords_t = std::array<pattern_index_t, NumDimensions>;
851 using HaloExtsMax_t =
typename HaloSpec_t::HaloExtsMax_t;
852 using RegIndDepVec_t =
typename RegionCoords_t::RegIndDepVec_t;
859 HaloBlock(GlobMem_t& globmem,
const PatternT& pattern,
const ViewSpec_t& view,
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) {
868 _halo_regions.reserve(_halo_reg_spec.num_regions());
869 _boundary_regions.reserve(_halo_reg_spec.num_regions());
871 _view_inner = _block_env.view_inner();
872 _view_inner_with_boundaries = _block_env.view_inner_boundary();
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];
884 _boundary_views.push_back(env_reg_info.bnd_reg_data.view);
885 _size_bnd_elems += env_reg_info.bnd_reg_data.view.size();
887 auto halo_extent = spec.extent();
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();
899 _halo_regions.push_back(
901 _globmem, _pattern, env_reg_info));
902 _halo_reg_mapping[r] = &_halo_regions.back();
904 auto bnd_reg_data = bnd_check.region_data_duplicate(spec,
false);
905 _boundary_regions.push_back(
907 _globmem, _pattern, env_reg_info));
908 _boundary_reg_mapping[r] = &_boundary_regions.back();
924 static constexpr
dim_t ndim() {
return NumDimensions; }
929 const Pattern_t&
pattern()
const {
return _pattern; }
934 const GlobMem_t&
globmem()
const {
return _globmem; }
940 return _glob_bound_spec;
963 return _halo_reg_mapping[
index];
975 return _boundary_reg_mapping[
index];
984 RegIndDepVec_t boundary_dependencies(region_index_t
index)
const {
985 RegIndDepVec_t index_dep{};
986 for(
auto reg_index : RegionCoords_t::boundary_dependencies(index)) {
987 auto region = halo_region(reg_index);
988 if(region !=
nullptr) {
989 index_dep.push_back(reg_index);
999 const ViewSpec_t&
view()
const {
return _view; }
1010 return _view_inner_with_boundaries;
1028 pattern_size_t
halo_size()
const {
return _size_halo_elems; }
1039 const ElementCoords_t& coords)
const {
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();
1044 region_index_t index = 0;
1045 if(coords[0] >= offsets[0]
1046 && coords[0] < static_cast<signed_extent_t>(extents[0]))
1048 else if(coords[0] >= static_cast<signed_extent_t>(extents[0]))
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;
1056 index = 2 + index * REGION_INDEX_BASE;
1063 GlobMem_t& _globmem;
1065 const PatternT& _pattern;
1067 const ViewSpec_t& _view;
1071 const ViewSpec_t _view_local;
1077 ViewSpec_t _view_inner_with_boundaries;
1079 ViewSpec_t _view_inner;
1081 RegionVector_t _halo_regions;
1083 std::array<Region_t*, RegionsMax> _halo_reg_mapping{};
1085 RegionVector_t _boundary_regions;
1087 std::array<Region_t*, RegionsMax> _boundary_reg_mapping{};
1089 BoundaryViews_t _boundary_views;
1091 pattern_size_t _size_bnd_elems = 0;
1093 pattern_size_t _size_halo_elems = 0;
1096 template <
typename ElementT,
typename PatternT,
typename GlobMemT>
1097 std::ostream& operator<<(std::ostream& os,
1100 os <<
"dash::halo::HaloBlock<" <<
typeid(ElementT).name() <<
">(" 1101 <<
"view global: " << haloblock.
view()
1102 <<
"; halo spec: " << haloblock.
halo_spec()
1103 <<
"; view local: " << haloblock.
view_local()
1104 <<
"; view inner: " << haloblock.
view_inner()
1106 <<
"; halo regions { ";
1112 os <<
"," << region;
1116 <<
"; halo elems: " << haloblock.
halo_size() <<
"; boundary regions: { ";
1122 os <<
"," << region;
1127 <<
"; boundary elems: " << haloblock.
boundary_size() <<
")";
1138 #endif // DASH__HALO_HALO_H__ GlobalBoundarySpec()
Default constructor.
constexpr region_extent_t extent() const
Returns the extent.
constexpr region_extent_t extent(const region_index_t index) const
Extent for a given region index.
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)
This class is a simple memory pool which holds allocates elements of size ValueType.
const ViewSpec_t & view_inner_with_boundaries() const
Returns a local ViewSpec that combines the boundary and inner view.
const ViewSpec_t & inner() const
Returns ViewSpec including all inner elements.
const HaloSpec_t & halo_spec() const
Returns used HaloSpec.
const Region_t * halo_region(const region_index_t index) const
Returns a specific halo region and nullptr if no region exists.
const BoundaryViews_t & boundary_views() const
Returns a set of local views that contains all boundary elements.
pattern_size_t halo_size() const
Number of halo elements.
const ViewSpec_t & view() const
Returns ViewSpec including all elements (locally)
Takes the local part of the NArray and builds halo and boundary regions.
constexpr auto begin(RangeType &&range) -> decltype(std::forward< RangeType >(range).begin())
No global boundary Halos.
const Pattern_t & pattern() const
The pattern instance that created the encapsulated block.
int32_t dart_unit_t
Data type for storing a unit ID.
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
const GlobBoundSpec_t & global_boundary_spec() const
Returns the GlobalBoundarySpec used by the HaloBlock instance.
const StencilSpec_t & stencil_spec() const
Returns StencilSpec.
constexpr const StencilArray_t & specs() const
const ViewSpec_t & view() const
Returns the initial global ViewSpec.
Reduce operands to their maximum value.
pattern_size_t boundary_size() const
Number of boundary elements (no duplicates)
const RegionVector_t & halo_regions() const
Returns all halo regions.
const ViewSpec_t & inner_with_boundaries() const
Returns ViewSpec including all inner and boundary elements.
void fill(GlobIterType first, GlobIterType last, const typename GlobIterType::value_type &value)
Assigns the given value to the elements in the range [first, last)
pattern_size_t boundary_size() const
Returns the number of all boundary elements (no dublicates)
const ViewSpec_t & view_inner() const
Returns the inner ViewSpec with local offsets depending on the used HaloSpec.
N-Dimensional region coordinates and associated indices for all possible Halo/Boundary regions of a H...
constexpr region_size_t num_regions() const
Number of specified regions.
Adapts all views HaloBlock provides to the given StencilSpec.
const Specs_t & specs() const
Used RegionSpec instance.
const BoundaryViews_t & boundary_views() const
Returns all boundary views including all boundary elements (no dublicates)
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.
Base class for dimensional attributes, stores an n-dimensional value with identical type all dimensio...
HaloBlock(GlobMem_t &globmem, const PatternT &pattern, const ViewSpec_t &view, const HaloSpec_t &halo_reg_spec, const GlobBoundSpec_t &bound_spec)
Constructor.
Contains all specified Halo regions.
constexpr dim_t ndim(const DimensionalType &d)
DistanceAll_t minmax_distances() const
Returns the minimal and maximal distances of all stencil points for all dimensions.
const BlockEnv_t & block_env() const
Returns the environment information object BlockEnvironment.
const HaloExtsMaxPair_t & halo_extension_max(dim_t dim) const
Returns the maximal extension for a specific dimension.
const RegionVector_t & boundary_regions() const
Returns all boundary regions.
constexpr GlobalBoundarySpec(BoundaryProp value, Values... values)
Constructor to define custom BoundaryProp values.
static region_index_t index(const StencilT &stencil)
Returns the region index for a given StencilPoint.
Provides RegionIter and some region metadata like RegionSpec, size etc.
BlockEnv_t block_env()
Returns the environment information object BlockEnvironment.
const GlobMem_t & globmem() const
The global memory instance that created the encapsulated block.
constexpr RegionSpec_t spec(const region_index_t index) const
Matching RegionSpec for a given region index.
const HaloExtsMax_t & halo_extension_max() const
Returns the maximal halo extension for every dimension.
constexpr const RegionCoords_t & coords() const
Returns the RegionCoords.
constexpr DimensionalType::extent_type extent(const DimensionalType &d)
A collection of stencil points (Stencil) e.g.
Global boundary property specification for every dimension.
Region specification connecting RegionCoords with an extent.
const ViewSpec_t & view_local() const
Returns the initial local ViewSpec.
const Region_t * boundary_region(const region_index_t index) const
Returns a specific region and nullptr if no region exists.