23#ifndef KOKKOS_DYNRANKVIEW_HPP
24#define KOKKOS_DYNRANKVIEW_HPP
25#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
26#define KOKKOS_IMPL_PUBLIC_INCLUDE
27#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_DYNRANKVIEW
30#include <Kokkos_Core.hpp>
31#include <impl/Kokkos_Error.hpp>
36template <
typename DataType,
class... Properties>
41template <
typename Specialize>
42struct DynRankDimTraits {
43 enum :
size_t { unspecified = KOKKOS_INVALID_INDEX };
46 KOKKOS_INLINE_FUNCTION
47 static size_t computeRank(
const size_t N0,
const size_t N1,
const size_t N2,
48 const size_t N3,
const size_t N4,
const size_t N5,
49 const size_t N6,
const size_t ) {
51 (N6 == unspecified && N5 == unspecified && N4 == unspecified &&
52 N3 == unspecified && N2 == unspecified && N1 == unspecified &&
55 : ((N6 == unspecified && N5 == unspecified && N4 == unspecified &&
56 N3 == unspecified && N2 == unspecified && N1 == unspecified)
58 : ((N6 == unspecified && N5 == unspecified &&
59 N4 == unspecified && N3 == unspecified &&
62 : ((N6 == unspecified && N5 == unspecified &&
63 N4 == unspecified && N3 == unspecified)
65 : ((N6 == unspecified && N5 == unspecified &&
68 : ((N6 == unspecified &&
71 : ((N6 == unspecified)
77 template <
typename Layout>
78 KOKKOS_INLINE_FUNCTION
static size_t computeRank(
const Layout& layout) {
79 return computeRank(layout.dimension[0], layout.dimension[1],
80 layout.dimension[2], layout.dimension[3],
81 layout.dimension[4], layout.dimension[5],
82 layout.dimension[6], layout.dimension[7]);
86 template <
typename Layout,
typename... P>
87 KOKKOS_INLINE_FUNCTION
static size_t computeRank(
88 const Kokkos::Impl::ViewCtorProp<P...>& ,
89 const Layout& layout) {
90 return computeRank(layout);
95 template <
typename Layout>
96 KOKKOS_INLINE_FUNCTION
static std::enable_if_t<
97 (std::is_same<Layout, Kokkos::LayoutRight>::value ||
98 std::is_same<Layout, Kokkos::LayoutLeft>::value),
100 createLayout(
const Layout& layout) {
101 return Layout(layout.dimension[0] != unspecified ? layout.dimension[0] : 1,
102 layout.dimension[1] != unspecified ? layout.dimension[1] : 1,
103 layout.dimension[2] != unspecified ? layout.dimension[2] : 1,
104 layout.dimension[3] != unspecified ? layout.dimension[3] : 1,
105 layout.dimension[4] != unspecified ? layout.dimension[4] : 1,
106 layout.dimension[5] != unspecified ? layout.dimension[5] : 1,
107 layout.dimension[6] != unspecified ? layout.dimension[6] : 1,
108 layout.dimension[7] != unspecified ? layout.dimension[7] : 1);
112 template <
typename Layout>
113 KOKKOS_INLINE_FUNCTION
static std::enable_if_t<
114 (std::is_same<Layout, Kokkos::LayoutStride>::value), Layout>
115 createLayout(
const Layout& layout) {
116 return Layout(layout.dimension[0] != unspecified ? layout.dimension[0] : 1,
118 layout.dimension[1] != unspecified ? layout.dimension[1] : 1,
120 layout.dimension[2] != unspecified ? layout.dimension[2] : 1,
122 layout.dimension[3] != unspecified ? layout.dimension[3] : 1,
124 layout.dimension[4] != unspecified ? layout.dimension[4] : 1,
126 layout.dimension[5] != unspecified ? layout.dimension[5] : 1,
128 layout.dimension[6] != unspecified ? layout.dimension[6] : 1,
130 layout.dimension[7] != unspecified ? layout.dimension[7] : 1,
135 template <
typename Traits,
typename... P>
136 KOKKOS_INLINE_FUNCTION
static std::enable_if_t<
137 (std::is_same<
typename Traits::array_layout,
139 std::is_same<typename Traits::array_layout, Kokkos::LayoutLeft>::value ||
140 std::is_same<
typename Traits::array_layout,
142 typename Traits::array_layout>
143 createLayout(
const Kokkos::Impl::ViewCtorProp<P...>& ,
144 const typename Traits::array_layout& layout) {
145 return createLayout(layout);
152 template <
typename ViewType,
typename ViewArg>
153 static ViewType createView(
const ViewArg& arg,
const size_t N0,
154 const size_t N1,
const size_t N2,
const size_t N3,
155 const size_t N4,
const size_t N5,
const size_t N6,
157 return ViewType(arg, N0 != unspecified ? N0 : 1, N1 != unspecified ? N1 : 1,
158 N2 != unspecified ? N2 : 1, N3 != unspecified ? N3 : 1,
159 N4 != unspecified ? N4 : 1, N5 != unspecified ? N5 : 1,
160 N6 != unspecified ? N6 : 1, N7 != unspecified ? N7 : 1);
165template <
typename Layout,
typename iType>
166KOKKOS_INLINE_FUNCTION
static std::enable_if_t<
167 (std::is_same<Layout, Kokkos::LayoutRight>::value ||
168 std::is_same<Layout, Kokkos::LayoutLeft>::value) &&
169 std::is_integral<iType>::value,
171reconstructLayout(
const Layout& layout, iType dynrank) {
172 return Layout(dynrank > 0 ? layout.dimension[0] : KOKKOS_INVALID_INDEX,
173 dynrank > 1 ? layout.dimension[1] : KOKKOS_INVALID_INDEX,
174 dynrank > 2 ? layout.dimension[2] : KOKKOS_INVALID_INDEX,
175 dynrank > 3 ? layout.dimension[3] : KOKKOS_INVALID_INDEX,
176 dynrank > 4 ? layout.dimension[4] : KOKKOS_INVALID_INDEX,
177 dynrank > 5 ? layout.dimension[5] : KOKKOS_INVALID_INDEX,
178 dynrank > 6 ? layout.dimension[6] : KOKKOS_INVALID_INDEX,
179 dynrank > 7 ? layout.dimension[7] : KOKKOS_INVALID_INDEX);
183template <
typename Layout,
typename iType>
184KOKKOS_INLINE_FUNCTION
static std::enable_if_t<
185 (std::is_same<Layout, Kokkos::LayoutStride>::value) &&
186 std::is_integral<iType>::value,
188reconstructLayout(
const Layout& layout, iType dynrank) {
189 return Layout(dynrank > 0 ? layout.dimension[0] : KOKKOS_INVALID_INDEX,
190 dynrank > 0 ? layout.stride[0] : (0),
191 dynrank > 1 ? layout.dimension[1] : KOKKOS_INVALID_INDEX,
192 dynrank > 1 ? layout.stride[1] : (0),
193 dynrank > 2 ? layout.dimension[2] : KOKKOS_INVALID_INDEX,
194 dynrank > 2 ? layout.stride[2] : (0),
195 dynrank > 3 ? layout.dimension[3] : KOKKOS_INVALID_INDEX,
196 dynrank > 3 ? layout.stride[3] : (0),
197 dynrank > 4 ? layout.dimension[4] : KOKKOS_INVALID_INDEX,
198 dynrank > 4 ? layout.stride[4] : (0),
199 dynrank > 5 ? layout.dimension[5] : KOKKOS_INVALID_INDEX,
200 dynrank > 5 ? layout.stride[5] : (0),
201 dynrank > 6 ? layout.dimension[6] : KOKKOS_INVALID_INDEX,
202 dynrank > 6 ? layout.stride[6] : (0),
203 dynrank > 7 ? layout.dimension[7] : KOKKOS_INVALID_INDEX,
204 dynrank > 7 ? layout.stride[7] : (0));
210template <
unsigned,
typename iType0,
class MapType>
212 const iType0&,
const MapType&) {
216template <
unsigned R,
typename iType0,
class MapType,
typename iType1,
219 const iType0& rank,
const MapType& map,
const iType1& i, Args... args) {
220 if (
static_cast<iType0
>(R) < rank) {
221 return (
size_t(i) < map.extent(R)) &&
222 dyn_rank_view_verify_operator_bounds<R + 1>(rank, map, args...);
224 KOKKOS_IMPL_DO_NOT_USE_PRINTF(
225 "DynRankView Debug Bounds Checking Error: at rank %u\n Extra "
226 "arguments beyond the rank must be zero \n",
229 dyn_rank_view_verify_operator_bounds<R + 1>(rank, map, args...);
232 dyn_rank_view_verify_operator_bounds<R + 1>(rank, map, args...);
236template <
unsigned,
class MapType>
237inline void dyn_rank_view_error_operator_bounds(
char*,
int,
const MapType&) {}
239template <
unsigned R,
class MapType,
class iType,
class... Args>
240inline void dyn_rank_view_error_operator_bounds(
char* buf,
int len,
242 const iType& i, Args... args) {
243 const int n = snprintf(
244 buf, len,
" %ld < %ld %c",
static_cast<unsigned long>(i),
245 static_cast<unsigned long>(map.extent(R)), (
sizeof...(Args) ?
',' :
')'));
246 dyn_rank_view_error_operator_bounds<R + 1>(buf + n, len - n, map, args...);
250template <
typename MemorySpace,
typename iType0,
typename iType1,
class MapType,
253 const iType0& op_rank,
const iType1& rank,
254 const Kokkos::Impl::SharedAllocationTracker& tracker,
const MapType& map,
256 if (
static_cast<iType0
>(rank) > op_rank) {
258 "DynRankView Bounds Checking Error: Need at least rank arguments to "
262 if (!dyn_rank_view_verify_operator_bounds<0>(rank, map, args...)) {
264 (
enum {LEN = 1024};
char buffer[LEN];
265 const std::string label = tracker.template get_label<MemorySpace>();
266 int n = snprintf(buffer, LEN,
"DynRankView bounds error of view %s (",
268 dyn_rank_view_error_operator_bounds<0>(buffer + n, LEN - n, map,
270 Kokkos::Impl::throw_runtime_exception(std::string(buffer));))
273 ((
void)tracker; Kokkos::abort("DynRankView bounds error");))
284template <
class DstTraits,
class SrcTraits>
286 DstTraits, SrcTraits,
287 std::enable_if_t<(std::is_same<typename DstTraits::memory_space,
288 typename SrcTraits::memory_space>::value &&
289 std::is_void<typename DstTraits::specialize>::value &&
290 std::is_void<typename SrcTraits::specialize>::value &&
291 (std::is_same<typename DstTraits::array_layout,
292 typename SrcTraits::array_layout>::value ||
293 ((std::is_same<typename DstTraits::array_layout,
294 Kokkos::LayoutLeft>::value ||
295 std::is_same<typename DstTraits::array_layout,
296 Kokkos::LayoutRight>::value ||
297 std::is_same<typename DstTraits::array_layout,
298 Kokkos::LayoutStride>::value) &&
299 (std::is_same<typename SrcTraits::array_layout,
300 Kokkos::LayoutLeft>::value ||
301 std::is_same<typename SrcTraits::array_layout,
302 Kokkos::LayoutRight>::value ||
303 std::is_same<typename SrcTraits::array_layout,
304 Kokkos::LayoutStride>::value)))),
305 Kokkos::Impl::ViewToDynRankViewTag>> {
308 is_assignable_value_type =
309 std::is_same<
typename DstTraits::value_type,
310 typename SrcTraits::value_type>::value ||
311 std::is_same<
typename DstTraits::value_type,
312 typename SrcTraits::const_value_type>::value
316 is_assignable_layout =
317 std::is_same<
typename DstTraits::array_layout,
318 typename SrcTraits::array_layout>::value ||
319 std::is_same<
typename DstTraits::array_layout,
324 enum { is_assignable = is_assignable_value_type && is_assignable_layout };
326 using DstType = ViewMapping<DstTraits, typename DstTraits::specialize>;
327 using SrcType = ViewMapping<SrcTraits, typename SrcTraits::specialize>;
329 template <
typename DT,
typename... DP,
typename ST,
typename... SP>
330 KOKKOS_INLINE_FUNCTION
static void assign(
333 is_assignable_value_type,
334 "View assignment must have same value type or const = non-const");
337 is_assignable_layout,
338 "View assignment must have compatible layout or have rank <= 1");
342 using dst_offset_type =
typename DstType::offset_type;
343 dst.m_map.m_impl_offset = dst_offset_type(
344 std::integral_constant<unsigned, 0>(),
346 dst.m_map.m_impl_handle = Kokkos::Impl::ViewDataHandle<DstTraits>::assign(
347 src.m_map.m_impl_handle, src.m_track.m_tracker);
348 dst.m_track.assign(src.m_track.m_tracker, DstTraits::is_managed);
349 dst.m_rank = src.Rank;
372struct is_dyn_rank_view :
public std::false_type {};
374template <
class D,
class... P>
375struct is_dyn_rank_view<Kokkos::DynRankView<D, P...>> :
public std::true_type {
378template <
typename DataType,
class... Properties>
379class DynRankView :
public ViewTraits<DataType, Properties...> {
380 static_assert(!std::is_array<DataType>::value &&
381 !std::is_pointer<DataType>::value,
382 "Cannot template DynRankView with array or pointer datatype - "
386 template <
class,
class...>
387 friend class DynRankView;
388 template <
class,
class...>
389 friend class Kokkos::Impl::ViewMapping;
392 using drvtraits = ViewTraits<DataType, Properties...>;
394 using view_type =
View<DataType*******, Properties...>;
396 using traits = ViewTraits<DataType*******, Properties...>;
400 Kokkos::Impl::ViewMapping<traits, typename traits::specialize>;
401 using track_type = Kokkos::Impl::SharedAllocationTracker;
408 KOKKOS_INLINE_FUNCTION
409 view_type& DownCast()
const {
return (view_type&)(*this); }
410 KOKKOS_INLINE_FUNCTION
411 const view_type& ConstDownCast()
const {
return (
const view_type&)(*this); }
417 using array_type = DynRankView<
418 typename drvtraits::scalar_array_type,
typename drvtraits::array_layout,
419 typename drvtraits::device_type,
typename drvtraits::memory_traits>;
422 using const_type = DynRankView<
423 typename drvtraits::const_data_type,
typename drvtraits::array_layout,
424 typename drvtraits::device_type,
typename drvtraits::memory_traits>;
427 using non_const_type = DynRankView<
428 typename drvtraits::non_const_data_type,
typename drvtraits::array_layout,
429 typename drvtraits::device_type,
typename drvtraits::memory_traits>;
432 using HostMirror = DynRankView<
typename drvtraits::non_const_data_type,
433 typename drvtraits::array_layout,
434 typename drvtraits::host_mirror_space>;
442 template <
typename iType>
443 KOKKOS_INLINE_FUNCTION
constexpr std::enable_if_t<
444 std::is_integral<iType>::value,
size_t>
445 extent(
const iType& r)
const {
446 return m_map.extent(r);
449 template <
typename iType>
450 KOKKOS_INLINE_FUNCTION
constexpr std::enable_if_t<
451 std::is_integral<iType>::value,
int>
452 extent_int(
const iType& r)
const {
453 return static_cast<int>(m_map.extent(r));
456 KOKKOS_INLINE_FUNCTION
constexpr typename traits::array_layout layout()
const;
463 KOKKOS_INLINE_FUNCTION
constexpr size_t size()
const {
464 return m_map.extent(0) * m_map.extent(1) * m_map.extent(2) *
465 m_map.extent(3) * m_map.extent(4) * m_map.extent(5) *
466 m_map.extent(6) * m_map.extent(7);
469 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_0()
const {
470 return m_map.stride_0();
472 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_1()
const {
473 return m_map.stride_1();
475 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_2()
const {
476 return m_map.stride_2();
478 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_3()
const {
479 return m_map.stride_3();
481 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_4()
const {
482 return m_map.stride_4();
484 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_5()
const {
485 return m_map.stride_5();
487 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_6()
const {
488 return m_map.stride_6();
490 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_7()
const {
491 return m_map.stride_7();
494 template <
typename iType>
495 KOKKOS_INLINE_FUNCTION
void stride(iType*
const s)
const {
502 using reference_type =
typename map_type::reference_type;
503 using pointer_type =
typename map_type::pointer_type;
506 reference_type_is_lvalue_reference =
507 std::is_lvalue_reference<reference_type>::value
510 KOKKOS_INLINE_FUNCTION
constexpr size_t span()
const {
return m_map.span(); }
511 KOKKOS_INLINE_FUNCTION
constexpr bool span_is_contiguous()
const {
512 return m_map.span_is_contiguous();
514 KOKKOS_INLINE_FUNCTION
constexpr pointer_type data()
const {
517 KOKKOS_INLINE_FUNCTION
constexpr bool is_allocated()
const {
518 return (m_map.data() !=
nullptr);
523 KOKKOS_INLINE_FUNCTION
524 const Kokkos::Impl::ViewMapping<traits, typename traits::specialize>&
534 std::is_same<typename traits::array_layout, Kokkos::LayoutLeft>::value,
537 std::is_same<typename traits::array_layout, Kokkos::LayoutRight>::value,
539 is_layout_stride = std::is_same<
typename traits::array_layout,
542 is_default_map = std::is_void<typename traits::specialize>::value &&
543 (is_layout_left || is_layout_right || is_layout_stride)
547#if defined(KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK)
550#define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(ARG) \
551 Kokkos::Impl::runtime_check_memory_access_violation< \
552 typename traits::memory_space>( \
553 "Kokkos::DynRankView ERROR: attempt to access inaccessible memory " \
555 Kokkos::Impl::dyn_rank_view_verify_operator_bounds< \
556 typename traits::memory_space> \
561#define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(ARG) \
562 Kokkos::Impl::runtime_check_memory_access_violation< \
563 typename traits::memory_space>( \
564 "Kokkos::DynRankView ERROR: attempt to access inaccessible memory " \
570 KOKKOS_INLINE_FUNCTION
571 constexpr unsigned rank()
const {
return m_rank; }
575 KOKKOS_INLINE_FUNCTION
576 reference_type operator()()
const {
577 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((0, this->rank(), m_track, m_map))
578 return impl_map().reference();
585 template <
typename iType>
586 KOKKOS_INLINE_FUNCTION std::enable_if_t<
587 std::is_same<
typename drvtraits::value_type,
588 typename drvtraits::scalar_array_type>::value &&
589 std::is_integral<iType>::value,
591 operator[](
const iType& i0)
const {
600 template <
typename iType>
601 KOKKOS_INLINE_FUNCTION std::enable_if_t<
602 !std::is_same<
typename drvtraits::value_type,
603 typename drvtraits::scalar_array_type>::value &&
604 std::is_integral<iType>::value,
606 operator[](
const iType& i0)
const {
608 const size_t dim_scalar = m_map.dimension_scalar();
609 const size_t bytes = this->span() / dim_scalar;
612 DataType*,
typename traits::array_layout,
typename traits::device_type,
613 Kokkos::MemoryTraits<traits::memory_traits::is_unmanaged |
614 traits::memory_traits::is_random_access |
615 traits::memory_traits::is_atomic>>;
616 tmp_view_type rankone_view(this->data(), bytes, dim_scalar);
617 return rankone_view(i0);
621 template <
typename iType>
622 KOKKOS_INLINE_FUNCTION
623 std::enable_if_t<(std::is_void<typename traits::specialize>::value &&
624 std::is_integral<iType>::value),
626 operator()(
const iType& i0)
const {
627 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((1, this->rank(), m_track, m_map, i0))
628 return m_map.reference(i0);
631 template <
typename iType>
632 KOKKOS_INLINE_FUNCTION
633 std::enable_if_t<!(std::is_void<typename traits::specialize>::value &&
634 std::is_integral<iType>::value),
636 operator()(
const iType& i0)
const {
637 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((1, this->rank(), m_track, m_map, i0))
638 return m_map.reference(i0, 0, 0, 0, 0, 0, 0);
642 template <
typename iType0,
typename iType1>
643 KOKKOS_INLINE_FUNCTION std::enable_if_t<
644 (std::is_void<typename traits::specialize>::value &&
645 std::is_integral<iType0>::value && std::is_integral<iType1>::value),
647 operator()(
const iType0& i0,
const iType1& i1)
const {
648 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((2, this->rank(), m_track, m_map, i0, i1))
649 return m_map.reference(i0, i1);
652 template <
typename iType0,
typename iType1>
653 KOKKOS_INLINE_FUNCTION
654 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
655 std::is_integral<iType0>::value),
657 operator()(
const iType0& i0,
const iType1& i1)
const {
658 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((2, this->rank(), m_track, m_map, i0, i1))
659 return m_map.reference(i0, i1, 0, 0, 0, 0, 0);
663 template <
typename iType0,
typename iType1,
typename iType2>
664 KOKKOS_INLINE_FUNCTION std::enable_if_t<
665 (std::is_void<typename traits::specialize>::value &&
666 std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
667 std::is_integral<iType2>::value),
669 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2)
const {
670 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
671 (3, this->rank(), m_track, m_map, i0, i1, i2))
672 return m_map.reference(i0, i1, i2);
675 template <
typename iType0,
typename iType1,
typename iType2>
676 KOKKOS_INLINE_FUNCTION
677 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
678 std::is_integral<iType0>::value),
680 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2)
const {
681 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
682 (3, this->rank(), m_track, m_map, i0, i1, i2))
683 return m_map.reference(i0, i1, i2, 0, 0, 0, 0);
687 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3>
688 KOKKOS_INLINE_FUNCTION std::enable_if_t<
689 (std::is_void<typename traits::specialize>::value &&
690 std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
691 std::is_integral<iType2>::value && std::is_integral<iType3>::value),
693 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2,
694 const iType3& i3)
const {
695 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
696 (4, this->rank(), m_track, m_map, i0, i1, i2, i3))
697 return m_map.reference(i0, i1, i2, i3);
700 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3>
701 KOKKOS_INLINE_FUNCTION
702 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
703 std::is_integral<iType0>::value),
705 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2,
706 const iType3& i3)
const {
707 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
708 (4, this->rank(), m_track, m_map, i0, i1, i2, i3))
709 return m_map.reference(i0, i1, i2, i3, 0, 0, 0);
713 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
715 KOKKOS_INLINE_FUNCTION std::enable_if_t<
716 (std::is_void<typename traits::specialize>::value &&
717 std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
718 std::is_integral<iType2>::value && std::is_integral<iType3>::value &&
719 std::is_integral<iType4>::value),
721 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2,
722 const iType3& i3,
const iType4& i4)
const {
723 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
724 (5, this->rank(), m_track, m_map, i0, i1, i2, i3, i4))
725 return m_map.reference(i0, i1, i2, i3, i4);
728 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
730 KOKKOS_INLINE_FUNCTION
731 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
732 std::is_integral<iType0>::value),
734 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2,
735 const iType3& i3,
const iType4& i4)
const {
736 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
737 (5, this->rank(), m_track, m_map, i0, i1, i2, i3, i4))
738 return m_map.reference(i0, i1, i2, i3, i4, 0, 0);
742 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
743 typename iType4,
typename iType5>
744 KOKKOS_INLINE_FUNCTION std::enable_if_t<
745 (std::is_void<typename traits::specialize>::value &&
746 std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
747 std::is_integral<iType2>::value && std::is_integral<iType3>::value &&
748 std::is_integral<iType4>::value && std::is_integral<iType5>::value),
750 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2,
751 const iType3& i3,
const iType4& i4,
const iType5& i5)
const {
752 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
753 (6, this->rank(), m_track, m_map, i0, i1, i2, i3, i4, i5))
754 return m_map.reference(i0, i1, i2, i3, i4, i5);
757 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
758 typename iType4,
typename iType5>
759 KOKKOS_INLINE_FUNCTION
760 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
761 std::is_integral<iType0>::value),
763 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2,
764 const iType3& i3,
const iType4& i4,
const iType5& i5)
const {
765 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
766 (6, this->rank(), m_track, m_map, i0, i1, i2, i3, i4, i5))
767 return m_map.reference(i0, i1, i2, i3, i4, i5, 0);
771 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
772 typename iType4,
typename iType5,
typename iType6>
773 KOKKOS_INLINE_FUNCTION std::enable_if_t<
774 (std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
775 std::is_integral<iType2>::value && std::is_integral<iType3>::value &&
776 std::is_integral<iType4>::value && std::is_integral<iType5>::value &&
777 std::is_integral<iType6>::value),
779 operator()(
const iType0& i0,
const iType1& i1,
const iType2& i2,
780 const iType3& i3,
const iType4& i4,
const iType5& i5,
781 const iType6& i6)
const {
782 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
783 (7, this->rank(), m_track, m_map, i0, i1, i2, i3, i4, i5, i6))
784 return m_map.reference(i0, i1, i2, i3, i4, i5, i6);
788 KOKKOS_INLINE_FUNCTION
789 reference_type access()
const {
790 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((0, this->rank(), m_track, m_map))
791 return impl_map().reference();
797 template <
typename iType>
798 KOKKOS_INLINE_FUNCTION
799 std::enable_if_t<(std::is_void<typename traits::specialize>::value &&
800 std::is_integral<iType>::value),
802 access(
const iType& i0)
const {
803 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((1, this->rank(), m_track, m_map, i0))
804 return m_map.reference(i0);
807 template <
typename iType>
808 KOKKOS_INLINE_FUNCTION
809 std::enable_if_t<!(std::is_void<typename traits::specialize>::value &&
810 std::is_integral<iType>::value),
812 access(
const iType& i0)
const {
813 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((1, this->rank(), m_track, m_map, i0))
814 return m_map.reference(i0, 0, 0, 0, 0, 0, 0);
818 template <
typename iType0,
typename iType1>
819 KOKKOS_INLINE_FUNCTION std::enable_if_t<
820 (std::is_void<typename traits::specialize>::value &&
821 std::is_integral<iType0>::value && std::is_integral<iType1>::value),
823 access(
const iType0& i0,
const iType1& i1)
const {
824 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((2, this->rank(), m_track, m_map, i0, i1))
825 return m_map.reference(i0, i1);
828 template <
typename iType0,
typename iType1>
829 KOKKOS_INLINE_FUNCTION
830 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
831 std::is_integral<iType0>::value),
833 access(
const iType0& i0,
const iType1& i1)
const {
834 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((2, this->rank(), m_track, m_map, i0, i1))
835 return m_map.reference(i0, i1, 0, 0, 0, 0, 0);
839 template <
typename iType0,
typename iType1,
typename iType2>
840 KOKKOS_INLINE_FUNCTION std::enable_if_t<
841 (std::is_void<typename traits::specialize>::value &&
842 std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
843 std::is_integral<iType2>::value),
845 access(
const iType0& i0,
const iType1& i1,
const iType2& i2)
const {
846 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
847 (3, this->rank(), m_track, m_map, i0, i1, i2))
848 return m_map.reference(i0, i1, i2);
851 template <
typename iType0,
typename iType1,
typename iType2>
852 KOKKOS_INLINE_FUNCTION
853 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
854 std::is_integral<iType0>::value),
856 access(
const iType0& i0,
const iType1& i1,
const iType2& i2)
const {
857 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
858 (3, this->rank(), m_track, m_map, i0, i1, i2))
859 return m_map.reference(i0, i1, i2, 0, 0, 0, 0);
863 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3>
864 KOKKOS_INLINE_FUNCTION std::enable_if_t<
865 (std::is_void<typename traits::specialize>::value &&
866 std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
867 std::is_integral<iType2>::value && std::is_integral<iType3>::value),
869 access(
const iType0& i0,
const iType1& i1,
const iType2& i2,
870 const iType3& i3)
const {
871 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
872 (4, this->rank(), m_track, m_map, i0, i1, i2, i3))
873 return m_map.reference(i0, i1, i2, i3);
876 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3>
877 KOKKOS_INLINE_FUNCTION
878 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
879 std::is_integral<iType0>::value),
881 access(
const iType0& i0,
const iType1& i1,
const iType2& i2,
882 const iType3& i3)
const {
883 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
884 (4, this->rank(), m_track, m_map, i0, i1, i2, i3))
885 return m_map.reference(i0, i1, i2, i3, 0, 0, 0);
889 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
891 KOKKOS_INLINE_FUNCTION std::enable_if_t<
892 (std::is_void<typename traits::specialize>::value &&
893 std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
894 std::is_integral<iType2>::value && std::is_integral<iType3>::value &&
895 std::is_integral<iType4>::value),
897 access(
const iType0& i0,
const iType1& i1,
const iType2& i2,
const iType3& i3,
898 const iType4& i4)
const {
899 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
900 (5, this->rank(), m_track, m_map, i0, i1, i2, i3, i4))
901 return m_map.reference(i0, i1, i2, i3, i4);
904 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
906 KOKKOS_INLINE_FUNCTION
907 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
908 std::is_integral<iType0>::value),
910 access(
const iType0& i0,
const iType1& i1,
const iType2& i2,
911 const iType3& i3,
const iType4& i4)
const {
912 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
913 (5, this->rank(), m_track, m_map, i0, i1, i2, i3, i4))
914 return m_map.reference(i0, i1, i2, i3, i4, 0, 0);
918 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
919 typename iType4,
typename iType5>
920 KOKKOS_INLINE_FUNCTION std::enable_if_t<
921 (std::is_void<typename traits::specialize>::value &&
922 std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
923 std::is_integral<iType2>::value && std::is_integral<iType3>::value &&
924 std::is_integral<iType4>::value && std::is_integral<iType5>::value),
926 access(
const iType0& i0,
const iType1& i1,
const iType2& i2,
const iType3& i3,
927 const iType4& i4,
const iType5& i5)
const {
928 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
929 (6, this->rank(), m_track, m_map, i0, i1, i2, i3, i4, i5))
930 return m_map.reference(i0, i1, i2, i3, i4, i5);
933 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
934 typename iType4,
typename iType5>
935 KOKKOS_INLINE_FUNCTION
936 std::enable_if_t<!(std::is_void<typename drvtraits::specialize>::value &&
937 std::is_integral<iType0>::value),
939 access(
const iType0& i0,
const iType1& i1,
const iType2& i2,
940 const iType3& i3,
const iType4& i4,
const iType5& i5)
const {
941 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
942 (6, this->rank(), m_track, m_map, i0, i1, i2, i3, i4, i5))
943 return m_map.reference(i0, i1, i2, i3, i4, i5, 0);
947 template <
typename iType0,
typename iType1,
typename iType2,
typename iType3,
948 typename iType4,
typename iType5,
typename iType6>
949 KOKKOS_INLINE_FUNCTION std::enable_if_t<
950 (std::is_integral<iType0>::value && std::is_integral<iType1>::value &&
951 std::is_integral<iType2>::value && std::is_integral<iType3>::value &&
952 std::is_integral<iType4>::value && std::is_integral<iType5>::value &&
953 std::is_integral<iType6>::value),
955 access(
const iType0& i0,
const iType1& i1,
const iType2& i2,
const iType3& i3,
956 const iType4& i4,
const iType5& i5,
const iType6& i6)
const {
957 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
958 (7, this->rank(), m_track, m_map, i0, i1, i2, i3, i4, i5, i6))
959 return m_map.reference(i0, i1, i2, i3, i4, i5, i6);
962#undef KOKKOS_IMPL_VIEW_OPERATOR_VERIFY
967 KOKKOS_DEFAULTED_FUNCTION
968 ~DynRankView() =
default;
970 KOKKOS_INLINE_FUNCTION
971 DynRankView() : m_track(), m_map(), m_rank() {}
973 KOKKOS_INLINE_FUNCTION
974 DynRankView(
const DynRankView& rhs)
975 : m_track(rhs.m_track), m_map(rhs.m_map), m_rank(rhs.m_rank) {}
977 KOKKOS_INLINE_FUNCTION
978 DynRankView(DynRankView&& rhs)
979 : m_track(rhs.m_track), m_map(rhs.m_map), m_rank(rhs.m_rank) {}
981 KOKKOS_INLINE_FUNCTION
982 DynRankView& operator=(
const DynRankView& rhs) {
983 m_track = rhs.m_track;
989 KOKKOS_INLINE_FUNCTION
990 DynRankView& operator=(DynRankView&& rhs) {
991 m_track = rhs.m_track;
1000 template <
class RT,
class... RP>
1001 KOKKOS_INLINE_FUNCTION DynRankView(
const DynRankView<RT, RP...>& rhs)
1002 : m_track(rhs.m_track, traits::is_managed), m_map(), m_rank(rhs.m_rank) {
1003 using SrcTraits =
typename DynRankView<RT, RP...>::traits;
1004 using Mapping = Kokkos::Impl::ViewMapping<traits, SrcTraits,
1005 typename traits::specialize>;
1006 static_assert(Mapping::is_assignable,
1007 "Incompatible DynRankView copy construction");
1008 Mapping::assign(m_map, rhs.m_map, rhs.m_track);
1011 template <
class RT,
class... RP>
1012 KOKKOS_INLINE_FUNCTION DynRankView& operator=(
1013 const DynRankView<RT, RP...>& rhs) {
1014 using SrcTraits =
typename DynRankView<RT, RP...>::traits;
1015 using Mapping = Kokkos::Impl::ViewMapping<traits, SrcTraits,
1016 typename traits::specialize>;
1017 static_assert(Mapping::is_assignable,
1018 "Incompatible DynRankView copy construction");
1019 Mapping::assign(m_map, rhs.m_map, rhs.m_track);
1020 m_track.assign(rhs.m_track, traits::is_managed);
1021 m_rank = rhs.rank();
1026 template <
class RT,
class... RP>
1027 KOKKOS_INLINE_FUNCTION DynRankView(
const View<RT, RP...>& rhs)
1028 : m_track(), m_map(), m_rank(rhs.Rank) {
1029 using SrcTraits =
typename View<RT, RP...>::traits;
1031 Kokkos::Impl::ViewMapping<traits, SrcTraits,
1033 static_assert(Mapping::is_assignable,
1034 "Incompatible View to DynRankView copy construction");
1035 Mapping::assign(*
this, rhs);
1038 template <
class RT,
class... RP>
1039 KOKKOS_INLINE_FUNCTION DynRankView& operator=(
const View<RT, RP...>& rhs) {
1040 using SrcTraits =
typename View<RT, RP...>::traits;
1042 Kokkos::Impl::ViewMapping<traits, SrcTraits,
1044 static_assert(Mapping::is_assignable,
1045 "Incompatible View to DynRankView copy assignment");
1046 Mapping::assign(*
this, rhs);
1053 KOKKOS_INLINE_FUNCTION
1054 int use_count()
const {
return m_track.use_count(); }
1056 inline const std::string label()
const {
1057 return m_track.template get_label<typename traits::memory_space>();
1064 template <
class... P>
1065 explicit inline DynRankView(
1066 const Kokkos::Impl::ViewCtorProp<P...>& arg_prop,
1067 std::enable_if_t<!Kokkos::Impl::ViewCtorProp<P...>::has_pointer,
1068 typename traits::array_layout>
const& arg_layout)
1071 m_rank(Impl::DynRankDimTraits<typename traits::specialize>::
1072 template computeRank<typename traits::array_layout, P...>(
1073 arg_prop, arg_layout)) {
1075 auto prop_copy = Impl::with_properties_if_unset(
1076 arg_prop, std::string{},
typename traits::device_type::memory_space{},
1077 typename traits::device_type::execution_space{});
1078 using alloc_prop =
decltype(prop_copy);
1080 static_assert(traits::is_managed,
1081 "View allocation constructor requires managed memory");
1083 if (alloc_prop::initialize &&
1084 !alloc_prop::execution_space::impl_is_initialized()) {
1087 Kokkos::Impl::throw_runtime_exception(
1088 "Constructing DynRankView and initializing data with uninitialized "
1093#if defined(KOKKOS_ENABLE_CUDA)
1099 if (std::is_same<Kokkos::CudaUVMSpace,
1100 typename traits::device_type::memory_space>::value) {
1101 typename traits::device_type::memory_space::execution_space().fence(
1102 "Kokkos::DynRankView<>::DynRankView: fence before UVM allocation");
1107 Kokkos::Impl::SharedAllocationRecord<>* record = m_map.allocate_shared(
1109 Impl::DynRankDimTraits<typename traits::specialize>::
1110 template createLayout<traits, P...>(arg_prop, arg_layout),
1111 Impl::ViewCtorProp<P...>::has_execution_space);
1114#if defined(KOKKOS_ENABLE_CUDA)
1115 if (std::is_same<Kokkos::CudaUVMSpace,
1116 typename traits::device_type::memory_space>::value) {
1117 typename traits::device_type::memory_space::execution_space().fence(
1118 "Kokkos::DynRankView<>::DynRankView: fence after UVM allocation");
1124 m_track.assign_allocated_record_to_uninitialized(record);
1128 template <
class... P>
1129 explicit KOKKOS_INLINE_FUNCTION DynRankView(
1130 const Kokkos::Impl::ViewCtorProp<P...>& arg_prop,
1131 std::enable_if_t<Kokkos::Impl::ViewCtorProp<P...>::has_pointer,
1132 typename traits::array_layout>
const& arg_layout)
1136 Impl::DynRankDimTraits<typename traits::specialize>::
1137 template createLayout<traits, P...>(arg_prop, arg_layout)),
1138 m_rank(Impl::DynRankDimTraits<typename traits::specialize>::
1139 template computeRank<typename traits::array_layout, P...>(
1140 arg_prop, arg_layout)) {
1142 std::is_same<pointer_type,
1143 typename Impl::ViewCtorProp<P...>::pointer_type>::value,
1144 "Constructing DynRankView to wrap user memory must supply matching "
1152 template <
class... P>
1153 explicit inline DynRankView(
1154 const Kokkos::Impl::ViewCtorProp<P...>& arg_prop,
1155 std::enable_if_t<!Kokkos::Impl::ViewCtorProp<P...>::has_pointer,
1156 size_t>
const arg_N0 = KOKKOS_INVALID_INDEX,
1157 const size_t arg_N1 = KOKKOS_INVALID_INDEX,
1158 const size_t arg_N2 = KOKKOS_INVALID_INDEX,
1159 const size_t arg_N3 = KOKKOS_INVALID_INDEX,
1160 const size_t arg_N4 = KOKKOS_INVALID_INDEX,
1161 const size_t arg_N5 = KOKKOS_INVALID_INDEX,
1162 const size_t arg_N6 = KOKKOS_INVALID_INDEX,
1163 const size_t arg_N7 = KOKKOS_INVALID_INDEX)
1164 : DynRankView(arg_prop, typename traits::array_layout(
1165 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4,
1166 arg_N5, arg_N6, arg_N7)) {}
1168 template <
class... P>
1169 explicit KOKKOS_INLINE_FUNCTION DynRankView(
1170 const Kokkos::Impl::ViewCtorProp<P...>& arg_prop,
1171 std::enable_if_t<Kokkos::Impl::ViewCtorProp<P...>::has_pointer,
1172 size_t>
const arg_N0 = KOKKOS_INVALID_INDEX,
1173 const size_t arg_N1 = KOKKOS_INVALID_INDEX,
1174 const size_t arg_N2 = KOKKOS_INVALID_INDEX,
1175 const size_t arg_N3 = KOKKOS_INVALID_INDEX,
1176 const size_t arg_N4 = KOKKOS_INVALID_INDEX,
1177 const size_t arg_N5 = KOKKOS_INVALID_INDEX,
1178 const size_t arg_N6 = KOKKOS_INVALID_INDEX,
1179 const size_t arg_N7 = KOKKOS_INVALID_INDEX)
1180 : DynRankView(arg_prop, typename traits::array_layout(
1181 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4,
1182 arg_N5, arg_N6, arg_N7)) {}
1185 template <
typename Label>
1186 explicit inline DynRankView(
1187 const Label& arg_label,
1188 std::enable_if_t<Kokkos::Impl::is_view_label<Label>::value,
1189 typename traits::array_layout>
const& arg_layout)
1190 : DynRankView(Kokkos::Impl::ViewCtorProp<std::string>(arg_label),
1194 template <
typename Label>
1195 explicit inline DynRankView(
1196 const Label& arg_label,
1197 std::enable_if_t<Kokkos::Impl::is_view_label<Label>::value,
const size_t>
1198 arg_N0 = KOKKOS_INVALID_INDEX,
1199 const size_t arg_N1 = KOKKOS_INVALID_INDEX,
1200 const size_t arg_N2 = KOKKOS_INVALID_INDEX,
1201 const size_t arg_N3 = KOKKOS_INVALID_INDEX,
1202 const size_t arg_N4 = KOKKOS_INVALID_INDEX,
1203 const size_t arg_N5 = KOKKOS_INVALID_INDEX,
1204 const size_t arg_N6 = KOKKOS_INVALID_INDEX,
1205 const size_t arg_N7 = KOKKOS_INVALID_INDEX)
1207 Kokkos::Impl::ViewCtorProp<std::string>(arg_label),
1208 typename traits::array_layout(arg_N0, arg_N1, arg_N2, arg_N3,
1209 arg_N4, arg_N5, arg_N6, arg_N7)) {}
1213 static constexpr size_t required_allocation_size(
1214 const size_t arg_N0 = 0,
const size_t arg_N1 = 0,
const size_t arg_N2 = 0,
1215 const size_t arg_N3 = 0,
const size_t arg_N4 = 0,
const size_t arg_N5 = 0,
1216 const size_t arg_N6 = 0,
const size_t arg_N7 = 0) {
1217 return map_type::memory_span(
typename traits::array_layout(
1218 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7));
1221 explicit KOKKOS_INLINE_FUNCTION DynRankView(
1222 pointer_type arg_ptr,
const size_t arg_N0 = KOKKOS_INVALID_INDEX,
1223 const size_t arg_N1 = KOKKOS_INVALID_INDEX,
1224 const size_t arg_N2 = KOKKOS_INVALID_INDEX,
1225 const size_t arg_N3 = KOKKOS_INVALID_INDEX,
1226 const size_t arg_N4 = KOKKOS_INVALID_INDEX,
1227 const size_t arg_N5 = KOKKOS_INVALID_INDEX,
1228 const size_t arg_N6 = KOKKOS_INVALID_INDEX,
1229 const size_t arg_N7 = KOKKOS_INVALID_INDEX)
1230 : DynRankView(Kokkos::Impl::ViewCtorProp<pointer_type>(arg_ptr), arg_N0,
1231 arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7) {}
1233 explicit KOKKOS_INLINE_FUNCTION DynRankView(
1234 pointer_type arg_ptr,
typename traits::array_layout& arg_layout)
1235 : DynRankView(Kokkos::Impl::ViewCtorProp<pointer_type>(arg_ptr),
1241 static inline size_t shmem_size(
const size_t arg_N0 = KOKKOS_INVALID_INDEX,
1242 const size_t arg_N1 = KOKKOS_INVALID_INDEX,
1243 const size_t arg_N2 = KOKKOS_INVALID_INDEX,
1244 const size_t arg_N3 = KOKKOS_INVALID_INDEX,
1245 const size_t arg_N4 = KOKKOS_INVALID_INDEX,
1246 const size_t arg_N5 = KOKKOS_INVALID_INDEX,
1247 const size_t arg_N6 = KOKKOS_INVALID_INDEX,
1248 const size_t arg_N7 = KOKKOS_INVALID_INDEX) {
1249 const size_t num_passed_args =
1250 (arg_N0 != KOKKOS_INVALID_INDEX) + (arg_N1 != KOKKOS_INVALID_INDEX) +
1251 (arg_N2 != KOKKOS_INVALID_INDEX) + (arg_N3 != KOKKOS_INVALID_INDEX) +
1252 (arg_N4 != KOKKOS_INVALID_INDEX) + (arg_N5 != KOKKOS_INVALID_INDEX) +
1253 (arg_N6 != KOKKOS_INVALID_INDEX) + (arg_N7 != KOKKOS_INVALID_INDEX);
1255 if (std::is_void<typename traits::specialize>::value &&
1256 num_passed_args != traits::rank_dynamic) {
1258 "Kokkos::View::shmem_size() rank_dynamic != number of arguments.\n");
1262 return map_type::memory_span(
typename traits::array_layout(
1263 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7));
1266 explicit KOKKOS_INLINE_FUNCTION DynRankView(
1267 const typename traits::execution_space::scratch_memory_space& arg_space,
1268 const typename traits::array_layout& arg_layout)
1270 Kokkos::Impl::ViewCtorProp<pointer_type>(
1271 reinterpret_cast<pointer_type>(
1272 arg_space.get_shmem(map_type::memory_span(
1273 Impl::DynRankDimTraits<typename traits::specialize>::
1274 createLayout(arg_layout)
1278 explicit KOKKOS_INLINE_FUNCTION DynRankView(
1279 const typename traits::execution_space::scratch_memory_space& arg_space,
1280 const size_t arg_N0 = KOKKOS_INVALID_INDEX,
1281 const size_t arg_N1 = KOKKOS_INVALID_INDEX,
1282 const size_t arg_N2 = KOKKOS_INVALID_INDEX,
1283 const size_t arg_N3 = KOKKOS_INVALID_INDEX,
1284 const size_t arg_N4 = KOKKOS_INVALID_INDEX,
1285 const size_t arg_N5 = KOKKOS_INVALID_INDEX,
1286 const size_t arg_N6 = KOKKOS_INVALID_INDEX,
1287 const size_t arg_N7 = KOKKOS_INVALID_INDEX)
1290 Kokkos::Impl::ViewCtorProp<pointer_type>(
1291 reinterpret_cast<pointer_type>(
1292 arg_space.get_shmem(map_type::memory_span(
1293 Impl::DynRankDimTraits<typename traits::specialize>::
1294 createLayout(typename traits::array_layout(
1295 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5,
1296 arg_N6, arg_N7)))))),
1297 typename traits::array_layout(arg_N0, arg_N1, arg_N2, arg_N3,
1298 arg_N4, arg_N5, arg_N6, arg_N7)) {}
1301template <
typename D,
class... P>
1302KOKKOS_INLINE_FUNCTION
constexpr unsigned rank(
1303 const DynRankView<D, P...>& DRV) {
1314struct DynRankSubviewTag {};
1320template <
class SrcTraits,
class... Args>
1322 std::enable_if_t<(std::is_void<typename SrcTraits::specialize>::value &&
1323 (std::is_same<typename SrcTraits::array_layout,
1324 Kokkos::LayoutLeft>::value ||
1325 std::is_same<typename SrcTraits::array_layout,
1326 Kokkos::LayoutRight>::value ||
1327 std::is_same<typename SrcTraits::array_layout,
1328 Kokkos::LayoutStride>::value)),
1329 Kokkos::Impl::DynRankSubviewTag>,
1330 SrcTraits, Args...> {
1334 R0 = bool(is_integral_extent<0, Args...>::value),
1335 R1 = bool(is_integral_extent<1, Args...>::value),
1336 R2 = bool(is_integral_extent<2, Args...>::value),
1337 R3 = bool(is_integral_extent<3, Args...>::value),
1338 R4 = bool(is_integral_extent<4, Args...>::value),
1339 R5 = bool(is_integral_extent<5, Args...>::value),
1340 R6 = bool(is_integral_extent<6, Args...>::value)
1344 rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3) +
1345 unsigned(R4) + unsigned(R5) + unsigned(R6)
1350 using value_type =
typename SrcTraits::value_type;
1352 using data_type = value_type*******;
1356 typename SrcTraits::device_type,
1357 typename SrcTraits::memory_traits>;
1360 Kokkos::View<data_type, array_layout,
typename SrcTraits::device_type,
1361 typename SrcTraits::memory_traits>;
1363 template <
class MemoryTraits>
1365 static_assert(Kokkos::is_memory_traits<MemoryTraits>::value,
"");
1369 typename SrcTraits::device_type, MemoryTraits>;
1372 typename SrcTraits::device_type, MemoryTraits>;
1375 using dimension =
typename SrcTraits::dimension;
1377 template <
class Arg0 = int,
class Arg1 = int,
class Arg2 = int,
1378 class Arg3 = int,
class Arg4 = int,
class Arg5 = int,
1380 struct ExtentGenerator {
1381 KOKKOS_INLINE_FUNCTION
1382 static SubviewExtents<7, rank> generator(
1383 const dimension& dim, Arg0 arg0 = Arg0(), Arg1 arg1 = Arg1(),
1384 Arg2 arg2 = Arg2(), Arg3 arg3 = Arg3(), Arg4 arg4 = Arg4(),
1385 Arg5 arg5 = Arg5(), Arg6 arg6 = Arg6()) {
1386 return SubviewExtents<7, rank>(dim, arg0, arg1, arg2, arg3, arg4, arg5,
1391 using ret_type = Kokkos::DynRankView<value_type, array_layout,
1392 typename SrcTraits::device_type,
1393 typename SrcTraits::memory_traits>;
1395 template <
typename T,
class... P>
1396 KOKKOS_INLINE_FUNCTION
static ret_type subview(
1397 const unsigned src_rank, Kokkos::DynRankView<T, P...>
const& src,
1399 using DstType = ViewMapping<traits_type, typename traits_type::specialize>;
1401 using DstDimType = std::conditional_t<
1402 (rank == 0), ViewDimension<>,
1404 (rank == 1), ViewDimension<0>,
1406 (rank == 2), ViewDimension<0, 0>,
1408 (rank == 3), ViewDimension<0, 0, 0>,
1410 (rank == 4), ViewDimension<0, 0, 0, 0>,
1412 (rank == 5), ViewDimension<0, 0, 0, 0, 0>,
1414 (rank == 6), ViewDimension<0, 0, 0, 0, 0, 0>,
1415 ViewDimension<0, 0, 0, 0, 0, 0, 0>>>>>>>>;
1417 using dst_offset_type = ViewOffset<DstDimType, Kokkos::LayoutStride>;
1418 using dst_handle_type =
typename DstType::handle_type;
1422 const SubviewExtents<7, rank> extents = ExtentGenerator<Args...>::generator(
1423 src.m_map.m_impl_offset.m_dim, args...);
1425 dst_offset_type tempdst(src.m_map.m_impl_offset, extents);
1427 dst.m_track = src.m_track;
1429 dst.m_map.m_impl_offset.m_dim.N0 = tempdst.m_dim.N0;
1430 dst.m_map.m_impl_offset.m_dim.N1 = tempdst.m_dim.N1;
1431 dst.m_map.m_impl_offset.m_dim.N2 = tempdst.m_dim.N2;
1432 dst.m_map.m_impl_offset.m_dim.N3 = tempdst.m_dim.N3;
1433 dst.m_map.m_impl_offset.m_dim.N4 = tempdst.m_dim.N4;
1434 dst.m_map.m_impl_offset.m_dim.N5 = tempdst.m_dim.N5;
1435 dst.m_map.m_impl_offset.m_dim.N6 = tempdst.m_dim.N6;
1437 dst.m_map.m_impl_offset.m_stride.S0 = tempdst.m_stride.S0;
1438 dst.m_map.m_impl_offset.m_stride.S1 = tempdst.m_stride.S1;
1439 dst.m_map.m_impl_offset.m_stride.S2 = tempdst.m_stride.S2;
1440 dst.m_map.m_impl_offset.m_stride.S3 = tempdst.m_stride.S3;
1441 dst.m_map.m_impl_offset.m_stride.S4 = tempdst.m_stride.S4;
1442 dst.m_map.m_impl_offset.m_stride.S5 = tempdst.m_stride.S5;
1443 dst.m_map.m_impl_offset.m_stride.S6 = tempdst.m_stride.S6;
1445 dst.m_map.m_impl_handle =
1446 dst_handle_type(src.m_map.m_impl_handle +
1447 src.m_map.m_impl_offset(
1448 extents.domain_offset(0), extents.domain_offset(1),
1449 extents.domain_offset(2), extents.domain_offset(3),
1450 extents.domain_offset(4), extents.domain_offset(5),
1451 extents.domain_offset(6)));
1454 (src_rank > 0 ? unsigned(R0) : 0) + (src_rank > 1 ? unsigned(R1) : 0) +
1455 (src_rank > 2 ? unsigned(R2) : 0) + (src_rank > 3 ? unsigned(R3) : 0) +
1456 (src_rank > 4 ? unsigned(R4) : 0) + (src_rank > 5 ? unsigned(R5) : 0) +
1457 (src_rank > 6 ? unsigned(R6) : 0);
1465template <
class V,
class... Args>
1466using Subdynrankview =
1467 typename Kokkos::Impl::ViewMapping<Kokkos::Impl::DynRankSubviewTag, V,
1470template <
class D,
class... P,
class... Args>
1471KOKKOS_INLINE_FUNCTION Subdynrankview<ViewTraits<D*******, P...>, Args...>
1472subdynrankview(
const Kokkos::DynRankView<D, P...>& src, Args... args) {
1473 if (src.rank() >
sizeof...(Args))
1477 "subdynrankview: num of args must be >= rank of the source "
1482 Kokkos::Impl::ViewMapping<Kokkos::Impl::DynRankSubviewTag,
1485 return metafcn::subview(src.rank(), src, args...);
1489template <
class D,
class... P,
class... Args>
1490KOKKOS_INLINE_FUNCTION Subdynrankview<ViewTraits<D*******, P...>, Args...>
1491subview(
const Kokkos::DynRankView<D, P...>& src, Args... args) {
1492 return subdynrankview(src, args...);
1500template <
class LT,
class... LP,
class RT,
class... RP>
1501KOKKOS_INLINE_FUNCTION
bool operator==(
const DynRankView<LT, LP...>& lhs,
1502 const DynRankView<RT, RP...>& rhs) {
1504 using lhs_traits = ViewTraits<LT, LP...>;
1505 using rhs_traits = ViewTraits<RT, RP...>;
1507 return std::is_same<
typename lhs_traits::const_value_type,
1508 typename rhs_traits::const_value_type>::value &&
1509 std::is_same<
typename lhs_traits::array_layout,
1510 typename rhs_traits::array_layout>::value &&
1511 std::is_same<
typename lhs_traits::memory_space,
1512 typename rhs_traits::memory_space>::value &&
1513 lhs.rank() == rhs.rank() && lhs.data() == rhs.data() &&
1514 lhs.span() == rhs.span() && lhs.extent(0) == rhs.extent(0) &&
1515 lhs.extent(1) == rhs.extent(1) && lhs.extent(2) == rhs.extent(2) &&
1516 lhs.extent(3) == rhs.extent(3) && lhs.extent(4) == rhs.extent(4) &&
1517 lhs.extent(5) == rhs.extent(5) && lhs.extent(6) == rhs.extent(6) &&
1518 lhs.extent(7) == rhs.extent(7);
1521template <
class LT,
class... LP,
class RT,
class... RP>
1522KOKKOS_INLINE_FUNCTION
bool operator!=(
const DynRankView<LT, LP...>& lhs,
1523 const DynRankView<RT, RP...>& rhs) {
1524 return !(operator==(lhs, rhs));
1534template <
class OutputView,
class Enable =
void>
1535struct DynRankViewFill {
1536 using const_value_type =
typename OutputView::traits::const_value_type;
1538 const OutputView output;
1539 const_value_type input;
1541 KOKKOS_INLINE_FUNCTION
1542 void operator()(
const size_t i0)
const {
1543 const size_t n1 = output.extent(1);
1544 const size_t n2 = output.extent(2);
1545 const size_t n3 = output.extent(3);
1546 const size_t n4 = output.extent(4);
1547 const size_t n5 = output.extent(5);
1548 const size_t n6 = output.extent(6);
1550 for (
size_t i1 = 0; i1 < n1; ++i1) {
1551 for (
size_t i2 = 0; i2 < n2; ++i2) {
1552 for (
size_t i3 = 0; i3 < n3; ++i3) {
1553 for (
size_t i4 = 0; i4 < n4; ++i4) {
1554 for (
size_t i5 = 0; i5 < n5; ++i5) {
1555 for (
size_t i6 = 0; i6 < n6; ++i6) {
1556 output.access(i0, i1, i2, i3, i4, i5, i6) = input;
1565 DynRankViewFill(
const OutputView& arg_out, const_value_type& arg_in)
1566 : output(arg_out), input(arg_in) {
1567 using execution_space =
typename OutputView::execution_space;
1570 Kokkos::parallel_for(
"Kokkos::DynRankViewFill", Policy(0, output.extent(0)),
1575template <
class OutputView>
1576struct DynRankViewFill<OutputView, std::enable_if_t<OutputView::Rank == 0>> {
1577 DynRankViewFill(
const OutputView& dst,
1578 const typename OutputView::const_value_type& src) {
1579 Kokkos::Impl::DeepCopy<
typename OutputView::memory_space,
1581 dst.data(), &src,
sizeof(
typename OutputView::const_value_type));
1585template <
class OutputView,
class InputView,
1586 class ExecSpace =
typename OutputView::execution_space>
1587struct DynRankViewRemap {
1588 const OutputView output;
1589 const InputView input;
1599 DynRankViewRemap(
const ExecSpace& exec_space,
const OutputView& arg_out,
1600 const InputView& arg_in)
1603 n0(std::min((size_t)arg_out.extent(0), (size_t)arg_in.extent(0))),
1604 n1(std::min((size_t)arg_out.extent(1), (size_t)arg_in.extent(1))),
1605 n2(std::min((size_t)arg_out.extent(2), (size_t)arg_in.extent(2))),
1606 n3(std::min((size_t)arg_out.extent(3), (size_t)arg_in.extent(3))),
1607 n4(std::min((size_t)arg_out.extent(4), (size_t)arg_in.extent(4))),
1608 n5(std::min((size_t)arg_out.extent(5), (size_t)arg_in.extent(5))),
1609 n6(std::min((size_t)arg_out.extent(6), (size_t)arg_in.extent(6))),
1610 n7(std::min((size_t)arg_out.extent(7), (size_t)arg_in.extent(7))) {
1613 Kokkos::parallel_for(
"Kokkos::DynRankViewRemap", Policy(exec_space, 0, n0),
1617 DynRankViewRemap(
const OutputView& arg_out,
const InputView& arg_in)
1620 n0(std::min((size_t)arg_out.extent(0), (size_t)arg_in.extent(0))),
1621 n1(std::min((size_t)arg_out.extent(1), (size_t)arg_in.extent(1))),
1622 n2(std::min((size_t)arg_out.extent(2), (size_t)arg_in.extent(2))),
1623 n3(std::min((size_t)arg_out.extent(3), (size_t)arg_in.extent(3))),
1624 n4(std::min((size_t)arg_out.extent(4), (size_t)arg_in.extent(4))),
1625 n5(std::min((size_t)arg_out.extent(5), (size_t)arg_in.extent(5))),
1626 n6(std::min((size_t)arg_out.extent(6), (size_t)arg_in.extent(6))),
1627 n7(std::min((size_t)arg_out.extent(7), (size_t)arg_in.extent(7))) {
1630 Kokkos::parallel_for(
"Kokkos::DynRankViewRemap", Policy(0, n0), *
this);
1633 KOKKOS_INLINE_FUNCTION
1634 void operator()(
const size_t i0)
const {
1635 for (
size_t i1 = 0; i1 < n1; ++i1) {
1636 for (
size_t i2 = 0; i2 < n2; ++i2) {
1637 for (
size_t i3 = 0; i3 < n3; ++i3) {
1638 for (
size_t i4 = 0; i4 < n4; ++i4) {
1639 for (
size_t i5 = 0; i5 < n5; ++i5) {
1640 for (
size_t i6 = 0; i6 < n6; ++i6) {
1641 output.access(i0, i1, i2, i3, i4, i5, i6) =
1642 input.access(i0, i1, i2, i3, i4, i5, i6);
1662template <
unsigned N,
typename T,
typename... Args>
1663KOKKOS_FUNCTION
auto as_view_of_rank_n(
1664 DynRankView<T, Args...> v,
1665 typename std::enable_if<std::is_same<
1666 typename ViewTraits<T, Args...>::specialize,
void>::value>::type* =
1668 if (v.rank() != N) {
1670 const std::string message =
1671 "Converting DynRankView of rank " + std::to_string(v.rank()) +
1672 " to a View of mis-matched rank " + std::to_string(N) +
"!";
1673 Kokkos::abort(message.c_str());)
1674 KOKKOS_IF_ON_DEVICE(
1675 Kokkos::abort("Converting DynRankView to a View of mis-matched rank!");)
1678 return View<typename RankDataType<T, N>::type, Args...>(
1679 v.data(), v.impl_map().layout());
1682template <typename Function, typename... Args>
1683void apply_to_view_of_static_rank(Function&& f, DynRankView<Args...> a) {
1685 case 0: f(as_view_of_rank_n<0>(a));
break;
1686 case 1: f(as_view_of_rank_n<1>(a));
break;
1687 case 2: f(as_view_of_rank_n<2>(a));
break;
1688 case 3: f(as_view_of_rank_n<3>(a));
break;
1689 case 4: f(as_view_of_rank_n<4>(a));
break;
1690 case 5: f(as_view_of_rank_n<5>(a));
break;
1691 case 6: f(as_view_of_rank_n<6>(a));
break;
1692 case 7: f(as_view_of_rank_n<7>(a));
break;
1697 "Trying to apply a function to a view of unexpected rank " +
1698 std::to_string(rank(a)))
1700 KOKKOS_IF_ON_DEVICE(
1702 "Trying to apply a function to a view of unexpected rank");)
1708template <
typename D,
class... P>
1709KOKKOS_INLINE_FUNCTION
constexpr auto DynRankView<D, P...>::layout() const ->
1710 typename traits::array_layout {
1712 case 0:
return Impl::as_view_of_rank_n<0>(*this).layout();
1713 case 1:
return Impl::as_view_of_rank_n<1>(*this).layout();
1714 case 2:
return Impl::as_view_of_rank_n<2>(*this).layout();
1715 case 3:
return Impl::as_view_of_rank_n<3>(*this).layout();
1716 case 4:
return Impl::as_view_of_rank_n<4>(*this).layout();
1717 case 5:
return Impl::as_view_of_rank_n<5>(*this).layout();
1718 case 6:
return Impl::as_view_of_rank_n<6>(*this).layout();
1719 case 7:
return Impl::as_view_of_rank_n<7>(*this).layout();
1724 "Calling DynRankView::layout on DRV of unexpected rank " +
1725 std::to_string(rank()))
1727 KOKKOS_IF_ON_DEVICE(
1729 "Calling DynRankView::layout on DRV of unexpected rank");)
1732 return m_map.layout();
1736template <
class ExecSpace,
class DT,
class... DP>
1737inline void deep_copy(
1738 const ExecSpace& e,
const DynRankView<DT, DP...>& dst,
1739 typename ViewTraits<DT, DP...>::const_value_type& value,
1740 std::enable_if_t<std::is_same<
typename ViewTraits<DT, DP...>::specialize,
1741 void>::value>* =
nullptr) {
1743 std::is_same<
typename ViewTraits<DT, DP...>::non_const_value_type,
1744 typename ViewTraits<DT, DP...>::value_type>::value,
1745 "deep_copy requires non-const type");
1747 Impl::apply_to_view_of_static_rank(
1748 [=](
auto view) { deep_copy(e, view, value); }, dst);
1751template <
class DT,
class... DP>
1752inline void deep_copy(
1753 const DynRankView<DT, DP...>& dst,
1754 typename ViewTraits<DT, DP...>::const_value_type& value,
1755 std::enable_if_t<std::is_same<
typename ViewTraits<DT, DP...>::specialize,
1756 void>::value>* =
nullptr) {
1757 Impl::apply_to_view_of_static_rank([=](
auto view) { deep_copy(view, value); },
1762template <
class ExecSpace,
class ST,
class... SP>
1763inline void deep_copy(
1765 typename ViewTraits<ST, SP...>::non_const_value_type& dst,
1766 const DynRankView<ST, SP...>& src,
1767 std::enable_if_t<std::is_same<
typename ViewTraits<ST, SP...>::specialize,
1768 void>::value>* = 0) {
1769 deep_copy(e, dst, Impl::as_view_of_rank_n<0>(src));
1772template <
class ST,
class... SP>
1773inline void deep_copy(
1774 typename ViewTraits<ST, SP...>::non_const_value_type& dst,
1775 const DynRankView<ST, SP...>& src,
1776 std::enable_if_t<std::is_same<
typename ViewTraits<ST, SP...>::specialize,
1777 void>::value>* = 0) {
1778 deep_copy(dst, Impl::as_view_of_rank_n<0>(src));
1787template <
class ExecSpace,
class DstType,
class SrcType>
1788inline void deep_copy(
1789 const ExecSpace& exec_space,
const DstType& dst,
const SrcType& src,
1791 (std::is_void<typename DstType::traits::specialize>::value &&
1792 std::is_void<typename SrcType::traits::specialize>::value &&
1793 (Kokkos::is_dyn_rank_view<DstType>::value ||
1794 Kokkos::is_dyn_rank_view<SrcType>::value))>* =
nullptr) {
1796 std::is_same<
typename DstType::traits::value_type,
1797 typename DstType::traits::non_const_value_type>::value,
1798 "deep_copy requires non-const destination type");
1800 switch (rank(dst)) {
1802 deep_copy(exec_space, Impl::as_view_of_rank_n<0>(dst),
1803 Impl::as_view_of_rank_n<0>(src));
1806 deep_copy(exec_space, Impl::as_view_of_rank_n<1>(dst),
1807 Impl::as_view_of_rank_n<1>(src));
1810 deep_copy(exec_space, Impl::as_view_of_rank_n<2>(dst),
1811 Impl::as_view_of_rank_n<2>(src));
1814 deep_copy(exec_space, Impl::as_view_of_rank_n<3>(dst),
1815 Impl::as_view_of_rank_n<3>(src));
1818 deep_copy(exec_space, Impl::as_view_of_rank_n<4>(dst),
1819 Impl::as_view_of_rank_n<4>(src));
1822 deep_copy(exec_space, Impl::as_view_of_rank_n<5>(dst),
1823 Impl::as_view_of_rank_n<5>(src));
1826 deep_copy(exec_space, Impl::as_view_of_rank_n<6>(dst),
1827 Impl::as_view_of_rank_n<6>(src));
1830 deep_copy(exec_space, Impl::as_view_of_rank_n<7>(dst),
1831 Impl::as_view_of_rank_n<7>(src));
1834 Kokkos::Impl::throw_runtime_exception(
1835 "Calling DynRankView deep_copy with a view of unexpected rank " +
1836 std::to_string(rank(dst)));
1840template <
class DstType,
class SrcType>
1841inline void deep_copy(
1842 const DstType& dst,
const SrcType& src,
1844 (std::is_void<typename DstType::traits::specialize>::value &&
1845 std::is_void<typename SrcType::traits::specialize>::value &&
1846 (Kokkos::is_dyn_rank_view<DstType>::value ||
1847 Kokkos::is_dyn_rank_view<SrcType>::value))>* =
nullptr) {
1849 std::is_same<
typename DstType::traits::value_type,
1850 typename DstType::traits::non_const_value_type>::value,
1851 "deep_copy requires non-const destination type");
1853 switch (rank(dst)) {
1855 deep_copy(Impl::as_view_of_rank_n<0>(dst),
1856 Impl::as_view_of_rank_n<0>(src));
1859 deep_copy(Impl::as_view_of_rank_n<1>(dst),
1860 Impl::as_view_of_rank_n<1>(src));
1863 deep_copy(Impl::as_view_of_rank_n<2>(dst),
1864 Impl::as_view_of_rank_n<2>(src));
1867 deep_copy(Impl::as_view_of_rank_n<3>(dst),
1868 Impl::as_view_of_rank_n<3>(src));
1871 deep_copy(Impl::as_view_of_rank_n<4>(dst),
1872 Impl::as_view_of_rank_n<4>(src));
1875 deep_copy(Impl::as_view_of_rank_n<5>(dst),
1876 Impl::as_view_of_rank_n<5>(src));
1879 deep_copy(Impl::as_view_of_rank_n<6>(dst),
1880 Impl::as_view_of_rank_n<6>(src));
1883 deep_copy(Impl::as_view_of_rank_n<7>(dst),
1884 Impl::as_view_of_rank_n<7>(src));
1887 Kokkos::Impl::throw_runtime_exception(
1888 "Calling DynRankView deep_copy with a view of unexpected rank " +
1889 std::to_string(rank(dst)));
1902template <
class Space,
class T,
class... P>
1903struct MirrorDRViewType {
1905 using src_view_type =
typename Kokkos::DynRankView<T, P...>;
1907 using memory_space =
typename Space::memory_space;
1911 std::is_same<memory_space, typename src_view_type::memory_space>::value
1914 using array_layout =
typename src_view_type::array_layout;
1917 using data_type =
typename src_view_type::non_const_data_type;
1919 using dest_view_type = Kokkos::DynRankView<data_type, array_layout, Space>;
1923 std::conditional_t<is_same_memspace, src_view_type, dest_view_type>;
1926template <
class Space,
class T,
class... P>
1927struct MirrorDRVType {
1929 using src_view_type =
typename Kokkos::DynRankView<T, P...>;
1931 using memory_space =
typename Space::memory_space;
1935 std::is_same<memory_space, typename src_view_type::memory_space>::value
1938 using array_layout =
typename src_view_type::array_layout;
1941 using data_type =
typename src_view_type::non_const_data_type;
1943 using view_type = Kokkos::DynRankView<data_type, array_layout, Space>;
1949template <
class T,
class... P,
class... ViewCtorArgs>
1950inline typename DynRankView<T, P...>::HostMirror create_mirror(
1951 const DynRankView<T, P...>& src,
1952 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
1953 std::enable_if_t<!Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space>* =
1955 using src_type = DynRankView<T, P...>;
1956 using dst_type =
typename src_type::HostMirror;
1958 using alloc_prop_input = Impl::ViewCtorProp<ViewCtorArgs...>;
1961 !alloc_prop_input::has_label,
1962 "The view constructor arguments passed to Kokkos::create_mirror "
1963 "must not include a label!");
1965 !alloc_prop_input::has_pointer,
1966 "The view constructor arguments passed to Kokkos::create_mirror must "
1967 "not include a pointer!");
1969 !alloc_prop_input::allow_padding,
1970 "The view constructor arguments passed to Kokkos::create_mirror must "
1971 "not explicitly allow padding!");
1973 auto prop_copy = Impl::with_properties_if_unset(
1974 arg_prop, std::string(src.label()).append(
"_mirror"));
1976 return dst_type(prop_copy, Impl::reconstructLayout(src.layout(), src.rank()));
1979template <
class T,
class... P,
class... ViewCtorArgs>
1980inline auto create_mirror(
1981 const DynRankView<T, P...>& src,
1982 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
1983 std::enable_if_t<Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space>* =
1985 using dst_type =
typename Impl::MirrorDRVType<
1986 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
1989 using alloc_prop_input = Impl::ViewCtorProp<ViewCtorArgs...>;
1992 !alloc_prop_input::has_label,
1993 "The view constructor arguments passed to Kokkos::create_mirror "
1994 "must not include a label!");
1996 !alloc_prop_input::has_pointer,
1997 "The view constructor arguments passed to Kokkos::create_mirror must "
1998 "not include a pointer!");
2000 !alloc_prop_input::allow_padding,
2001 "The view constructor arguments passed to Kokkos::create_mirror must "
2002 "not explicitly allow padding!");
2004 auto prop_copy = Impl::with_properties_if_unset(
2005 arg_prop, std::string(src.label()).append(
"_mirror"));
2007 return dst_type(prop_copy, Impl::reconstructLayout(src.layout(), src.rank()));
2013template <
class T,
class... P>
2014inline typename DynRankView<T, P...>::HostMirror create_mirror(
2015 const DynRankView<T, P...>& src,
2016 std::enable_if_t<std::is_same<
typename ViewTraits<T, P...>::specialize,
2017 void>::value>* =
nullptr) {
2018 return Impl::create_mirror(src, Kokkos::Impl::ViewCtorProp<>{});
2021template <
class T,
class... P>
2022inline typename DynRankView<T, P...>::HostMirror create_mirror(
2023 Kokkos::Impl::WithoutInitializing_t wi,
const DynRankView<T, P...>& src,
2024 std::enable_if_t<std::is_same<
typename ViewTraits<T, P...>::specialize,
2025 void>::value>* =
nullptr) {
2026 return Impl::create_mirror(src, Kokkos::view_alloc(wi));
2029template <
class T,
class... P,
class... ViewCtorArgs>
2030inline typename DynRankView<T, P...>::HostMirror create_mirror(
2031 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
2032 const DynRankView<T, P...>& src,
2034 std::is_void<
typename ViewTraits<T, P...>::specialize>::value &&
2035 !Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space>* =
nullptr) {
2036 return Impl::create_mirror(src, arg_prop);
2040template <
class Space,
class T,
class... P,
2041 typename Enable = std::enable_if_t<
2042 Kokkos::is_space<Space>::value &&
2043 std::is_void<
typename ViewTraits<T, P...>::specialize>::value>>
2044typename Impl::MirrorDRVType<Space, T, P...>::view_type create_mirror(
2045 const Space&,
const Kokkos::DynRankView<T, P...>& src) {
2046 return Impl::create_mirror(
2047 src, Kokkos::view_alloc(
typename Space::memory_space{}));
2050template <
class Space,
class T,
class... P>
2051typename Impl::MirrorDRVType<Space, T, P...>::view_type create_mirror(
2052 Kokkos::Impl::WithoutInitializing_t wi,
const Space&,
2053 const Kokkos::DynRankView<T, P...>& src,
2054 std::enable_if_t<std::is_same<
typename ViewTraits<T, P...>::specialize,
2055 void>::value>* =
nullptr) {
2056 return Impl::create_mirror(
2057 src, Kokkos::view_alloc(wi,
typename Space::memory_space{}));
2060template <
class T,
class... P,
class... ViewCtorArgs>
2061inline auto create_mirror(
2062 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
2063 const DynRankView<T, P...>& src,
2065 std::is_void<
typename ViewTraits<T, P...>::specialize>::value &&
2066 Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space>* =
nullptr) {
2067 using ReturnType =
typename Impl::MirrorDRVType<
2068 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
2070 return ReturnType{Impl::create_mirror(src, arg_prop)};
2074template <
class T,
class... P,
class... ViewCtorArgs>
2075inline std::enable_if_t<
2076 !Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space &&
2078 typename DynRankView<T, P...>::memory_space,
2079 typename DynRankView<T, P...>::HostMirror::memory_space>::value &&
2081 typename DynRankView<T, P...>::data_type,
2082 typename DynRankView<T, P...>::HostMirror::data_type>::value,
2083 typename DynRankView<T, P...>::HostMirror>
2084create_mirror_view(
const DynRankView<T, P...>& src,
2085 const typename Impl::ViewCtorProp<ViewCtorArgs...>&) {
2089template <
class T,
class... P,
class... ViewCtorArgs>
2090inline std::enable_if_t<
2091 !Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space &&
2093 typename DynRankView<T, P...>::memory_space,
2094 typename DynRankView<T, P...>::HostMirror::memory_space>::value &&
2096 typename DynRankView<T, P...>::data_type,
2097 typename DynRankView<T, P...>::HostMirror::data_type>::value),
2098 typename DynRankView<T, P...>::HostMirror>
2100 const DynRankView<T, P...>& src,
2101 const typename Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop) {
2102 return Kokkos::Impl::create_mirror(src, arg_prop);
2105template <
class T,
class... P,
class... ViewCtorArgs,
2106 class = std::enable_if_t<
2107 Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space>>
2108inline std::enable_if_t<
2110 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space>::value &&
2111 Impl::MirrorDRViewType<
2112 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
2113 P...>::is_same_memspace,
2114 typename Impl::MirrorDRViewType<
2115 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
2117create_mirror_view(
const Kokkos::DynRankView<T, P...>& src,
2118 const typename Impl::ViewCtorProp<ViewCtorArgs...>&) {
2122template <
class T,
class... P,
class... ViewCtorArgs,
2123 class = std::enable_if_t<
2124 Impl::ViewCtorProp<ViewCtorArgs...>::has_memory_space>>
2125inline std::enable_if_t<
2127 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space>::value &&
2128 !Impl::MirrorDRViewType<
2129 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
2130 P...>::is_same_memspace,
2131 typename Impl::MirrorDRViewType<
2132 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
2135 const Kokkos::DynRankView<T, P...>& src,
2136 const typename Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop) {
2137 return Kokkos::Impl::create_mirror(src, arg_prop);
2142template <
class T,
class... P>
2143inline std::enable_if_t<
2145 typename DynRankView<T, P...>::memory_space,
2146 typename DynRankView<T, P...>::HostMirror::memory_space>::value &&
2147 std::is_same<
typename DynRankView<T, P...>::data_type,
2148 typename DynRankView<T, P...>::HostMirror::data_type>::value),
2149 typename DynRankView<T, P...>::HostMirror>
2150create_mirror_view(
const Kokkos::DynRankView<T, P...>& src) {
2154template <
class T,
class... P>
2155inline std::enable_if_t<
2157 typename DynRankView<T, P...>::memory_space,
2158 typename DynRankView<T, P...>::HostMirror::memory_space>::value &&
2160 typename DynRankView<T, P...>::data_type,
2161 typename DynRankView<T, P...>::HostMirror::data_type>::value),
2162 typename DynRankView<T, P...>::HostMirror>
2163create_mirror_view(
const Kokkos::DynRankView<T, P...>& src) {
2164 return Kokkos::create_mirror(src);
2167template <
class T,
class... P>
2168inline auto create_mirror_view(Kokkos::Impl::WithoutInitializing_t wi,
2169 const DynRankView<T, P...>& src) {
2170 return Impl::create_mirror_view(src, Kokkos::view_alloc(wi));
2175template <
class Space,
class T,
class... P,
2176 class Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
2177inline typename Impl::MirrorDRViewType<Space, T, P...>::view_type
2179 const Space&,
const Kokkos::DynRankView<T, P...>& src,
2181 Impl::MirrorDRViewType<Space, T, P...>::is_same_memspace>* =
nullptr) {
2186template <
class Space,
class T,
class... P,
2187 class Enable = std::enable_if_t<Kokkos::is_space<Space>::value>>
2188inline typename Impl::MirrorDRViewType<Space, T, P...>::view_type
2190 const Space& space,
const Kokkos::DynRankView<T, P...>& src,
2192 !Impl::MirrorDRViewType<Space, T, P...>::is_same_memspace>* =
nullptr) {
2193 return Kokkos::create_mirror(space, src);
2196template <
class Space,
class T,
class... P>
2197inline auto create_mirror_view(Kokkos::Impl::WithoutInitializing_t wi,
2199 const Kokkos::DynRankView<T, P...>& src) {
2200 return Impl::create_mirror_view(
2201 src, Kokkos::view_alloc(
typename Space::memory_space{}, wi));
2204template <
class T,
class... P,
class... ViewCtorArgs>
2205inline auto create_mirror_view(
2206 const typename Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
2207 const Kokkos::DynRankView<T, P...>& src) {
2208 return Impl::create_mirror_view(src, arg_prop);
2211template <
class... ViewCtorArgs,
class T,
class... P>
2212auto create_mirror_view_and_copy(
2213 const Impl::ViewCtorProp<ViewCtorArgs...>&,
2214 const Kokkos::DynRankView<T, P...>& src,
2216 std::is_void<
typename ViewTraits<T, P...>::specialize>::value &&
2217 Impl::MirrorDRViewType<
2218 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
2219 P...>::is_same_memspace>* =
nullptr) {
2220 using alloc_prop_input = Impl::ViewCtorProp<ViewCtorArgs...>;
2222 alloc_prop_input::has_memory_space,
2223 "The view constructor arguments passed to "
2224 "Kokkos::create_mirror_view_and_copy must include a memory space!");
2225 static_assert(!alloc_prop_input::has_pointer,
2226 "The view constructor arguments passed to "
2227 "Kokkos::create_mirror_view_and_copy must "
2228 "not include a pointer!");
2229 static_assert(!alloc_prop_input::allow_padding,
2230 "The view constructor arguments passed to "
2231 "Kokkos::create_mirror_view_and_copy must "
2232 "not explicitly allow padding!");
2235 if (!alloc_prop_input::has_execution_space)
2237 "Kokkos::create_mirror_view_and_copy: fence before returning src view");
2241template <
class... ViewCtorArgs,
class T,
class... P>
2242auto create_mirror_view_and_copy(
2243 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
2244 const Kokkos::DynRankView<T, P...>& src,
2246 std::is_void<
typename ViewTraits<T, P...>::specialize>::value &&
2247 !Impl::MirrorDRViewType<
2248 typename Impl::ViewCtorProp<ViewCtorArgs...>::memory_space, T,
2249 P...>::is_same_memspace>* =
nullptr) {
2250 using alloc_prop_input = Impl::ViewCtorProp<ViewCtorArgs...>;
2252 alloc_prop_input::has_memory_space,
2253 "The view constructor arguments passed to "
2254 "Kokkos::create_mirror_view_and_copy must include a memory space!");
2255 static_assert(!alloc_prop_input::has_pointer,
2256 "The view constructor arguments passed to "
2257 "Kokkos::create_mirror_view_and_copy must "
2258 "not include a pointer!");
2259 static_assert(!alloc_prop_input::allow_padding,
2260 "The view constructor arguments passed to "
2261 "Kokkos::create_mirror_view_and_copy must "
2262 "not explicitly allow padding!");
2263 using Space =
typename alloc_prop_input::memory_space;
2264 using Mirror =
typename Impl::MirrorDRViewType<Space, T, P...>::view_type;
2266 auto arg_prop_copy = Impl::with_properties_if_unset(
2267 arg_prop, std::string{}, WithoutInitializing,
2268 typename Space::execution_space{});
2270 std::string& label = Impl::get_property<Impl::LabelTag>(arg_prop_copy);
2271 if (label.empty()) label = src.label();
2272 auto mirror =
typename Mirror::non_const_type{
2273 arg_prop_copy, Impl::reconstructLayout(src.layout(), src.rank())};
2274 if constexpr (alloc_prop_input::has_execution_space) {
2275 deep_copy(Impl::get_property<Impl::ExecutionSpaceTag>(arg_prop_copy),
2278 deep_copy(mirror, src);
2282template <
class Space,
class T,
class... P>
2283auto create_mirror_view_and_copy(
const Space&,
2284 const Kokkos::DynRankView<T, P...>& src,
2285 std::string
const& name =
"") {
2286 return create_mirror_view_and_copy(
2287 Kokkos::view_alloc(
typename Space::memory_space{}, name), src);
2298template <
class... ViewCtorArgs,
class T,
class... P>
2299inline void impl_resize(
const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
2300 DynRankView<T, P...>& v,
const size_t n0,
2301 const size_t n1,
const size_t n2,
const size_t n3,
2302 const size_t n4,
const size_t n5,
const size_t n6,
2304 using drview_type = DynRankView<T, P...>;
2305 using alloc_prop_input = Impl::ViewCtorProp<ViewCtorArgs...>;
2308 "Can only resize managed views");
2309 static_assert(!alloc_prop_input::has_label,
2310 "The view constructor arguments passed to Kokkos::resize "
2311 "must not include a label!");
2312 static_assert(!alloc_prop_input::has_pointer,
2313 "The view constructor arguments passed to Kokkos::resize must "
2314 "not include a pointer!");
2315 static_assert(!alloc_prop_input::has_memory_space,
2316 "The view constructor arguments passed to Kokkos::resize must "
2317 "not include a memory space instance!");
2319 auto prop_copy = Impl::with_properties_if_unset(
2320 arg_prop, v.label(),
typename drview_type::execution_space{});
2322 drview_type v_resized(prop_copy, n0, n1, n2, n3, n4, n5, n6, n7);
2324 if constexpr (alloc_prop_input::has_execution_space)
2325 Kokkos::Impl::DynRankViewRemap<drview_type, drview_type>(
2326 Impl::get_property<Impl::ExecutionSpaceTag>(prop_copy), v_resized, v);
2328 Kokkos::Impl::DynRankViewRemap<drview_type, drview_type>(v_resized, v);
2333template <
class T,
class... P>
2334inline void resize(DynRankView<T, P...>& v,
2335 const size_t n0 = KOKKOS_INVALID_INDEX,
2336 const size_t n1 = KOKKOS_INVALID_INDEX,
2337 const size_t n2 = KOKKOS_INVALID_INDEX,
2338 const size_t n3 = KOKKOS_INVALID_INDEX,
2339 const size_t n4 = KOKKOS_INVALID_INDEX,
2340 const size_t n5 = KOKKOS_INVALID_INDEX,
2341 const size_t n6 = KOKKOS_INVALID_INDEX,
2342 const size_t n7 = KOKKOS_INVALID_INDEX) {
2343 impl_resize(Impl::ViewCtorProp<>{}, v, n0, n1, n2, n3, n4, n5, n6, n7);
2346template <
class... ViewCtorArgs,
class T,
class... P>
2347void resize(
const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
2348 DynRankView<T, P...>& v,
2349 const size_t n0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
2350 const size_t n1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
2351 const size_t n2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
2352 const size_t n3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
2353 const size_t n4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
2354 const size_t n5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
2355 const size_t n6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
2356 const size_t n7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG) {
2357 impl_resize(arg_prop, v, n0, n1, n2, n3, n4, n5, n6, n7);
2360template <
class I,
class T,
class... P>
2361inline std::enable_if_t<Impl::is_view_ctor_property<I>::value> resize(
2362 const I& arg_prop, DynRankView<T, P...>& v,
2363 const size_t n0 = KOKKOS_INVALID_INDEX,
2364 const size_t n1 = KOKKOS_INVALID_INDEX,
2365 const size_t n2 = KOKKOS_INVALID_INDEX,
2366 const size_t n3 = KOKKOS_INVALID_INDEX,
2367 const size_t n4 = KOKKOS_INVALID_INDEX,
2368 const size_t n5 = KOKKOS_INVALID_INDEX,
2369 const size_t n6 = KOKKOS_INVALID_INDEX,
2370 const size_t n7 = KOKKOS_INVALID_INDEX) {
2371 impl_resize(Kokkos::view_alloc(arg_prop), v, n0, n1, n2, n3, n4, n5, n6, n7);
2376template <
class... ViewCtorArgs,
class T,
class... P>
2377inline void impl_realloc(DynRankView<T, P...>& v,
const size_t n0,
2378 const size_t n1,
const size_t n2,
const size_t n3,
2379 const size_t n4,
const size_t n5,
const size_t n6,
2381 const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop) {
2382 using drview_type = DynRankView<T, P...>;
2383 using alloc_prop_input = Impl::ViewCtorProp<ViewCtorArgs...>;
2386 "Can only realloc managed views");
2387 static_assert(!alloc_prop_input::has_label,
2388 "The view constructor arguments passed to Kokkos::realloc must "
2389 "not include a label!");
2390 static_assert(!alloc_prop_input::has_pointer,
2391 "The view constructor arguments passed to Kokkos::realloc must "
2392 "not include a pointer!");
2393 static_assert(!alloc_prop_input::has_memory_space,
2394 "The view constructor arguments passed to Kokkos::realloc must "
2395 "not include a memory space instance!");
2397 auto arg_prop_copy = Impl::with_properties_if_unset(arg_prop, v.label());
2400 v = drview_type(arg_prop_copy, n0, n1, n2, n3, n4, n5, n6, n7);
2403template <
class T,
class... P,
class... ViewCtorArgs>
2404inline void realloc(
const Impl::ViewCtorProp<ViewCtorArgs...>& arg_prop,
2405 DynRankView<T, P...>& v,
2406 const size_t n0 = KOKKOS_INVALID_INDEX,
2407 const size_t n1 = KOKKOS_INVALID_INDEX,
2408 const size_t n2 = KOKKOS_INVALID_INDEX,
2409 const size_t n3 = KOKKOS_INVALID_INDEX,
2410 const size_t n4 = KOKKOS_INVALID_INDEX,
2411 const size_t n5 = KOKKOS_INVALID_INDEX,
2412 const size_t n6 = KOKKOS_INVALID_INDEX,
2413 const size_t n7 = KOKKOS_INVALID_INDEX) {
2414 impl_realloc(v, n0, n1, n2, n3, n4, n5, n6, n7, arg_prop);
2417template <
class T,
class... P>
2418inline void realloc(DynRankView<T, P...>& v,
2419 const size_t n0 = KOKKOS_INVALID_INDEX,
2420 const size_t n1 = KOKKOS_INVALID_INDEX,
2421 const size_t n2 = KOKKOS_INVALID_INDEX,
2422 const size_t n3 = KOKKOS_INVALID_INDEX,
2423 const size_t n4 = KOKKOS_INVALID_INDEX,
2424 const size_t n5 = KOKKOS_INVALID_INDEX,
2425 const size_t n6 = KOKKOS_INVALID_INDEX,
2426 const size_t n7 = KOKKOS_INVALID_INDEX) {
2427 impl_realloc(v, n0, n1, n2, n3, n4, n5, n6, n7, Impl::ViewCtorProp<>{});
2430template <
class I,
class T,
class... P>
2431inline std::enable_if_t<Impl::is_view_ctor_property<I>::value> realloc(
2432 const I& arg_prop, DynRankView<T, P...>& v,
2433 const size_t n0 = KOKKOS_INVALID_INDEX,
2434 const size_t n1 = KOKKOS_INVALID_INDEX,
2435 const size_t n2 = KOKKOS_INVALID_INDEX,
2436 const size_t n3 = KOKKOS_INVALID_INDEX,
2437 const size_t n4 = KOKKOS_INVALID_INDEX,
2438 const size_t n5 = KOKKOS_INVALID_INDEX,
2439 const size_t n6 = KOKKOS_INVALID_INDEX,
2440 const size_t n7 = KOKKOS_INVALID_INDEX) {
2441 impl_realloc(v, n0, n1, n2, n3, n4, n5, n6, n7, Kokkos::view_alloc(arg_prop));
2446#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_DYNRANKVIEW
2447#undef KOKKOS_IMPL_PUBLIC_INCLUDE
2448#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_DYNRANKVIEW
Memory management for host memory.
Execution policy for work over a range of an integral type.
View to an array of data.
KOKKOS_INLINE_FUNCTION bool dyn_rank_view_verify_operator_bounds(const iType0 &, const MapType &)
Debug bounds-checking routines.
Assign compatible default mappings.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices.
Memory layout tag indicated arbitrarily strided multi-index mapping into contiguous memory.
Traits class for accessing attributes of a View.