580 template <
class,
class...>
582 template <
class,
class...>
583 friend class Kokkos::Impl::ViewMapping;
585 using view_tracker_type = Kokkos::Impl::ViewTracker<View>;
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,
608 View<
typename traits::const_data_type,
typename traits::array_layout,
613 View<
typename traits::non_const_data_type,
typename traits::array_layout,
618 View<
typename traits::non_const_data_type,
typename traits::array_layout,
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)
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)
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);