45 #ifndef KOKKOS_VIEW_HPP 46 #define KOKKOS_VIEW_HPP 48 #include <type_traits> 51 #include <initializer_list> 53 #include <Kokkos_Core_fwd.hpp> 54 #include <Kokkos_HostSpace.hpp> 55 #include <Kokkos_MemoryTraits.hpp> 56 #include <Kokkos_ExecPolicy.hpp> 58 #include <impl/Kokkos_Tools.hpp> 66 template <
class DataType>
67 struct ViewArrayAnalysis;
69 template <
class DataType,
class ArrayLayout,
71 typename ViewArrayAnalysis<DataType>::non_const_value_type>
72 struct ViewDataAnalysis;
74 template <
class,
class...>
77 enum :
bool { is_assignable_data_type =
false };
78 enum :
bool { is_assignable =
false };
81 template <
typename IntType>
82 KOKKOS_INLINE_FUNCTION std::size_t count_valid_integers(
83 const IntType i0,
const IntType i1,
const IntType i2,
const IntType i3,
84 const IntType i4,
const IntType i5,
const IntType i6,
const IntType i7) {
85 static_assert(std::is_integral<IntType>::value,
86 "count_valid_integers() must have integer arguments.");
88 return (i0 != KOKKOS_INVALID_INDEX) + (i1 != KOKKOS_INVALID_INDEX) +
89 (i2 != KOKKOS_INVALID_INDEX) + (i3 != KOKKOS_INVALID_INDEX) +
90 (i4 != KOKKOS_INVALID_INDEX) + (i5 != KOKKOS_INVALID_INDEX) +
91 (i6 != KOKKOS_INVALID_INDEX) + (i7 != KOKKOS_INVALID_INDEX);
94 KOKKOS_INLINE_FUNCTION
95 void runtime_check_rank_device(
const size_t dyn_rank,
const bool is_void_spec,
96 const size_t i0,
const size_t i1,
97 const size_t i2,
const size_t i3,
98 const size_t i4,
const size_t i5,
99 const size_t i6,
const size_t i7) {
101 const size_t num_passed_args =
102 count_valid_integers(i0, i1, i2, i3, i4, i5, i6, i7);
104 if (num_passed_args != dyn_rank && is_void_spec) {
106 "Number of arguments passed to Kokkos::View() constructor must match " 107 "the dynamic rank of the view.");
112 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 113 KOKKOS_INLINE_FUNCTION
114 void runtime_check_rank_host(
const size_t dyn_rank,
const bool is_void_spec,
115 const size_t i0,
const size_t i1,
const size_t i2,
116 const size_t i3,
const size_t i4,
const size_t i5,
117 const size_t i6,
const size_t i7,
118 const std::string& label) {
120 const size_t num_passed_args =
121 count_valid_integers(i0, i1, i2, i3, i4, i5, i6, i7);
123 if (num_passed_args != dyn_rank) {
124 const std::string message =
125 "Constructor for Kokkos View '" + label +
126 "' has mismatched number of arguments. Number of arguments = " +
127 std::to_string(num_passed_args) +
128 " but dynamic rank = " + std::to_string(dyn_rank) +
" \n";
129 Kokkos::abort(message.c_str());
141 template <
class ViewType,
int Traits = 0>
142 struct ViewUniformType;
168 template <
class DataType,
class... Properties>
173 using execution_space = void;
174 using memory_space = void;
175 using HostMirrorSpace = void;
176 using array_layout = void;
177 using memory_traits = void;
178 using specialize = void;
181 template <
class... Prop>
184 using execution_space =
typename ViewTraits<void, Prop...>::execution_space;
185 using memory_space =
typename ViewTraits<void, Prop...>::memory_space;
186 using HostMirrorSpace =
typename ViewTraits<void, Prop...>::HostMirrorSpace;
187 using array_layout =
typename ViewTraits<void, Prop...>::array_layout;
188 using memory_traits =
typename ViewTraits<void, Prop...>::memory_traits;
189 using specialize =
typename ViewTraits<void, Prop...>::specialize;
192 template <
class ArrayLayout,
class... Prop>
193 struct ViewTraits<typename std::enable_if<
194 Kokkos::Impl::is_array_layout<ArrayLayout>::value>::type,
195 ArrayLayout, Prop...> {
198 using execution_space =
typename ViewTraits<void, Prop...>::execution_space;
199 using memory_space =
typename ViewTraits<void, Prop...>::memory_space;
200 using HostMirrorSpace =
typename ViewTraits<void, Prop...>::HostMirrorSpace;
201 using array_layout = ArrayLayout;
202 using memory_traits =
typename ViewTraits<void, Prop...>::memory_traits;
203 using specialize =
typename ViewTraits<void, Prop...>::specialize;
206 template <
class Space,
class... Prop>
208 typename std::enable_if<Kokkos::Impl::is_space<Space>::value>::type, Space,
213 std::is_same<
typename ViewTraits<void, Prop...>::execution_space,
215 std::is_same<
typename ViewTraits<void, Prop...>::memory_space,
217 std::is_same<
typename ViewTraits<void, Prop...>::HostMirrorSpace,
219 std::is_same<
typename ViewTraits<void, Prop...>::array_layout,
221 "Only one View Execution or Memory Space template argument");
223 using execution_space =
typename Space::execution_space;
224 using memory_space =
typename Space::memory_space;
225 using HostMirrorSpace =
226 typename Kokkos::Impl::HostMirror<Space>::Space::memory_space;
227 using array_layout =
typename execution_space::array_layout;
228 using memory_traits =
typename ViewTraits<void, Prop...>::memory_traits;
229 using specialize =
typename ViewTraits<void, Prop...>::specialize;
232 template <
class MemoryTraits,
class... Prop>
233 struct ViewTraits<typename std::enable_if<Kokkos::Impl::is_memory_traits<
234 MemoryTraits>::value>::type,
235 MemoryTraits, Prop...> {
239 std::is_same<
typename ViewTraits<void, Prop...>::execution_space,
241 std::is_same<
typename ViewTraits<void, Prop...>::memory_space,
243 std::is_same<
typename ViewTraits<void, Prop...>::array_layout,
245 std::is_same<
typename ViewTraits<void, Prop...>::memory_traits,
247 "MemoryTrait is the final optional template argument for a View");
249 using execution_space = void;
250 using memory_space = void;
251 using HostMirrorSpace = void;
252 using array_layout = void;
253 using memory_traits = MemoryTraits;
254 using specialize = void;
257 template <
class DataType,
class... Properties>
261 using prop = ViewTraits<void, Properties...>;
263 using ExecutionSpace =
typename std::conditional<
264 !std::is_same<typename prop::execution_space, void>::value,
265 typename prop::execution_space, Kokkos::DefaultExecutionSpace>::type;
267 using MemorySpace =
typename std::conditional<
268 !std::is_same<typename prop::memory_space, void>::value,
269 typename prop::memory_space,
typename ExecutionSpace::memory_space>::type;
271 using ArrayLayout =
typename std::conditional<
272 !std::is_same<typename prop::array_layout, void>::value,
273 typename prop::array_layout,
typename ExecutionSpace::array_layout>::type;
275 using HostMirrorSpace =
typename std::conditional<
276 !std::is_same<typename prop::HostMirrorSpace, void>::value,
277 typename prop::HostMirrorSpace,
278 typename Kokkos::Impl::HostMirror<ExecutionSpace>::Space>::type;
280 using MemoryTraits =
typename std::conditional<
281 !std::is_same<typename prop::memory_traits, void>::value,
282 typename prop::memory_traits,
typename Kokkos::MemoryManaged>::type;
286 using data_analysis = Kokkos::Impl::ViewDataAnalysis<DataType, ArrayLayout>;
292 using data_type =
typename data_analysis::type;
293 using const_data_type =
typename data_analysis::const_type;
294 using non_const_data_type =
typename data_analysis::non_const_type;
299 using scalar_array_type =
typename data_analysis::scalar_array_type;
300 using const_scalar_array_type =
301 typename data_analysis::const_scalar_array_type;
302 using non_const_scalar_array_type =
303 typename data_analysis::non_const_scalar_array_type;
308 using value_type =
typename data_analysis::value_type;
309 using const_value_type =
typename data_analysis::const_value_type;
310 using non_const_value_type =
typename data_analysis::non_const_value_type;
315 using array_layout = ArrayLayout;
316 using dimension =
typename data_analysis::dimension;
318 using specialize =
typename std::conditional<
319 std::is_same<typename data_analysis::specialize, void>::value,
320 typename prop::specialize,
typename data_analysis::specialize>::
323 enum { rank = dimension::rank };
324 enum { rank_dynamic = dimension::rank_dynamic };
329 using execution_space = ExecutionSpace;
330 using memory_space = MemorySpace;
331 using device_type = Kokkos::Device<ExecutionSpace, MemorySpace>;
332 using memory_traits = MemoryTraits;
333 using host_mirror_space = HostMirrorSpace;
335 using size_type =
typename MemorySpace::size_type;
337 enum { is_hostspace = std::is_same<MemorySpace, HostSpace>::value };
338 enum { is_managed = MemoryTraits::is_unmanaged == 0 };
339 enum { is_random_access = MemoryTraits::is_random_access == 1 };
432 template <
class T1,
class T2>
433 struct is_always_assignable_impl;
435 template <
class... ViewTDst,
class... ViewTSrc>
436 struct is_always_assignable_impl<
Kokkos::
View<ViewTDst...>,
438 using mapping_type = Kokkos::Impl::ViewMapping<
441 typename Kokkos::View<ViewTDst...>::traits::specialize>;
443 constexpr
static bool value =
444 mapping_type::is_assignable &&
445 static_cast<int>(
Kokkos::View<ViewTDst...>::rank_dynamic) >=
449 template <
class View1,
class View2>
450 using is_always_assignable = is_always_assignable_impl<
451 typename std::remove_reference<View1>::type,
452 typename std::remove_const<
453 typename std::remove_reference<View2>::type>::type>;
455 #ifdef KOKKOS_ENABLE_CXX17 456 template <
class T1,
class T2>
457 inline constexpr
bool is_always_assignable_v =
458 is_always_assignable<T1, T2>::value;
461 template <
class... ViewTDst,
class... ViewTSrc>
464 using DstTraits =
typename Kokkos::View<ViewTDst...>::traits;
465 using SrcTraits =
typename Kokkos::View<ViewTSrc...>::traits;
467 Kokkos::Impl::ViewMapping<DstTraits, SrcTraits,
468 typename DstTraits::specialize>;
470 #ifdef KOKKOS_ENABLE_CXX17 471 return is_always_assignable_v<
Kokkos::View<ViewTDst...>,
477 (mapping_type::is_assignable &&
478 ((DstTraits::dimension::rank_dynamic >= 1) ||
479 (dst.static_extent(0) == src.
extent(0))) &&
480 ((DstTraits::dimension::rank_dynamic >= 2) ||
481 (dst.static_extent(1) == src.
extent(1))) &&
482 ((DstTraits::dimension::rank_dynamic >= 3) ||
483 (dst.static_extent(2) == src.
extent(2))) &&
484 ((DstTraits::dimension::rank_dynamic >= 4) ||
485 (dst.static_extent(3) == src.
extent(3))) &&
486 ((DstTraits::dimension::rank_dynamic >= 5) ||
487 (dst.static_extent(4) == src.
extent(4))) &&
488 ((DstTraits::dimension::rank_dynamic >= 6) ||
489 (dst.static_extent(5) == src.
extent(5))) &&
490 ((DstTraits::dimension::rank_dynamic >= 7) ||
491 (dst.static_extent(6) == src.
extent(6))) &&
492 ((DstTraits::dimension::rank_dynamic >= 8) ||
493 (dst.static_extent(7) == src.
extent(7))));
501 #include <impl/Kokkos_ViewMapping.hpp> 502 #include <impl/Kokkos_ViewArray.hpp> 511 constexpr Kokkos::Impl::ALL_t ALL = Kokkos::Impl::ALL_t();
513 constexpr Kokkos::Impl::WithoutInitializing_t WithoutInitializing =
514 Kokkos::Impl::WithoutInitializing_t();
516 constexpr Kokkos::Impl::AllowPadding_t AllowPadding =
517 Kokkos::Impl::AllowPadding_t();
531 template <
class... Args>
532 inline Impl::ViewCtorProp<typename Impl::ViewCtorProp<void, Args>::type...>
533 view_alloc(Args
const&... args) {
535 Impl::ViewCtorProp<typename Impl::ViewCtorProp<void, Args>::type...>;
537 static_assert(!return_type::has_pointer,
538 "Cannot give pointer-to-memory for view allocation");
540 return return_type(args...);
543 template <
class... Args>
544 KOKKOS_INLINE_FUNCTION
545 Impl::ViewCtorProp<typename Impl::ViewCtorProp<void, Args>::type...>
546 view_wrap(Args
const&... args) {
548 Impl::ViewCtorProp<typename Impl::ViewCtorProp<void, Args>::type...>;
550 static_assert(!return_type::has_memory_space &&
551 !return_type::has_execution_space &&
552 !return_type::has_label && return_type::has_pointer,
553 "Must only give pointer-to-memory for view wrapping");
555 return return_type(args...);
565 template <
class DataType,
class... Properties>
569 struct is_view :
public std::false_type {};
571 template <
class D,
class... P>
572 struct is_view<
View<D, P...>> :
public std::true_type {};
574 template <
class D,
class... P>
575 struct is_view<const
View<D, P...>> :
public std::true_type {};
577 template <
class DataType,
class... Properties>
578 class View :
public ViewTraits<DataType, Properties...> {
580 template <
class,
class...>
582 template <
class,
class...>
583 friend class Kokkos::Impl::ViewMapping;
585 using view_tracker_type = Kokkos::Impl::ViewTracker<View>;
588 using traits = ViewTraits<DataType, Properties...>;
592 Kokkos::Impl::ViewMapping<traits, typename traits::specialize>;
593 template <
typename V>
594 friend struct Kokkos::Impl::ViewTracker;
596 view_tracker_type m_track;
603 View<
typename traits::scalar_array_type,
typename traits::array_layout,
604 typename traits::device_type,
typename traits::memory_traits>;
608 View<
typename traits::const_data_type,
typename traits::array_layout,
609 typename traits::device_type,
typename traits::memory_traits>;
613 View<
typename traits::non_const_data_type,
typename traits::array_layout,
614 typename traits::device_type,
typename traits::memory_traits>;
618 View<
typename traits::non_const_data_type,
typename traits::array_layout,
619 Device<DefaultHostExecutionSpace,
620 typename traits::host_mirror_space::memory_space>>;
624 View<
typename traits::non_const_data_type,
typename traits::array_layout,
625 typename traits::host_mirror_space>;
629 using uniform_const_type =
630 typename Impl::ViewUniformType<View, 0>::const_type;
631 using uniform_runtime_type =
632 typename Impl::ViewUniformType<View, 0>::runtime_type;
633 using uniform_runtime_const_type =
634 typename Impl::ViewUniformType<View, 0>::runtime_const_type;
635 using uniform_nomemspace_type =
636 typename Impl::ViewUniformType<View, 0>::nomemspace_type;
637 using uniform_const_nomemspace_type =
638 typename Impl::ViewUniformType<View, 0>::const_nomemspace_type;
639 using uniform_runtime_nomemspace_type =
640 typename Impl::ViewUniformType<View, 0>::runtime_nomemspace_type;
641 using uniform_runtime_const_nomemspace_type =
642 typename Impl::ViewUniformType<View, 0>::runtime_const_nomemspace_type;
647 enum { Rank = map_type::Rank };
655 template <
typename iType>
656 KOKKOS_INLINE_FUNCTION constexpr
657 typename std::enable_if<std::is_integral<iType>::value,
size_t>::type
659 return m_map.extent(r);
662 static KOKKOS_INLINE_FUNCTION constexpr
size_t static_extent(
663 const unsigned r) noexcept {
664 return map_type::static_extent(r);
667 template <
typename iType>
668 KOKKOS_INLINE_FUNCTION constexpr
669 typename std::enable_if<std::is_integral<iType>::value,
int>::type
670 extent_int(
const iType& r)
const noexcept {
671 return static_cast<int>(m_map.extent(r));
674 KOKKOS_INLINE_FUNCTION constexpr
typename traits::array_layout layout()
676 return m_map.layout();
684 KOKKOS_INLINE_FUNCTION constexpr
size_t size()
const {
685 return m_map.dimension_0() * m_map.dimension_1() * m_map.dimension_2() *
686 m_map.dimension_3() * m_map.dimension_4() * m_map.dimension_5() *
687 m_map.dimension_6() * m_map.dimension_7();
690 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_0()
const {
691 return m_map.stride_0();
693 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_1()
const {
694 return m_map.stride_1();
696 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_2()
const {
697 return m_map.stride_2();
699 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_3()
const {
700 return m_map.stride_3();
702 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_4()
const {
703 return m_map.stride_4();
705 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_5()
const {
706 return m_map.stride_5();
708 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_6()
const {
709 return m_map.stride_6();
711 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_7()
const {
712 return m_map.stride_7();
715 template <
typename iType>
716 KOKKOS_INLINE_FUNCTION constexpr
717 typename std::enable_if<std::is_integral<iType>::value,
size_t>::type
718 stride(iType r)
const {
734 : m_map.stride_7())))))));
737 template <
typename iType>
738 KOKKOS_INLINE_FUNCTION
void stride(iType*
const s)
const {
745 using reference_type =
typename map_type::reference_type;
746 using pointer_type =
typename map_type::pointer_type;
749 reference_type_is_lvalue_reference =
750 std::is_lvalue_reference<reference_type>::value
753 KOKKOS_INLINE_FUNCTION constexpr
size_t span()
const {
return m_map.span(); }
754 KOKKOS_INLINE_FUNCTION
bool span_is_contiguous()
const {
755 return m_map.span_is_contiguous();
757 KOKKOS_INLINE_FUNCTION constexpr
bool is_allocated()
const {
758 return m_map.data() !=
nullptr;
760 KOKKOS_INLINE_FUNCTION constexpr pointer_type data()
const {
767 KOKKOS_INLINE_FUNCTION
768 const Kokkos::Impl::ViewMapping<traits, typename traits::specialize>&
772 KOKKOS_INLINE_FUNCTION
773 const Kokkos::Impl::SharedAllocationTracker& impl_track()
const {
774 return m_track.m_tracker;
779 static constexpr
bool is_layout_left =
780 std::is_same<typename traits::array_layout, Kokkos::LayoutLeft>::value;
782 static constexpr
bool is_layout_right =
783 std::is_same<typename traits::array_layout, Kokkos::LayoutRight>::value;
785 static constexpr
bool is_layout_stride =
786 std::is_same<typename traits::array_layout, Kokkos::LayoutStride>::value;
788 static constexpr
bool is_default_map =
789 std::is_same<typename traits::specialize, void>::value &&
790 (is_layout_left || is_layout_right || is_layout_stride);
792 #if defined(KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK) 794 #define KOKKOS_IMPL_SINK(ARG) ARG 796 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(ARG) \ 797 Kokkos::Impl::verify_space<Kokkos::Impl::ActiveExecutionMemorySpace, \ 798 typename traits::memory_space>::check(); \ 799 Kokkos::Impl::view_verify_operator_bounds<typename traits::memory_space> ARG; 803 #define KOKKOS_IMPL_SINK(ARG) 805 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(ARG) \ 806 Kokkos::Impl::verify_space<Kokkos::Impl::ActiveExecutionMemorySpace, \ 807 typename traits::memory_space>::check(); 815 KOKKOS_FORCEINLINE_FUNCTION
816 reference_type operator()()
const {
return m_map.reference(); }
820 template <
typename I0>
821 KOKKOS_FORCEINLINE_FUNCTION
822 typename std::enable_if<(Kokkos::Impl::are_integral<I0>::value &&
823 (1 == Rank) && !is_default_map),
824 reference_type>::type
825 operator()(
const I0& i0)
const {
826 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0))
827 return m_map.reference(i0);
830 template <
typename I0>
831 KOKKOS_FORCEINLINE_FUNCTION
832 typename std::enable_if<(Kokkos::Impl::are_integral<I0>::value &&
833 (1 == Rank) && is_default_map &&
835 reference_type>::type
836 operator()(
const I0& i0)
const {
837 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0))
838 return m_map.m_impl_handle[i0];
841 template <
typename I0>
842 KOKKOS_FORCEINLINE_FUNCTION
843 typename std::enable_if<(Kokkos::Impl::are_integral<I0>::value &&
844 (1 == Rank) && is_default_map &&
846 reference_type>::type
847 operator()(
const I0& i0)
const {
848 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0))
849 return m_map.m_impl_handle[m_map.m_impl_offset.m_stride.S0 * i0];
854 template <
typename I0>
855 KOKKOS_FORCEINLINE_FUNCTION
856 typename std::enable_if<(Kokkos::Impl::are_integral<I0>::value &&
857 (1 == Rank) && !is_default_map),
858 reference_type>::type
859 operator[](
const I0& i0)
const {
860 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0))
861 return m_map.reference(i0);
864 template <
typename I0>
865 KOKKOS_FORCEINLINE_FUNCTION
866 typename std::enable_if<(Kokkos::Impl::are_integral<I0>::value &&
867 (1 == Rank) && is_default_map &&
869 reference_type>::type
870 operator[](
const I0& i0)
const {
871 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0))
872 return m_map.m_impl_handle[i0];
875 template <
typename I0>
876 KOKKOS_FORCEINLINE_FUNCTION
877 typename std::enable_if<(Kokkos::Impl::are_integral<I0>::value &&
878 (1 == Rank) && is_default_map &&
880 reference_type>::type
881 operator[](
const I0& i0)
const {
882 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0))
883 return m_map.m_impl_handle[m_map.m_impl_offset.m_stride.S0 * i0];
889 template <
typename I0,
typename I1>
890 KOKKOS_FORCEINLINE_FUNCTION
891 typename std::enable_if<(Kokkos::Impl::are_integral<I0, I1>::value &&
892 (2 == Rank) && !is_default_map),
893 reference_type>::type
894 operator()(
const I0& i0,
const I1& i1)
const {
895 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1))
896 return m_map.reference(i0, i1);
899 template <
typename I0,
typename I1>
900 KOKKOS_FORCEINLINE_FUNCTION
901 typename std::enable_if<(Kokkos::Impl::are_integral<I0, I1>::value &&
902 (2 == Rank) && is_default_map &&
903 is_layout_left && (traits::rank_dynamic == 0)),
904 reference_type>::type
905 operator()(
const I0& i0,
const I1& i1)
const {
906 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1))
907 return m_map.m_impl_handle[i0 + m_map.m_impl_offset.m_dim.N0 * i1];
910 template <
typename I0,
typename I1>
911 KOKKOS_FORCEINLINE_FUNCTION
912 typename std::enable_if<(Kokkos::Impl::are_integral<I0, I1>::value &&
913 (2 == Rank) && is_default_map &&
914 is_layout_left && (traits::rank_dynamic != 0)),
915 reference_type>::type
916 operator()(
const I0& i0,
const I1& i1)
const {
917 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1))
918 return m_map.m_impl_handle[i0 + m_map.m_impl_offset.m_stride * i1];
921 template <
typename I0,
typename I1>
922 KOKKOS_FORCEINLINE_FUNCTION
923 typename std::enable_if<(Kokkos::Impl::are_integral<I0, I1>::value &&
924 (2 == Rank) && is_default_map &&
925 is_layout_right && (traits::rank_dynamic == 0)),
926 reference_type>::type
927 operator()(
const I0& i0,
const I1& i1)
const {
928 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1))
929 return m_map.m_impl_handle[i1 + m_map.m_impl_offset.m_dim.N1 * i0];
932 template <
typename I0,
typename I1>
933 KOKKOS_FORCEINLINE_FUNCTION
934 typename std::enable_if<(Kokkos::Impl::are_integral<I0, I1>::value &&
935 (2 == Rank) && is_default_map &&
936 is_layout_right && (traits::rank_dynamic != 0)),
937 reference_type>::type
938 operator()(
const I0& i0,
const I1& i1)
const {
939 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1))
940 return m_map.m_impl_handle[i1 + m_map.m_impl_offset.m_stride * i0];
943 template <
typename I0,
typename I1>
944 KOKKOS_FORCEINLINE_FUNCTION
945 typename std::enable_if<(Kokkos::Impl::are_integral<I0, I1>::value &&
946 (2 == Rank) && is_default_map &&
948 reference_type>::type
949 operator()(
const I0& i0,
const I1& i1)
const {
950 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1))
951 return m_map.m_impl_handle[i0 * m_map.m_impl_offset.m_stride.S0 +
952 i1 * m_map.m_impl_offset.m_stride.S1];
958 template <
typename I0,
typename I1,
typename I2>
959 KOKKOS_FORCEINLINE_FUNCTION
960 typename std::enable_if<(Kokkos::Impl::are_integral<I0, I1, I2>::value &&
961 (3 == Rank) && is_default_map),
962 reference_type>::type
963 operator()(
const I0& i0,
const I1& i1,
const I2& i2)
const {
964 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1, i2))
965 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2)];
968 template <
typename I0,
typename I1,
typename I2>
969 KOKKOS_FORCEINLINE_FUNCTION
970 typename std::enable_if<(Kokkos::Impl::are_integral<I0, I1, I2>::value &&
971 (3 == Rank) && !is_default_map),
972 reference_type>::type
973 operator()(
const I0& i0,
const I1& i1,
const I2& i2)
const {
974 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1, i2))
975 return m_map.reference(i0, i1, i2);
981 template <
typename I0,
typename I1,
typename I2,
typename I3>
982 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
983 (Kokkos::Impl::are_integral<I0, I1, I2, I3>::value && (4 == Rank) &&
985 reference_type>::type
986 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3)
const {
987 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1, i2, i3))
988 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3)];
991 template <
typename I0,
typename I1,
typename I2,
typename I3>
992 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
993 (Kokkos::Impl::are_integral<I0, I1, I2, I3>::value && (4 == Rank) &&
995 reference_type>::type
996 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3)
const {
997 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1, i2, i3))
998 return m_map.reference(i0, i1, i2, i3);
1004 template <
typename I0,
typename I1,
typename I2,
typename I3,
typename I4>
1005 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
1006 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4>::value && (5 == Rank) &&
1008 reference_type>::type
1009 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3,
1010 const I4& i4)
const {
1011 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1, i2, i3, i4))
1012 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3, i4)];
1015 template <
typename I0,
typename I1,
typename I2,
typename I3,
typename I4>
1016 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
1017 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4>::value && (5 == Rank) &&
1019 reference_type>::type
1020 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3,
1021 const I4& i4)
const {
1022 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1, i2, i3, i4))
1023 return m_map.reference(i0, i1, i2, i3, i4);
1029 template <
typename I0,
typename I1,
typename I2,
typename I3,
typename I4,
1031 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
1032 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5>::value &&
1033 (6 == Rank) && is_default_map),
1034 reference_type>::type
1035 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3,
1036 const I4& i4,
const I5& i5)
const {
1037 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1, i2, i3, i4, i5))
1038 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3, i4, i5)];
1041 template <
typename I0,
typename I1,
typename I2,
typename I3,
typename I4,
1043 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
1044 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5>::value &&
1045 (6 == Rank) && !is_default_map),
1046 reference_type>::type
1047 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3,
1048 const I4& i4,
const I5& i5)
const {
1049 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY((m_track, m_map, i0, i1, i2, i3, i4, i5))
1050 return m_map.reference(i0, i1, i2, i3, i4, i5);
1056 template <
typename I0,
typename I1,
typename I2,
typename I3,
typename I4,
1057 typename I5,
typename I6>
1058 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
1059 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6>::value &&
1060 (7 == Rank) && is_default_map),
1061 reference_type>::type
1062 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3,
1063 const I4& i4,
const I5& i5,
const I6& i6)
const {
1064 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1065 (m_track, m_map, i0, i1, i2, i3, i4, i5, i6))
1066 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3, i4, i5, i6)];
1069 template <
typename I0,
typename I1,
typename I2,
typename I3,
typename I4,
1070 typename I5,
typename I6>
1071 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
1072 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6>::value &&
1073 (7 == Rank) && !is_default_map),
1074 reference_type>::type
1075 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3,
1076 const I4& i4,
const I5& i5,
const I6& i6)
const {
1077 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1078 (m_track, m_map, i0, i1, i2, i3, i4, i5, i6))
1079 return m_map.reference(i0, i1, i2, i3, i4, i5, i6);
1085 template <
typename I0,
typename I1,
typename I2,
typename I3,
typename I4,
1086 typename I5,
typename I6,
typename I7>
1087 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
1088 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6, I7>::value &&
1089 (8 == Rank) && is_default_map),
1090 reference_type>::type
1091 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3,
1092 const I4& i4,
const I5& i5,
const I6& i6,
const I7& i7)
const {
1093 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1094 (m_track, m_map, i0, i1, i2, i3, i4, i5, i6, i7))
1096 .m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3, i4, i5, i6, i7)];
1099 template <
typename I0,
typename I1,
typename I2,
typename I3,
typename I4,
1100 typename I5,
typename I6,
typename I7>
1101 KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<
1102 (Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6, I7>::value &&
1103 (8 == Rank) && !is_default_map),
1104 reference_type>::type
1105 operator()(
const I0& i0,
const I1& i1,
const I2& i2,
const I3& i3,
1106 const I4& i4,
const I5& i5,
const I6& i6,
const I7& i7)
const {
1107 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1108 (m_track, m_map, i0, i1, i2, i3, i4, i5, i6, i7))
1109 return m_map.reference(i0, i1, i2, i3, i4, i5, i6, i7);
1112 template <
class... Args>
1113 KOKKOS_FORCEINLINE_FUNCTION
1114 typename std::enable_if<(Kokkos::Impl::are_integral<Args...>::value &&
1116 reference_type>::type
1117 access(Args... KOKKOS_IMPL_SINK(args))
const {
1118 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1119 KOKKOS_IMPL_SINK((m_track, m_map, args...)))
1120 return m_map.reference();
1123 template <typename I0, class... Args>
1124 KOKKOS_FORCEINLINE_FUNCTION
1125 typename std::enable_if<(
Kokkos::Impl::are_integral<I0, Args...>::value &&
1126 (1 == Rank) && !is_default_map),
1127 reference_type>::type
1128 access(const I0& i0, Args... KOKKOS_IMPL_SINK(args))
const {
1129 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1130 KOKKOS_IMPL_SINK((m_track, m_map, i0, args...)))
1131 return m_map.reference(i0);
1134 template <typename I0, class... Args>
1135 KOKKOS_FORCEINLINE_FUNCTION
1136 typename std::enable_if<(
Kokkos::Impl::are_integral<I0, Args...>::value &&
1137 (1 == Rank) && is_default_map &&
1139 reference_type>::type
1140 access(const I0& i0, Args... KOKKOS_IMPL_SINK(args))
const {
1141 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1142 KOKKOS_IMPL_SINK((m_track, m_map, i0, args...)))
1143 return m_map.m_impl_handle[i0];
1146 template <typename I0, class... Args>
1147 KOKKOS_FORCEINLINE_FUNCTION
1148 typename std::enable_if<(
Kokkos::Impl::are_integral<I0, Args...>::value &&
1149 (1 == Rank) && is_default_map &&
1151 reference_type>::type
1152 access(const I0& i0, Args... KOKKOS_IMPL_SINK(args))
const {
1153 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1154 KOKKOS_IMPL_SINK((m_track, m_map, i0, args...)))
1155 return m_map.m_impl_handle[m_map.m_impl_offset.m_stride.S0 * i0];
1158 template <typename I0, typename I1, class... Args>
1159 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1160 (
Kokkos::Impl::are_integral<I0, I1, Args...>::value && (2 == Rank) &&
1162 reference_type>::type
1163 access(const I0& i0, const I1& i1, Args... KOKKOS_IMPL_SINK(args))
const {
1164 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1165 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, args...)))
1166 return m_map.reference(i0, i1);
1169 template <typename I0, typename I1, class... Args>
1170 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1171 (
Kokkos::Impl::are_integral<I0, I1, Args...>::value && (2 == Rank) &&
1172 is_default_map && is_layout_left && (traits::rank_dynamic == 0)),
1173 reference_type>::type
1174 access(const I0& i0, const I1& i1, Args... KOKKOS_IMPL_SINK(args))
const {
1175 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1176 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, args...)))
1177 return m_map.m_impl_handle[i0 + m_map.m_impl_offset.m_dim.N0 * i1];
1180 template <typename I0, typename I1, class... Args>
1181 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1182 (
Kokkos::Impl::are_integral<I0, I1, Args...>::value && (2 == Rank) &&
1183 is_default_map && is_layout_left && (traits::rank_dynamic != 0)),
1184 reference_type>::type
1185 access(const I0& i0, const I1& i1, Args... KOKKOS_IMPL_SINK(args))
const {
1186 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1187 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, args...)))
1188 return m_map.m_impl_handle[i0 + m_map.m_impl_offset.m_stride * i1];
1191 template <typename I0, typename I1, class... Args>
1192 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1193 (
Kokkos::Impl::are_integral<I0, I1, Args...>::value && (2 == Rank) &&
1194 is_default_map && is_layout_right && (traits::rank_dynamic == 0)),
1195 reference_type>::type
1196 access(const I0& i0, const I1& i1, Args... KOKKOS_IMPL_SINK(args))
const {
1197 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1198 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, args...)))
1199 return m_map.m_impl_handle[i1 + m_map.m_impl_offset.m_dim.N1 * i0];
1202 template <typename I0, typename I1, class... Args>
1203 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1204 (
Kokkos::Impl::are_integral<I0, I1, Args...>::value && (2 == Rank) &&
1205 is_default_map && is_layout_right && (traits::rank_dynamic != 0)),
1206 reference_type>::type
1207 access(const I0& i0, const I1& i1, Args... KOKKOS_IMPL_SINK(args))
const {
1208 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1209 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, args...)))
1210 return m_map.m_impl_handle[i1 + m_map.m_impl_offset.m_stride * i0];
1213 template <typename I0, typename I1, class... Args>
1214 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1215 (
Kokkos::Impl::are_integral<I0, I1, Args...>::value && (2 == Rank) &&
1216 is_default_map && is_layout_stride),
1217 reference_type>::type
1218 access(const I0& i0, const I1& i1, Args... KOKKOS_IMPL_SINK(args))
const {
1219 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1220 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, args...)))
1221 return m_map.m_impl_handle[i0 * m_map.m_impl_offset.m_stride.S0 +
1222 i1 * m_map.m_impl_offset.m_stride.S1];
1228 template <typename I0, typename I1, typename I2, class... Args>
1229 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1230 (
Kokkos::Impl::are_integral<I0, I1, I2, Args...>::value && (3 == Rank) &&
1232 reference_type>::type
1233 access(const I0& i0, const I1& i1, const I2& i2,
1234 Args... KOKKOS_IMPL_SINK(args))
const {
1235 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1236 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, args...)))
1237 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2)];
1240 template <typename I0, typename I1, typename I2, class... Args>
1241 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1242 (
Kokkos::Impl::are_integral<I0, I1, I2, Args...>::value && (3 == Rank) &&
1244 reference_type>::type
1245 access(const I0& i0, const I1& i1, const I2& i2,
1246 Args... KOKKOS_IMPL_SINK(args))
const {
1247 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1248 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, args...)))
1249 return m_map.reference(i0, i1, i2);
1255 template <typename I0, typename I1, typename I2, typename I3, class... Args>
1256 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1257 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, Args...>::value &&
1258 (4 == Rank) && is_default_map),
1259 reference_type>::type
1260 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
1261 Args... KOKKOS_IMPL_SINK(args))
const {
1262 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1263 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, i3, args...)))
1264 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3)];
1267 template <typename I0, typename I1, typename I2, typename I3, class... Args>
1268 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1269 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, Args...>::value &&
1270 (4 == Rank) && !is_default_map),
1271 reference_type>::type
1272 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3,
1273 Args... KOKKOS_IMPL_SINK(args))
const {
1274 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1275 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, i3, args...)))
1276 return m_map.reference(i0, i1, i2, i3);
1282 template <typename I0, typename I1, typename I2, typename I3, typename I4,
1284 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1285 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, Args...>::value &&
1286 (5 == Rank) && is_default_map),
1287 reference_type>::type
1288 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3, const I4& i4,
1289 Args... KOKKOS_IMPL_SINK(args))
const {
1290 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1291 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, i3, i4, args...)))
1292 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3, i4)];
1295 template <typename I0, typename I1, typename I2, typename I3, typename I4,
1297 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1298 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, Args...>::value &&
1299 (5 == Rank) && !is_default_map),
1300 reference_type>::type
1301 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3, const I4& i4,
1302 Args... KOKKOS_IMPL_SINK(args))
const {
1303 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1304 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, i3, i4, args...)))
1305 return m_map.reference(i0, i1, i2, i3, i4);
1311 template <typename I0, typename I1, typename I2, typename I3, typename I4,
1312 typename I5, class... Args>
1313 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1314 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, Args...>::value &&
1315 (6 == Rank) && is_default_map),
1316 reference_type>::type
1317 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3, const I4& i4,
1318 const I5& i5, Args... KOKKOS_IMPL_SINK(args))
const {
1319 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1320 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, i3, i4, i5, args...)))
1321 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3, i4, i5)];
1324 template <typename I0, typename I1, typename I2, typename I3, typename I4,
1325 typename I5, class... Args>
1326 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1327 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, Args...>::value &&
1328 (6 == Rank) && !is_default_map),
1329 reference_type>::type
1330 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3, const I4& i4,
1331 const I5& i5, Args... KOKKOS_IMPL_SINK(args))
const {
1332 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1333 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, i3, i4, i5, args...)))
1334 return m_map.reference(i0, i1, i2, i3, i4, i5);
1340 template <typename I0, typename I1, typename I2, typename I3, typename I4,
1341 typename I5, typename I6, class... Args>
1342 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1343 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6, Args...>::value &&
1344 (7 == Rank) && is_default_map),
1345 reference_type>::type
1346 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3, const I4& i4,
1347 const I5& i5, const I6& i6, Args... KOKKOS_IMPL_SINK(args))
const {
1348 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1349 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, i3, i4, i5, i6, args...)))
1350 return m_map.m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3, i4, i5, i6)];
1353 template <typename I0, typename I1, typename I2, typename I3, typename I4,
1354 typename I5, typename I6, class... Args>
1355 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1356 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6, Args...>::value &&
1357 (7 == Rank) && !is_default_map),
1358 reference_type>::type
1359 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3, const I4& i4,
1360 const I5& i5, const I6& i6, Args... KOKKOS_IMPL_SINK(args))
const {
1361 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(
1362 KOKKOS_IMPL_SINK((m_track, m_map, i0, i1, i2, i3, i4, i5, i6, args...)))
1363 return m_map.reference(i0, i1, i2, i3, i4, i5, i6);
1369 template <typename I0, typename I1, typename I2, typename I3, typename I4,
1370 typename I5, typename I6, typename I7, class... Args>
1371 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1372 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6, I7,
1374 (8 == Rank) && is_default_map),
1375 reference_type>::type
1376 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3, const I4& i4,
1377 const I5& i5, const I6& i6, const I7& i7,
1378 Args... KOKKOS_IMPL_SINK(args))
const {
1379 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(KOKKOS_IMPL_SINK(
1380 (m_track, m_map, i0, i1, i2, i3, i4, i5, i6, i7, args...)))
1382 .m_impl_handle[m_map.m_impl_offset(i0, i1, i2, i3, i4, i5, i6, i7)];
1385 template <typename I0, typename I1, typename I2, typename I3, typename I4,
1386 typename I5, typename I6, typename I7, class... Args>
1387 KOKKOS_FORCEINLINE_FUNCTION typename std::enable_if<
1388 (
Kokkos::Impl::are_integral<I0, I1, I2, I3, I4, I5, I6, I7,
1390 (8 == Rank) && !is_default_map),
1391 reference_type>::type
1392 access(const I0& i0, const I1& i1, const I2& i2, const I3& i3, const I4& i4,
1393 const I5& i5, const I6& i6, const I7& i7,
1394 Args... KOKKOS_IMPL_SINK(args))
const {
1395 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY(KOKKOS_IMPL_SINK(
1396 (m_track, m_map, i0, i1, i2, i3, i4, i5, i6, i7, args...)))
1397 return m_map.reference(i0, i1, i2, i3, i4, i5, i6, i7);
1400 #undef KOKKOS_IMPL_VIEW_OPERATOR_VERIFY 1405 KOKKOS_DEFAULTED_FUNCTION
1408 KOKKOS_DEFAULTED_FUNCTION
1411 KOKKOS_DEFAULTED_FUNCTION
1412 View(
const View&) =
default;
1414 KOKKOS_DEFAULTED_FUNCTION
1415 View(View&&) =
default;
1417 KOKKOS_DEFAULTED_FUNCTION
1418 View& operator=(
const View&) =
default;
1420 KOKKOS_DEFAULTED_FUNCTION
1421 View& operator=(View&&) =
default;
1427 template <
class RT,
class... RP>
1428 KOKKOS_INLINE_FUNCTION View(
1429 const View<RT, RP...>& rhs,
1430 typename std::enable_if<Kokkos::Impl::ViewMapping<
1431 traits,
typename View<RT, RP...>::traits,
1432 typename traits::specialize>::is_assignable_data_type>::type* =
1434 : m_track(rhs), m_map() {
1435 using SrcTraits =
typename View<RT, RP...>::traits;
1436 using Mapping = Kokkos::Impl::ViewMapping<traits, SrcTraits,
1437 typename traits::specialize>;
1438 static_assert(Mapping::is_assignable,
1439 "Incompatible View copy construction");
1440 Mapping::assign(m_map, rhs.m_map, rhs.m_track.m_tracker);
1443 template <
class RT,
class... RP>
1444 KOKKOS_INLINE_FUNCTION
typename std::enable_if<
1445 Kokkos::Impl::ViewMapping<
1446 traits,
typename View<RT, RP...>::traits,
1447 typename traits::specialize>::is_assignable_data_type,
1449 operator=(
const View<RT, RP...>& rhs) {
1450 using SrcTraits =
typename View<RT, RP...>::traits;
1451 using Mapping = Kokkos::Impl::ViewMapping<traits, SrcTraits,
1452 typename traits::specialize>;
1453 static_assert(Mapping::is_assignable,
"Incompatible View copy assignment");
1454 Mapping::assign(m_map, rhs.m_map, rhs.m_track.m_tracker);
1455 m_track.assign(rhs);
1463 template <
class RT,
class... RP,
class Arg0,
class... Args>
1464 KOKKOS_INLINE_FUNCTION View(
const View<RT, RP...>& src_view,
const Arg0 arg0,
1466 : m_track(src_view), m_map() {
1467 using SrcType =
View<RT, RP...>;
1469 using Mapping = Kokkos::Impl::ViewMapping<void,
typename SrcType::traits,
1472 using DstType =
typename Mapping::type;
1475 Kokkos::Impl::ViewMapping<traits,
typename DstType::traits,
1476 typename traits::specialize>::is_assignable,
1477 "Subview construction requires compatible view and subview arguments");
1479 Mapping::assign(m_map, src_view.m_map, arg0, args...);
1485 KOKKOS_INLINE_FUNCTION
1486 int use_count()
const {
return m_track.m_tracker.use_count(); }
1488 inline const std::string label()
const {
1489 return m_track.m_tracker
1490 .template get_label<typename traits::memory_space>();
1496 template <
class... P>
1497 explicit inline View(
1498 const Impl::ViewCtorProp<P...>& arg_prop,
1499 typename std::enable_if<!Impl::ViewCtorProp<P...>::has_pointer,
1500 typename traits::array_layout>::type
const&
1502 : m_track(), m_map() {
1504 using alloc_prop_input = Impl::ViewCtorProp<P...>;
1508 using alloc_prop = Impl::ViewCtorProp<
1510 typename std::conditional<alloc_prop_input::has_label,
1511 std::integral_constant<unsigned int, 0>,
1512 typename std::string>::type,
1513 typename std::conditional<
1514 alloc_prop_input::has_memory_space,
1515 std::integral_constant<unsigned int, 1>,
1516 typename traits::device_type::memory_space>::type,
1517 typename std::conditional<
1518 alloc_prop_input::has_execution_space,
1519 std::integral_constant<unsigned int, 2>,
1520 typename traits::device_type::execution_space>::type>;
1522 static_assert(traits::is_managed,
1523 "View allocation constructor requires managed memory");
1525 if (alloc_prop::initialize &&
1526 !alloc_prop::execution_space::impl_is_initialized()) {
1529 Kokkos::Impl::throw_runtime_exception(
1530 "Constructing View and initializing data with uninitialized " 1535 alloc_prop prop_copy(arg_prop);
1538 #if defined(KOKKOS_ENABLE_CUDA) 1544 if (std::is_same<Kokkos::CudaUVMSpace,
1545 typename traits::device_type::memory_space>::value) {
1546 typename traits::device_type::memory_space::execution_space().fence();
1551 Kokkos::Impl::SharedAllocationRecord<>* record =
1552 m_map.allocate_shared(prop_copy, arg_layout);
1555 #if defined(KOKKOS_ENABLE_CUDA) 1556 if (std::is_same<Kokkos::CudaUVMSpace,
1557 typename traits::device_type::memory_space>::value) {
1558 typename traits::device_type::memory_space::execution_space().fence();
1564 m_track.m_tracker.assign_allocated_record_to_uninitialized(record);
1567 KOKKOS_INLINE_FUNCTION
1568 void assign_data(pointer_type arg_data) {
1569 m_track.m_tracker.clear();
1570 m_map.assign_data(arg_data);
1574 template <
class... P>
1575 explicit KOKKOS_INLINE_FUNCTION
View(
1576 const Impl::ViewCtorProp<P...>& arg_prop,
1577 typename std::enable_if<Impl::ViewCtorProp<P...>::has_pointer,
1578 typename traits::array_layout>::type
const&
1582 m_map(arg_prop, arg_layout) {
1584 std::is_same<pointer_type,
1585 typename Impl::ViewCtorProp<P...>::pointer_type>::value,
1586 "Constructing View to wrap user memory must supply matching pointer " 1591 template <
class... P>
1592 explicit inline View(
1593 const Impl::ViewCtorProp<P...>& arg_prop,
1594 typename std::enable_if<!Impl::ViewCtorProp<P...>::has_pointer,
1595 size_t>::type
const arg_N0 =
1596 KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1597 const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1598 const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1599 const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1600 const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1601 const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1602 const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1603 const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
1605 typename traits::array_layout(arg_N0, arg_N1, arg_N2, arg_N3,
1606 arg_N4, arg_N5, arg_N6, arg_N7)) {
1607 #ifdef KOKKOS_ENABLE_OPENMPTARGET 1608 KOKKOS_IMPL_IF_ON_HOST
1609 Impl::runtime_check_rank_host(
1610 traits::rank_dynamic,
1611 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1612 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1613 else Impl::runtime_check_rank_device(
1614 traits::rank_dynamic,
1615 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1616 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1617 #elif defined(KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST) 1618 Impl::runtime_check_rank_host(
1619 traits::rank_dynamic,
1620 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1621 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1623 Impl::runtime_check_rank_device(
1624 traits::rank_dynamic,
1625 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1626 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1631 template <
class... P>
1632 explicit KOKKOS_INLINE_FUNCTION
View(
1633 const Impl::ViewCtorProp<P...>& arg_prop,
1634 typename std::enable_if<Impl::ViewCtorProp<P...>::has_pointer,
1635 size_t>::type
const arg_N0 =
1636 KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1637 const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1638 const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1639 const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1640 const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1641 const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1642 const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1643 const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
1645 typename traits::array_layout(arg_N0, arg_N1, arg_N2, arg_N3,
1646 arg_N4, arg_N5, arg_N6, arg_N7)) {
1647 #ifdef KOKKOS_ENABLE_OPENMPTARGET 1648 KOKKOS_IMPL_IF_ON_HOST
1649 Impl::runtime_check_rank_host(
1650 traits::rank_dynamic,
1651 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1652 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1653 else Impl::runtime_check_rank_device(
1654 traits::rank_dynamic,
1655 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1656 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1657 #elif defined(KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST) 1658 Impl::runtime_check_rank_host(
1659 traits::rank_dynamic,
1660 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1661 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1663 Impl::runtime_check_rank_device(
1664 traits::rank_dynamic,
1665 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1666 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1672 template <
typename Label>
1673 explicit inline View(
1674 const Label& arg_label,
1675 typename std::enable_if<Kokkos::Impl::is_view_label<Label>::value,
1676 typename traits::array_layout>::type
const&
1678 :
View(Impl::ViewCtorProp<std::string>(arg_label), arg_layout) {}
1681 template <
typename Label>
1682 explicit inline View(
1683 const Label& arg_label,
1684 typename std::enable_if<Kokkos::Impl::is_view_label<Label>::value,
1685 const size_t>::type arg_N0 =
1686 KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1687 const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1688 const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1689 const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1690 const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1691 const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1692 const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1693 const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
1694 :
View(Impl::ViewCtorProp<std::string>(arg_label),
1695 typename traits::array_layout(arg_N0, arg_N1, arg_N2, arg_N3,
1696 arg_N4, arg_N5, arg_N6, arg_N7)) {
1697 static_assert(traits::array_layout::is_extent_constructible,
1698 "Layout is not extent constructible. A layout object should " 1699 "be passed too.\n");
1701 #ifdef KOKKOS_ENABLE_OPENMPTARGET 1702 KOKKOS_IMPL_IF_ON_HOST
1703 Impl::runtime_check_rank_host(
1704 traits::rank_dynamic,
1705 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1706 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1707 else Impl::runtime_check_rank_device(
1708 traits::rank_dynamic,
1709 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1710 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1711 #elif defined(KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST) 1712 Impl::runtime_check_rank_host(
1713 traits::rank_dynamic,
1714 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1715 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1717 Impl::runtime_check_rank_device(
1718 traits::rank_dynamic,
1719 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1720 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1728 template <
class Traits>
1729 KOKKOS_INLINE_FUNCTION
View(
1730 const view_tracker_type& track,
1731 const Kokkos::Impl::ViewMapping<Traits, typename Traits::specialize>& map)
1732 : m_track(track), m_map() {
1734 Kokkos::Impl::ViewMapping<traits, Traits, typename traits::specialize>;
1735 static_assert(Mapping::is_assignable,
1736 "Incompatible View copy construction");
1737 Mapping::assign(m_map, map, track.m_tracker);
1743 template <
class Traits>
1744 KOKKOS_INLINE_FUNCTION
View(
1745 const typename view_tracker_type::track_type& track,
1746 const Kokkos::Impl::ViewMapping<Traits, typename Traits::specialize>& map)
1747 : m_track(track), m_map() {
1749 Kokkos::Impl::ViewMapping<traits, Traits, typename traits::specialize>;
1750 static_assert(Mapping::is_assignable,
1751 "Incompatible View copy construction");
1752 Mapping::assign(m_map, map, track);
1757 static constexpr
size_t required_allocation_size(
1758 const size_t arg_N0 = 0,
const size_t arg_N1 = 0,
const size_t arg_N2 = 0,
1759 const size_t arg_N3 = 0,
const size_t arg_N4 = 0,
const size_t arg_N5 = 0,
1760 const size_t arg_N6 = 0,
const size_t arg_N7 = 0) {
1761 return map_type::memory_span(
typename traits::array_layout(
1762 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7));
1765 explicit KOKKOS_INLINE_FUNCTION
View(
1766 pointer_type arg_ptr,
const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1767 const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1768 const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1769 const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1770 const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1771 const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1772 const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1773 const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
1774 :
View(Impl::ViewCtorProp<pointer_type>(arg_ptr),
1775 typename traits::array_layout(arg_N0, arg_N1, arg_N2, arg_N3,
1776 arg_N4, arg_N5, arg_N6, arg_N7)) {
1777 #ifdef KOKKOS_ENABLE_OPENMPTARGET 1778 KOKKOS_IMPL_IF_ON_HOST
1779 Impl::runtime_check_rank_host(
1780 traits::rank_dynamic,
1781 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1782 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1783 else Impl::runtime_check_rank_device(
1784 traits::rank_dynamic,
1785 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1786 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1787 #elif defined(KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST) 1788 Impl::runtime_check_rank_host(
1789 traits::rank_dynamic,
1790 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1791 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1793 Impl::runtime_check_rank_device(
1794 traits::rank_dynamic,
1795 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1796 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1801 explicit KOKKOS_INLINE_FUNCTION
View(
1802 pointer_type arg_ptr,
const typename traits::array_layout& arg_layout)
1803 :
View(Impl::ViewCtorProp<pointer_type>(arg_ptr), arg_layout) {}
1808 static inline size_t shmem_size(
const size_t arg_N0 = KOKKOS_INVALID_INDEX,
1809 const size_t arg_N1 = KOKKOS_INVALID_INDEX,
1810 const size_t arg_N2 = KOKKOS_INVALID_INDEX,
1811 const size_t arg_N3 = KOKKOS_INVALID_INDEX,
1812 const size_t arg_N4 = KOKKOS_INVALID_INDEX,
1813 const size_t arg_N5 = KOKKOS_INVALID_INDEX,
1814 const size_t arg_N6 = KOKKOS_INVALID_INDEX,
1815 const size_t arg_N7 = KOKKOS_INVALID_INDEX) {
1816 if (is_layout_stride) {
1818 "Kokkos::View::shmem_size(extents...) doesn't work with " 1819 "LayoutStride. Pass a LayoutStride object instead");
1821 const size_t num_passed_args = Impl::count_valid_integers(
1822 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1824 if (std::is_same<typename traits::specialize, void>::value &&
1825 num_passed_args != traits::rank_dynamic) {
1827 "Kokkos::View::shmem_size() rank_dynamic != number of arguments.\n");
1830 return View::shmem_size(
typename traits::array_layout(
1831 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7));
1834 static inline size_t shmem_size(
1835 typename traits::array_layout
const& arg_layout) {
1836 return map_type::memory_span(arg_layout) +
1837 sizeof(
typename traits::value_type);
1840 explicit KOKKOS_INLINE_FUNCTION
View(
1841 const typename traits::execution_space::scratch_memory_space& arg_space,
1842 const typename traits::array_layout& arg_layout)
1843 :
View(Impl::ViewCtorProp<pointer_type>(
1844 reinterpret_cast<pointer_type>(arg_space.get_shmem_aligned(
1845 map_type::memory_span(arg_layout),
1846 sizeof(typename traits::value_type)))),
1849 explicit KOKKOS_INLINE_FUNCTION
View(
1850 const typename traits::execution_space::scratch_memory_space& arg_space,
1851 const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1852 const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1853 const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1854 const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1855 const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1856 const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1857 const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG,
1858 const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG)
1859 :
View(Impl::ViewCtorProp<pointer_type>(
1860 reinterpret_cast<pointer_type>(arg_space.get_shmem_aligned(
1861 map_type::memory_span(typename traits::array_layout(
1862 arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6,
1864 sizeof(typename traits::value_type)))),
1865 typename traits::array_layout(arg_N0, arg_N1, arg_N2, arg_N3,
1866 arg_N4, arg_N5, arg_N6, arg_N7)) {
1867 #ifdef KOKKOS_ENABLE_OPENMPTARGET 1868 KOKKOS_IMPL_IF_ON_HOST
1869 Impl::runtime_check_rank_host(
1870 traits::rank_dynamic,
1871 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1872 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1873 else Impl::runtime_check_rank_device(
1874 traits::rank_dynamic,
1875 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1876 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1877 #elif defined(KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST) 1878 Impl::runtime_check_rank_host(
1879 traits::rank_dynamic,
1880 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1881 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7, label());
1883 Impl::runtime_check_rank_device(
1884 traits::rank_dynamic,
1885 std::is_same<typename traits::specialize, void>::value, arg_N0, arg_N1,
1886 arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7);
1896 template <
typename D,
class... P>
1897 KOKKOS_INLINE_FUNCTION constexpr
unsigned rank(
const View<D, P...>& V) {
1904 template <
class V,
class... Args>
1906 typename Kokkos::Impl::ViewMapping<
void 1909 typename V::traits, Args...>::type;
1911 template <
class D,
class... P,
class... Args>
1912 KOKKOS_INLINE_FUNCTION
1913 typename Kokkos::Impl::ViewMapping<
void 1916 ViewTraits<D, P...>, Args...>::type
1917 subview(
const View<D, P...>& src, Args... args) {
1918 static_assert(View<D, P...>::Rank ==
sizeof...(Args),
1919 "subview requires one argument for each source View rank");
1921 return typename Kokkos::Impl::ViewMapping<
1924 ViewTraits<D, P...>, Args...>::type(src, args...);
1927 template <
class MemoryTraits,
class D,
class... P,
class... Args>
1928 KOKKOS_INLINE_FUNCTION
typename Kokkos::Impl::ViewMapping<
1931 ViewTraits<D, P...>, Args...>::template apply<MemoryTraits>::type
1932 subview(
const View<D, P...>& src, Args... args) {
1933 static_assert(View<D, P...>::Rank ==
sizeof...(Args),
1934 "subview requires one argument for each source View rank");
1936 return typename Kokkos::Impl::ViewMapping<
1939 ViewTraits<D, P...>,
1940 Args...>::template apply<MemoryTraits>::type(src, args...);
1950 template <
class LT,
class... LP,
class RT,
class... RP>
1951 KOKKOS_INLINE_FUNCTION
bool operator==(
const View<LT, LP...>& lhs,
1952 const View<RT, RP...>& rhs) {
1954 using lhs_traits = ViewTraits<LT, LP...>;
1955 using rhs_traits = ViewTraits<RT, RP...>;
1957 return std::is_same<
typename lhs_traits::const_value_type,
1958 typename rhs_traits::const_value_type>::value &&
1959 std::is_same<
typename lhs_traits::array_layout,
1960 typename rhs_traits::array_layout>::value &&
1961 std::is_same<
typename lhs_traits::memory_space,
1962 typename rhs_traits::memory_space>::value &&
1963 unsigned(lhs_traits::rank) == unsigned(rhs_traits::rank) &&
1964 lhs.data() == rhs.data() && lhs.span() == rhs.span() &&
1965 lhs.extent(0) == rhs.extent(0) && lhs.extent(1) == rhs.extent(1) &&
1966 lhs.extent(2) == rhs.extent(2) && lhs.extent(3) == rhs.extent(3) &&
1967 lhs.extent(4) == rhs.extent(4) && lhs.extent(5) == rhs.extent(5) &&
1968 lhs.extent(6) == rhs.extent(6) && lhs.extent(7) == rhs.extent(7);
1971 template <
class LT,
class... LP,
class RT,
class... RP>
1972 KOKKOS_INLINE_FUNCTION
bool operator!=(
const View<LT, LP...>& lhs,
1973 const View<RT, RP...>& rhs) {
1974 return !(operator==(lhs, rhs));
1985 inline void shared_allocation_tracking_disable() {
1986 Kokkos::Impl::SharedAllocationRecord<void, void>::tracking_disable();
1989 inline void shared_allocation_tracking_enable() {
1990 Kokkos::Impl::SharedAllocationRecord<void, void>::tracking_enable();
2002 template <
class Specialize,
typename A,
typename B>
2003 struct CommonViewValueType;
2005 template <
typename A,
typename B>
2006 struct CommonViewValueType<void, A, B> {
2007 using value_type =
typename std::common_type<A, B>::type;
2010 template <
class Specialize,
class ValueType>
2011 struct CommonViewAllocProp;
2013 template <
class ValueType>
2014 struct CommonViewAllocProp<void, ValueType> {
2015 using value_type = ValueType;
2016 using scalar_array_type = ValueType;
2018 template <
class... Views>
2019 KOKKOS_INLINE_FUNCTION CommonViewAllocProp(
const Views&...) {}
2022 template <
class... Views>
2023 struct DeduceCommonViewAllocProp;
2027 template <
class FirstView>
2028 struct DeduceCommonViewAllocProp<FirstView> {
2029 using specialize =
typename FirstView::traits::specialize;
2031 using value_type =
typename FirstView::traits::value_type;
2033 enum :
bool { is_view = is_view<FirstView>::value };
2035 using prop_type = CommonViewAllocProp<specialize, value_type>;
2038 template <
class FirstView,
class... NextViews>
2039 struct DeduceCommonViewAllocProp<FirstView, NextViews...> {
2040 using NextTraits = DeduceCommonViewAllocProp<NextViews...>;
2042 using first_specialize =
typename FirstView::traits::specialize;
2043 using first_value_type =
typename FirstView::traits::value_type;
2045 enum :
bool { first_is_view = is_view<FirstView>::value };
2047 using next_specialize =
typename NextTraits::specialize;
2048 using next_value_type =
typename NextTraits::value_type;
2050 enum :
bool { next_is_view = NextTraits::is_view };
2057 static_assert(!(!std::is_same<first_specialize, next_specialize>::value &&
2058 !std::is_same<first_specialize, void>::value &&
2059 !std::is_same<void, next_specialize>::value),
2060 "Kokkos DeduceCommonViewAllocProp ERROR: Only one non-void " 2061 "specialize trait allowed");
2064 using specialize =
typename std::conditional<
2065 std::is_same<first_specialize, next_specialize>::value, first_specialize,
2066 typename std::conditional<(std::is_same<first_specialize, void>::value &&
2067 !std::is_same<next_specialize, void>::value),
2068 next_specialize, first_specialize>::type>::type;
2070 using value_type =
typename CommonViewValueType<specialize, first_value_type,
2071 next_value_type>::value_type;
2073 enum :
bool { is_view = (first_is_view && next_is_view) };
2075 using prop_type = CommonViewAllocProp<specialize, value_type>;
2080 template <
class... Views>
2081 using DeducedCommonPropsType =
2082 typename Impl::DeduceCommonViewAllocProp<Views...>::prop_type;
2085 template <
class... Views>
2086 KOKKOS_INLINE_FUNCTION DeducedCommonPropsType<Views...> common_view_alloc_prop(
2087 Views
const&... views) {
2088 return DeducedCommonPropsType<Views...>(views...);
2096 using Kokkos::is_view;
2101 #include <impl/Kokkos_ViewUniformType.hpp> 2102 #include <impl/Kokkos_Atomic_View.hpp>
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< std::is_integral< iType >::value, size_t >::type extent(const iType &r) const noexcept
rank() to be implemented
typename Impl::ViewUniformType< View, 0 >::type uniform_type
Unified types.
View to an array of data.
View< typename traits::scalar_array_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > array_type
Compatible view of array of scalar types.
Traits class for accessing attributes of a View.