1 #ifndef DASH__CSR_PATTERN_1D_H_ 2 #define DASH__CSR_PATTERN_1D_H_ 4 #include <dash/Types.h> 5 #include <dash/Distribution.h> 6 #include <dash/Exception.h> 7 #include <dash/Dimensional.h> 8 #include <dash/Cartesian.h> 11 #include <dash/pattern/PatternProperties.h> 12 #include <dash/pattern/internal/PatternArguments.h> 14 #include <dash/internal/Math.h> 15 #include <dash/internal/Logging.h> 21 #include <type_traits> 35 MemArrange Arrangement = dash::ROW_MAJOR,
49 MemArrange Arrangement,
52 class CSRPattern<1, Arrangement, IndexType>
55 static const dim_t NumDimensions = 1;
58 static constexpr
char const * PatternName =
"CSRPattern1D";
89 typedef CSRPattern<NumDimensions, Arrangement, IndexType>
92 typedef typename std::make_unsigned<IndexType>::type
108 typedef internal::PatternArguments<NumDimensions, IndexType>
112 typedef IndexType index_type;
113 typedef SizeType size_type;
121 std::array<index_type, NumDimensions> coords;
128 std::vector<size_type> _local_sizes;
130 std::vector<size_type> _block_offsets;
132 MemoryLayout_t _memory_layout;
134 BlockSpec_t _blockspec;
137 DistributionSpec_t _distspec;
141 TeamSpec_t _teamspec;
143 SizeType _nunits = 0;
145 SizeType _local_size = 0;
147 LocalMemoryLayout_t _local_memory_layout;
149 SizeType _local_capacity = 0;
151 IndexType _lbegin = 0;
162 template<
typename ... Args>
172 : CSRPattern(PatternArguments_t(arg, args...))
174 DASH_LOG_TRACE(
"CSRPattern()",
"Constructor with argument list");
176 _local_sizes.size(), _nunits,
177 "Number of given local sizes " << _local_sizes.size() <<
" " <<
178 "does not match number of units" << _nunits);
179 initialize_local_range();
180 DASH_LOG_TRACE(
"CSRPattern()",
"CSRPattern initialized");
190 const SizeSpec_t & sizespec,
192 const DistributionSpec_t & distspec,
194 const TeamSpec_t & teamspec,
197 : _size(sizespec.
size()),
198 _local_sizes(initialize_local_sizes(
202 _block_offsets(initialize_block_offsets(
204 _memory_layout(
std::array<SizeType, 1> {{ _size }}),
205 _blockspec(initialize_blockspec(
207 _distspec(DistributionSpec_t()),
213 _nunits(_team->
size()),
215 initialize_local_extent(
218 _local_memory_layout(std::array<SizeType, 1> {{ _local_size }}),
219 _local_capacity(initialize_local_capacity(_local_sizes))
221 DASH_LOG_TRACE(
"CSRPattern()",
"(sizespec, dist, team)");
223 _local_sizes.size(), _nunits,
224 "Number of given local sizes " << _local_sizes.size() <<
" " <<
225 "does not match number of units" << _nunits);
226 initialize_local_range();
227 DASH_LOG_TRACE(
"CSRPattern()",
"CSRPattern initialized");
237 const SizeSpec_t & sizespec,
239 const DistributionSpec_t & distspec,
242 : _size(sizespec.
size()),
243 _local_sizes(initialize_local_sizes(
247 _block_offsets(initialize_block_offsets(
249 _memory_layout(
std::array<SizeType, 1> {{ _size }}),
250 _blockspec(initialize_blockspec(
252 _distspec(DistributionSpec_t()),
254 _teamspec(_distspec, *_team),
255 _nunits(_team->
size()),
257 initialize_local_extent(
260 _local_memory_layout(std::array<SizeType, 1> {{ _local_size }}),
261 _local_capacity(initialize_local_capacity(_local_sizes))
263 DASH_LOG_TRACE(
"CSRPattern()",
"(sizespec, dist, team)");
265 _local_sizes.size(), _nunits,
266 "Number of given local sizes " << _local_sizes.size() <<
" " <<
267 "does not match number of units" << _nunits);
268 initialize_local_range();
269 DASH_LOG_TRACE(
"CSRPattern()",
"CSRPattern initialized");
278 template<
typename ... Args>
281 const std::vector<size_type> & local_sizes,
290 : CSRPattern(local_sizes, PatternArguments_t(arg, args...))
292 DASH_LOG_TRACE(
"CSRPattern()",
"Constructor with argument list");
294 _local_sizes.size(), _nunits,
295 "Number of given local sizes " << _local_sizes.size() <<
" " <<
296 "does not match number of units" << _nunits);
297 initialize_local_range();
298 DASH_LOG_TRACE(
"CSRPattern()",
"CSRPattern initialized");
308 const std::vector<size_type> & local_sizes,
310 const TeamSpec_t & teamspec,
313 : _size(initialize_size(
315 _local_sizes(local_sizes),
316 _block_offsets(initialize_block_offsets(
318 _memory_layout(
std::array<SizeType, 1> {{ _size }}),
319 _blockspec(initialize_blockspec(
321 _distspec(DistributionSpec_t()),
327 _nunits(_team->
size()),
329 initialize_local_extent(
332 _local_memory_layout(std::array<SizeType, 1> {{ _local_size }}),
333 _local_capacity(initialize_local_capacity(_local_sizes))
335 DASH_LOG_TRACE(
"CSRPattern()",
"(sizespec, dist, teamspec, team)");
337 _local_sizes.size(), _nunits,
338 "Number of given local sizes " << _local_sizes.size() <<
" " <<
339 "does not match number of units" << _nunits);
340 initialize_local_range();
341 DASH_LOG_TRACE(
"CSRPattern()",
"CSRPattern initialized");
351 const std::vector<size_type> & local_sizes,
357 _local_sizes(local_sizes),
359 initialize_block_offsets(
361 _memory_layout(
std::array<SizeType, 1> {{ _size }}),
363 initialize_blockspec(
365 _distspec(DistributionSpec_t()),
367 _teamspec(_distspec, *_team),
368 _nunits(_team->
size()),
370 initialize_local_extent(
373 _local_memory_layout(
374 std::array<SizeType, 1> {{ _local_size }}),
376 initialize_local_capacity(_local_sizes))
378 DASH_LOG_TRACE(
"CSRPattern()",
"(sizespec, dist, team)");
380 _local_sizes.size(), _nunits,
381 "Number of given local sizes " << _local_sizes.size() <<
" " <<
382 "does not match number of units" << _nunits);
383 initialize_local_range();
384 DASH_LOG_TRACE(
"CSRPattern()",
"CSRPattern initialized");
390 CSRPattern(
const self_t & other) =
default;
395 CSRPattern(self_t && other) =
default;
404 : CSRPattern(static_cast<const self_t &>(other))
410 self_t & operator=(
const self_t & other) =
default;
415 self_t & operator=(self_t && other) =
default;
422 const self_t & other)
const noexcept
424 return (
this == &other) ||
427 _size == other._size &&
428 _local_sizes == other._local_sizes &&
429 _distspec == other._distspec &&
430 _teamspec == other._teamspec &&
431 _nunits == other._nunits
440 const self_t & other)
const noexcept
442 return !(*
this == other);
450 constexpr IndexType
lbegin() const noexcept
460 constexpr IndexType
lend() const noexcept
476 const std::array<IndexType, NumDimensions> & coords,
478 const ViewSpec_t & viewspec)
const 480 return unit_at(coords[0] + viewspec.offset(0));
489 const std::array<IndexType, NumDimensions> & g_coords)
const 491 return unit_at(g_coords[0]);
501 IndexType global_pos,
503 const ViewSpec_t & viewspec)
const 505 return unit_at(global_pos + viewspec.offset(0));
515 IndexType g_index)
const 517 DASH_LOG_TRACE_VAR(
"CSRPattern.unit_at()", g_index);
519 for (
team_unit_t unit_idx{0}; unit_idx < _nunits; ++unit_idx) {
520 if (g_index < _local_sizes[unit_idx]) {
521 DASH_LOG_TRACE_VAR(
"CSRPattern.unit_at >", unit_idx);
524 g_index -= _local_sizes[unit_idx];
528 "CSRPattern.unit_at: " <<
529 "global index " << g_index <<
" is out of bounds");
549 "Wrong dimension for Pattern::local_extent. " <<
550 "Expected dimension = 0, got " << dim);
569 "Wrong dimension for Pattern::local_extent. " <<
570 "Expected dimension = 0, got " << dim);
585 constexpr std::array<SizeType, NumDimensions>
588 return std::array<SizeType, 1> {{ _local_sizes[_team->myid()] }};
604 return std::array<SizeType, 1> {{ _local_sizes[unit] }};
619 const std::array<IndexType, NumDimensions> & local_coords,
621 const ViewSpec_t & viewspec)
const noexcept
623 return local_coords[0] + viewspec.offset(0);
633 const std::array<IndexType, NumDimensions> & local_coords)
const 635 return local_coords[0];
647 const std::array<IndexType, NumDimensions> & g_coords)
const 649 local_index_t l_index =
local(g_coords[0]);
650 local_coords_t l_coords;
651 l_coords.unit = l_index.unit;
652 l_coords.coords[0] = l_index.index;
664 IndexType g_index)
const 666 DASH_LOG_TRACE_VAR(
"CSRPattern.local()", g_index);
667 local_index_t l_index;
669 for (
team_unit_t unit_idx{0}; unit_idx < _nunits; ++unit_idx) {
670 if (g_index < _local_sizes[unit_idx]) {
671 l_index.unit = unit_idx;
672 l_index.index = g_index;
673 DASH_LOG_TRACE(
"CSRPattern.local >",
674 "unit:", l_index.unit,
675 "index:", l_index.index);
678 g_index -= _local_sizes[unit_idx];
682 "CSRPattern.local: " <<
683 "global index " << g_index <<
" is out of bounds");
693 const std::array<IndexType, NumDimensions> & g_coords)
const 695 return std::array<IndexType, 1> {{
local(g_coords[0]).index }};
705 const std::array<IndexType, NumDimensions> & g_coords)
const 707 return local(g_coords[0]);
719 inline std::array<IndexType, NumDimensions>
global(
721 const std::array<IndexType, NumDimensions> & local_coords)
const 723 DASH_LOG_DEBUG_VAR(
"CSRPattern.global()", unit);
724 DASH_LOG_DEBUG_VAR(
"CSRPattern.global()", local_coords);
725 DASH_LOG_TRACE_VAR(
"CSRPattern.global", _nunits);
730 index_type glob_index = _block_offsets[unit] + local_coords[0];
731 DASH_LOG_TRACE_VAR(
"CSRPattern.global >", glob_index);
732 return std::array<IndexType, 1> {{ glob_index }};
740 constexpr std::array<IndexType, NumDimensions>
global(
741 const std::array<IndexType, NumDimensions> & l_coords)
const 743 return global(_team->myid(), l_coords);
756 IndexType l_index)
const 758 return global(unit, std::array<IndexType, 1> {{ l_index }})[0];
770 IndexType l_index)
const 772 return global(_team->myid(), std::array<IndexType, 1> {{ l_index }})[0];
785 const std::array<IndexType, NumDimensions> & l_coords)
const 787 return global(unit, l_coords[0]);
802 constexpr IndexType
at(
803 const std::array<IndexType, NumDimensions> & g_coords)
const 805 return local_coords(g_coords)[0];
816 const std::array<IndexType, NumDimensions> & g_coords,
817 const ViewSpec_t & viewspec)
const 819 auto vs_coords = g_coords;
820 vs_coords[0] += viewspec.offset(0);
821 return local_coords(vs_coords)[0];
831 template<
typename ... Values>
832 constexpr IndexType
at(IndexType value, Values ... values)
const 835 sizeof...(values) == NumDimensions-1,
836 "Wrong parameter number");
837 return at(std::array<IndexType, NumDimensions> {{
838 value, (IndexType)values...
855 return (
index >= _block_offsets[unit])
856 && ( unit == _nunits-1
857 ||
index < _block_offsets[unit+1]
868 IndexType
index)
const 870 auto unit = team().myid();
871 bool is_loc = index >= _block_offsets[unit] &&
872 (unit == _nunits-1 ||
873 index < _block_offsets[unit+1]);
884 constexpr
const BlockSpec_t &
blockspec() const noexcept
896 const std::array<index_type, NumDimensions> & g_coords)
const 898 return static_cast<index_type
>(unit_at(g_coords[0]));
906 index_type g_block_index)
const 908 DASH_LOG_DEBUG_VAR(
"CSRPattern<1>.block >", g_block_index);
909 index_type offset = _block_offsets[g_block_index];
910 auto block_size = _local_sizes[g_block_index];
911 std::array<index_type, NumDimensions> offsets = {{ offset }};
912 std::array<size_type, NumDimensions> extents = {{ block_size }};
913 ViewSpec_t block_vs(offsets, extents);
914 DASH_LOG_DEBUG_VAR(
"CSRPattern<1>.block >", block_vs);
923 index_type l_block_index)
const 925 DASH_LOG_DEBUG_VAR(
"CSRPattern<1>.local_block()", l_block_index);
928 "CSRPattern always assigns exactly 1 block to a single unit");
929 index_type block_offset = _block_offsets[_team->myid()];
930 size_type block_size = _local_sizes[_team->myid()];
931 std::array<index_type, NumDimensions> offsets = {{ block_offset }};
932 std::array<size_type, NumDimensions> extents = {{ block_size }};
933 ViewSpec_t block_vs(offsets, extents);
934 DASH_LOG_DEBUG_VAR(
"CSRPattern<1>.local_block >", block_vs);
943 index_type l_block_index)
const 945 DASH_LOG_DEBUG_VAR(
"CSRPattern<1>.local_block_local >", l_block_index);
946 size_type block_size = _local_sizes[_team->myid()];
947 std::array<index_type, NumDimensions> offsets = {{ 0 }};
948 std::array<size_type, NumDimensions> extents = {{ block_size }};
949 ViewSpec_t block_vs(offsets, extents);
950 DASH_LOG_DEBUG_VAR(
"CSRPattern<1>.local_block_local >", block_vs);
963 dim_t dimension)
const noexcept
965 return _local_capacity;
978 return _local_capacity;
989 return _local_capacity;
1008 constexpr SizeType local_size(
team_unit_t unit)
const noexcept
1010 return _local_sizes[unit.id];
1038 constexpr IndexType
size() const noexcept
1055 constexpr
const DistributionSpec_t &
distspec() const noexcept
1067 return SizeSpec_t(std::array<SizeType, 1> {{ _size }});
1075 constexpr
const std::array<SizeType, NumDimensions>
1078 return std::array<SizeType, 1> {{ _size }};
1098 constexpr std::array<IndexType, NumDimensions>
coords(
1099 IndexType
index)
const noexcept
1101 return std::array<IndexType, 1> {{
index }};
1112 const ViewSpec_t & viewspec)
const {
1113 return std::array<IndexType, 1> {{ index + viewspec.offset(0) }};
1137 const PatternArguments_t & arguments)
1139 initialize_local_sizes(
1140 arguments.sizespec().size(),
1141 arguments.distspec(),
1147 std::vector<size_type> local_sizes,
const PatternArguments_t &arguments)
1148 : _size(arguments.sizespec().size())
1149 , _local_sizes(std::move(local_sizes))
1150 , _block_offsets(initialize_block_offsets(_local_sizes))
1151 , _memory_layout(std::array<SizeType, 1>{{_size}})
1152 , _blockspec(initialize_blockspec(_local_sizes))
1153 , _distspec(arguments.distspec())
1154 , _team(&arguments.team())
1155 , _teamspec(arguments.teamspec())
1156 , _nunits(_team->
size())
1157 , _local_size(initialize_local_extent(_team->myid(), _local_sizes))
1158 , _local_memory_layout(std::array<SizeType, 1>{{_local_size}})
1159 , _local_capacity(initialize_local_capacity(_local_sizes))
1165 inline SizeType initialize_size(
1166 const std::vector<size_type> & local_sizes)
const 1168 DASH_LOG_TRACE_VAR(
"CSRPattern.init_size()", local_sizes);
1170 for (size_type unit_idx = 0; unit_idx < local_sizes.size(); ++
1172 size += local_sizes[unit_idx];
1174 DASH_LOG_TRACE_VAR(
"CSRPattern.init_size >", size);
1182 std::vector<size_type> initialize_local_sizes(
1183 size_type total_size,
1184 const DistributionSpec_t & distspec,
1187 DASH_LOG_TRACE_VAR(
"CSRPattern.init_local_sizes()", total_size);
1188 std::vector<size_type> l_sizes;
1189 auto nunits = team.
size();
1190 DASH_LOG_TRACE_VAR(
"CSRPattern.init_local_sizes()", nunits);
1192 l_sizes.push_back(total_size);
1197 auto dist_type = distspec[0].type;
1198 DASH_LOG_TRACE_VAR(
"CSRPattern.init_local_sizes()", dist_type);
1200 if (dist_type == dash::internal::DIST_BLOCKED ||
1201 dist_type == dash::internal::DIST_TILE) {
1202 auto blocksize = dash::math::div_ceil(total_size, nunits);
1203 for (size_type u = 0; u < nunits; ++u) {
1204 l_sizes.push_back(blocksize);
1208 }
else if (dist_type == dash::internal::DIST_UNDEFINED) {
1209 for (size_type u = 0; u < nunits; ++u) {
1210 l_sizes.push_back(0);
1213 }
else if (dist_type == dash::internal::DIST_NONE) {
1214 l_sizes.push_back(total_size);
1215 for (size_type u = 0; u < nunits-1; ++u) {
1216 l_sizes.push_back(0);
1222 "CSRPattern expects TILE (" << dash::internal::DIST_TILE <<
") " <<
1223 "or BLOCKED (" << dash::internal::DIST_BLOCKED <<
") " <<
1224 "distribution, got " << dist_type);
1226 DASH_LOG_TRACE_VAR(
"CSRPattern.init_local_sizes >", l_sizes);
1230 BlockSpec_t initialize_blockspec(
1231 const std::vector<size_type> & local_sizes)
const 1233 DASH_LOG_TRACE_VAR(
"CSRPattern.init_blockspec", local_sizes);
1234 BlockSpec_t blockspec({
1235 static_cast<size_type
>(local_sizes.size())
1237 DASH_LOG_TRACE_VAR(
"CSRPattern.init_blockspec >", blockspec);
1245 std::vector<size_type> initialize_block_offsets(
1246 const std::vector<size_type> & local_sizes)
const 1248 DASH_LOG_TRACE_VAR(
"CSRPattern.init_block_offsets", local_sizes);
1249 std::vector<size_type> block_offsets;
1250 if (local_sizes.size() > 0) {
1252 block_offsets.push_back(0);
1253 for (size_type unit_idx = 0;
1254 unit_idx < local_sizes.size()-1;
1257 auto block_offset = block_offsets[unit_idx] +
1258 local_sizes[unit_idx];
1259 block_offsets.push_back(block_offset);
1262 DASH_LOG_TRACE_VAR(
"CSRPattern.init_block_offsets >", block_offsets);
1263 return block_offsets;
1269 SizeType initialize_local_capacity(
1270 const std::vector<size_type> & local_sizes)
const 1272 SizeType l_capacity = 0;
1277 if (max_local_size != local_sizes.end()) {
1278 l_capacity = *max_local_size;
1280 DASH_LOG_DEBUG_VAR(
"CSRPattern.init_lcapacity >", l_capacity);
1288 void initialize_local_range()
1290 auto l_size = _local_size;
1291 DASH_LOG_DEBUG_VAR(
"CSRPattern.init_local_range()", l_size);
1301 _lend =
global(l_size - 1) + 1;
1303 DASH_LOG_DEBUG_VAR(
"CSRPattern.init_local_range >", _lbegin);
1304 DASH_LOG_DEBUG_VAR(
"CSRPattern.init_local_range >", _lend);
1310 SizeType initialize_local_extent(
1312 const std::vector<size_type> & local_sizes)
const 1314 DASH_LOG_DEBUG_VAR(
"CSRPattern.init_local_extent()", unit);
1315 if (local_sizes.size() == 0) {
1319 SizeType l_extent = local_sizes[
static_cast<int>(unit)];
1320 DASH_LOG_DEBUG_VAR(
"CSRPattern.init_local_extent >", l_extent);
1328 #endif // DASH__CSR_PATTERN_1D_H_ constexpr const std::array< SizeType, NumDimensions > extents() const noexcept
Size specification of the index space mapped by this pattern.
All blocks have identical size.
pattern_layout_properties< pattern_layout_tag::blocked, pattern_layout_tag::linear > layout_properties
Satisfiable properties in pattern property category Layout:
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...
constexpr const TeamSpec_t & teamspec() const noexcept
Cartesian arrangement of the Team containing the units to which this pattern's elements are mapped...
constexpr SizeType local_size() const noexcept
The actual number of elements in this pattern that are local to the calling unit in total...
constexpr std::enable_if< std::is_integral< IndexType >::value, IndexType >::type index(IndexType idx)
size_t size()
Return the number of units in the global team.
constexpr auto local(ViewType &v) -> typename std::enable_if<(std::is_pointer< typename ViewType::iterator >::value||(dash::view_traits< ViewValueT >::is_local::value)), ViewType &>::type
This class is a simple memory pool which holds allocates elements of size ValueType.
Local element order corresponds to a logical linearization within single blocks (if blocked) or withi...
constexpr std::array< SizeType, NumDimensions > local_extents(team_unit_t unit) const noexcept
The actual number of elements in this pattern that are local to the given unit, by dimension...
local_index_t local(IndexType g_index) const
Converts global index to its associated unit and respective local index.
constexpr team_unit_t unit_at(IndexType global_pos, const ViewSpec_t &viewspec) const
Convert given global linear index to its assigned unit id.
Specifies cartesian extents in a specific number of dimensions.
constexpr IndexType at(const std::array< IndexType, NumDimensions > &g_coords) const
at
pattern_partitioning_properties< pattern_partitioning_tag::minimal, pattern_partitioning_tag::rectangular, pattern_partitioning_tag::balanced, pattern_partitioning_tag::unbalanced > partitioning_properties
Satisfiable properties in pattern property category Partitioning:
constexpr 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...
Specifies view parameters for implementing submat, rows and cols.
constexpr bool operator==(const self_t &other) const noexcept
Equality comparison operator.
constexpr std::array< SizeType, NumDimensions > local_extents() const noexcept
The actual number of elements in this pattern that are local to the calling unit, by dimension...
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
constexpr SizeSpec_t sizespec() const noexcept
Size specification of the index space mapped by this pattern.
constexpr SizeType blocksize(dim_t dimension) const noexcept
Maximum number of elements in a single block in the given dimension.
CSRPattern(const std::vector< size_type > &local_sizes, Team &team=dash::Team::All())
Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec, TeamSpec and a Team.
constexpr index_type block_at(const std::array< index_type, NumDimensions > &g_coords) const
Index of block at given global coordinates.
IndexType local_extent(dim_t dim) const
The actual number of elements in this pattern that are local to the calling unit in the given dimensi...
static constexpr MemArrange memory_order()
Memory order followed by the pattern.
CSRPattern(const std::vector< size_type > &local_sizes, const TeamSpec_t &teamspec, dash::Team &team=dash::Team::All())
Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec, TeamSpec and a Team.
The number of blocks assigned to units may differ.
constexpr team_unit_t unit_at(const std::array< IndexType, NumDimensions > &coords, const ViewSpec_t &viewspec) const
unit_at
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...
Minimal number of blocks in every dimension, typically at most one block per unit.
Block extents are constant for every dimension.
constexpr bool is_local(IndexType index, team_unit_t unit) const noexcept
is_local
constexpr std::enable_if< dash::view_traits< ViewType >::is_view::value &&dash::view_traits< ViewType >::is_local::value, const typename ViewType::global_type & >::type global(const ViewType &v)
size_t size() const
The number of units in this team.
constexpr dash::Team & team() const noexcept
The Team containing the units to which this pattern's elements are mapped.
constexpr std::array< IndexType, NumDimensions > coords(IndexType index) const noexcept
Convert given global linear offset (index) to global cartesian coordinates.
Cartesian space defined by extents in n dimensions.
std::array< IndexType, NumDimensions > global(team_unit_t unit, const std::array< IndexType, NumDimensions > &local_coords) const
global
internal::default_signed_index default_index_t
Signed integer type used as default for index values.
constexpr 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.
constexpr std::array< IndexType, NumDimensions > global(const std::array< IndexType, NumDimensions > &l_coords) const
Converts local coordinates of active unit to global coordinates.
static constexpr dim_t ndim()
Number of dimensions of the cartesian space partitioned by the pattern.
A Team instance specifies a subset of all available units.
constexpr IndexType local_at(const std::array< IndexType, NumDimensions > &local_coords, const ViewSpec_t &viewspec) const noexcept
local
Elements are contiguous in local memory within a single block and thus indexed blockwise.
constexpr IndexType global(IndexType l_index) const
Resolve an element's linear global index from the calling unit's local index of that element...
CSRPattern(const SizeSpec_t &sizespec, const DistributionSpec_t &distspec, const TeamSpec_t &teamspec, Team &team=dash::Team::All())
Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec, TeamSpec and Team.
Defines a cartesian, totally-ordered index space by mapping linear indices to cartesian coordinates d...
constexpr SizeType local_capacity() const noexcept
Maximum number of elements assigned to a single unit in total, equivalent to the local capacity of ev...
constexpr 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.
constexpr team_unit_t unit_at(const std::array< IndexType, NumDimensions > &g_coords) const
Convert given coordinate in pattern to its assigned unit id.
IndexType at(const std::array< IndexType, NumDimensions > &g_coords, const ViewSpec_t &viewspec) const
Global coordinates and viewspec to local index.
constexpr const BlockSpec_t & blockspec() const noexcept
block
CSRPattern(self_t &other)
Copy constructor using non-const lvalue reference parameter.
constexpr IndexType capacity() const noexcept
The maximum number of elements arranged in this pattern.
Size of blocks may differ.
constexpr const DistributionSpec_t & distspec() const noexcept
Distribution specification of this pattern.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
constexpr SizeType max_blocksize() const noexcept
Maximum number of elements in a single block in all dimensions.
GlobIter max_element(const GlobIter &first, const GlobIter &last, Compare compare=Compare())
Finds an iterator pointing to the element with the greatest value in the range [first,last).
constexpr IndexType size() const noexcept
The number of elements arranged in this pattern.
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...
CSRPattern(SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...
CSRPattern(const SizeSpec_t &sizespec, const DistributionSpec_t &distspec, Team &team=dash::Team::All())
Constructor, initializes a pattern from explicit instances of SizeSpec, DistributionSpec and Team...
constexpr IndexType at(IndexType value, Values ... values) const
Global coordinates to local index.
local_coords_t local(const std::array< IndexType, NumDimensions > &g_coords) const
Converts global coordinates to their associated unit and its respective local coordinates.
team_unit_t unit_at(IndexType g_index) const
Convert given global linear index to its assigned unit id.
constexpr IndexType lbegin() const noexcept
Resolves the global index of the first local element in the pattern.
constexpr IndexType local_at(const std::array< IndexType, NumDimensions > &local_coords) const
Convert given local coordinates to linear local offset (index).
static Team & All()
The invariant Team instance containing all available units.
see https://en.cppreference.com/w/cpp/feature_test for recommended feature tests
constexpr IndexType lend() const noexcept
Resolves the global index past the last local element in the pattern.
std::array< IndexType, NumDimensions > coords(IndexType index, const ViewSpec_t &viewspec) const
Convert given global linear offset (index) to global cartesian coordinates using viewspec.
bool is_local(IndexType index) const
Whether the given global index is local to the unit that created this pattern instance.
CSRPattern(const std::vector< size_type > &local_sizes, SizeType arg, Args &&... args)
Constructor, initializes a pattern from an argument list consisting of the pattern size (extent...
IndexType extent(dim_t dim) const
extent
constexpr 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...
constexpr IndexType num_units() const noexcept
The number of units to which this pattern's elements are mapped.
DistributionSpec describes distribution patterns of all dimensions,.
pattern_mapping_properties< pattern_mapping_tag::unbalanced > mapping_properties
Satisfiable properties in pattern property category Mapping:
Generic type of mapping properties of a model satisfying the Pattern concept.
constexpr bool operator!=(const self_t &other) const noexcept
Inquality comparison operator.