44 #ifndef KOKKOS_VIEW_HPP 45 #define KOKKOS_VIEW_HPP 47 #include <type_traits> 50 #include <initializer_list> 52 #include <Kokkos_Core_fwd.hpp> 53 #include <Kokkos_HostSpace.hpp> 54 #include <Kokkos_MemoryTraits.hpp> 55 #include <Kokkos_ExecPolicy.hpp> 57 #if defined(KOKKOS_ENABLE_PROFILING) 58 #include <impl/Kokkos_Profiling_Interface.hpp> 67 template<
class DataType >
68 struct ViewArrayAnalysis ;
70 template<
class DataType ,
class ArrayLayout
71 ,
typename ValueType =
72 typename ViewArrayAnalysis< DataType >::non_const_value_type
74 struct ViewDataAnalysis ;
76 template< class ,
class ... >
77 class ViewMapping {
public:
enum { is_assignable =
false }; };
81 template <
typename IntType>
82 KOKKOS_INLINE_FUNCTION
83 std::size_t count_valid_integers(
const IntType i0,
91 static_assert(std::is_integral<IntType>::value,
"count_valid_integers() must have integer arguments.");
93 return ( i0 !=KOKKOS_INVALID_INDEX ) + ( i1 !=KOKKOS_INVALID_INDEX ) + ( i2 !=KOKKOS_INVALID_INDEX ) +
94 ( i3 !=KOKKOS_INVALID_INDEX ) + ( i4 !=KOKKOS_INVALID_INDEX ) + ( i5 !=KOKKOS_INVALID_INDEX ) +
95 ( i6 !=KOKKOS_INVALID_INDEX ) + ( i7 !=KOKKOS_INVALID_INDEX );
100 KOKKOS_INLINE_FUNCTION
101 void runtime_check_rank_device(
const size_t dyn_rank,
102 const bool is_void_spec,
112 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE 114 if ( is_void_spec ) {
115 const size_t num_passed_args = count_valid_integers(i0, i1, i2, i3,
118 if ( num_passed_args != dyn_rank && is_void_spec ) {
120 Kokkos::abort(
"Number of arguments passed to Kokkos::View() constructor must match the dynamic rank of the view.") ;
127 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 128 KOKKOS_INLINE_FUNCTION
129 void runtime_check_rank_host(
const size_t dyn_rank,
130 const bool is_void_spec,
138 const size_t i7,
const std::string & label ){
140 #ifndef KOKKOS_ENABLE_DEPRECATED_CODE 142 if ( is_void_spec ) {
143 const size_t num_passed_args = count_valid_integers(i0, i1, i2, i3,
146 if ( num_passed_args != dyn_rank ) {
148 const std::string message =
"Constructor for Kokkos View '" + label +
"' has mismatched number of arguments. Number of arguments = " 149 + std::to_string(num_passed_args) +
" but dynamic rank = " + std::to_string(dyn_rank) +
" \n";
150 Kokkos::abort(message.c_str()) ;
163 template<
class ViewType ,
int Traits = 0 >
164 struct ViewUniformType;
190 template<
class DataType ,
class ... Properties >
196 typedef void execution_space ;
197 typedef void memory_space ;
198 typedef void HostMirrorSpace ;
199 typedef void array_layout ;
200 typedef void memory_traits ;
203 template<
class ... Prop >
207 typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
208 typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
209 typedef typename ViewTraits<void,Prop...>::HostMirrorSpace HostMirrorSpace ;
210 typedef typename ViewTraits<void,Prop...>::array_layout array_layout ;
211 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
214 template<
class ArrayLayout ,
class ... Prop >
215 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_array_layout<ArrayLayout>::value >::type , ArrayLayout , Prop ... >
219 typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
220 typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
221 typedef typename ViewTraits<void,Prop...>::HostMirrorSpace HostMirrorSpace ;
222 typedef ArrayLayout array_layout ;
223 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
226 template<
class Space ,
class ... Prop >
227 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_space<Space>::value >::type , Space , Prop ... >
231 static_assert( std::is_same<
typename ViewTraits<void,Prop...>::execution_space ,
void >::value &&
232 std::is_same<
typename ViewTraits<void,Prop...>::memory_space ,
void >::value &&
233 std::is_same<
typename ViewTraits<void,Prop...>::HostMirrorSpace ,
void >::value &&
234 std::is_same<
typename ViewTraits<void,Prop...>::array_layout ,
void >::value
235 ,
"Only one View Execution or Memory Space template argument" );
237 typedef typename Space::execution_space execution_space ;
238 typedef typename Space::memory_space memory_space ;
239 typedef typename Kokkos::Impl::HostMirror< Space >::Space HostMirrorSpace ;
240 typedef typename execution_space::array_layout array_layout ;
241 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
244 template<
class MemoryTraits ,
class ... Prop >
245 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_memory_traits<MemoryTraits>::value >::type , MemoryTraits , Prop ... >
249 static_assert( std::is_same<
typename ViewTraits<void,Prop...>::execution_space ,
void >::value &&
250 std::is_same<
typename ViewTraits<void,Prop...>::memory_space ,
void >::value &&
251 std::is_same<
typename ViewTraits<void,Prop...>::array_layout ,
void >::value &&
252 std::is_same<
typename ViewTraits<void,Prop...>::memory_traits ,
void >::value
253 ,
"MemoryTrait is the final optional template argument for a View" );
255 typedef void execution_space ;
256 typedef void memory_space ;
257 typedef void HostMirrorSpace ;
258 typedef void array_layout ;
259 typedef MemoryTraits memory_traits ;
263 template<
class DataType ,
class ... Properties >
268 typedef ViewTraits< void , Properties ... > prop ;
271 std::conditional< ! std::is_same< typename prop::execution_space , void >::value
272 ,
typename prop::execution_space
273 , Kokkos::DefaultExecutionSpace
278 std::conditional< ! std::is_same< typename prop::memory_space , void >::value
279 ,
typename prop::memory_space
280 ,
typename ExecutionSpace::memory_space
285 std::conditional< ! std::is_same< typename prop::array_layout , void >::value
286 ,
typename prop::array_layout
287 ,
typename ExecutionSpace::array_layout
293 < ! std::is_same< typename prop::HostMirrorSpace , void >::value
294 ,
typename prop::HostMirrorSpace
295 ,
typename Kokkos::Impl::HostMirror< ExecutionSpace >::Space
300 std::conditional< ! std::is_same< typename prop::memory_traits , void >::value
301 ,
typename prop::memory_traits
302 ,
typename Kokkos::MemoryManaged
308 typedef Kokkos::Impl::ViewDataAnalysis< DataType , ArrayLayout > data_analysis ;
315 typedef typename data_analysis::type data_type ;
316 typedef typename data_analysis::const_type const_data_type ;
317 typedef typename data_analysis::non_const_type non_const_data_type ;
322 typedef typename data_analysis::scalar_array_type scalar_array_type ;
323 typedef typename data_analysis::const_scalar_array_type const_scalar_array_type ;
324 typedef typename data_analysis::non_const_scalar_array_type non_const_scalar_array_type ;
329 typedef typename data_analysis::value_type value_type ;
330 typedef typename data_analysis::const_value_type const_value_type ;
331 typedef typename data_analysis::non_const_value_type non_const_value_type ;
336 typedef ArrayLayout array_layout ;
337 typedef typename data_analysis::dimension dimension ;
338 typedef typename data_analysis::specialize specialize ;
340 enum { rank = dimension::rank };
341 enum { rank_dynamic = dimension::rank_dynamic };
346 typedef ExecutionSpace execution_space ;
347 typedef MemorySpace memory_space ;
348 typedef Kokkos::Device<ExecutionSpace,MemorySpace> device_type ;
349 typedef MemoryTraits memory_traits ;
350 typedef HostMirrorSpace host_mirror_space ;
352 typedef typename MemorySpace::size_type size_type ;
354 enum { is_hostspace = std::is_same< MemorySpace , HostSpace >::value };
355 enum { is_managed = MemoryTraits::Unmanaged == 0 };
356 enum { is_random_access = MemoryTraits::RandomAccess == 1 };
443 template<
class DataType ,
class ... Properties >
451 #include <impl/Kokkos_ViewMapping.hpp> 452 #include <impl/Kokkos_ViewArray.hpp> 461 constexpr Kokkos::Impl::ALL_t
462 ALL = Kokkos::Impl::ALL_t();
464 constexpr Kokkos::Impl::WithoutInitializing_t
465 WithoutInitializing = Kokkos::Impl::WithoutInitializing_t();
467 constexpr Kokkos::Impl::AllowPadding_t
468 AllowPadding = Kokkos::Impl::AllowPadding_t();
481 template<
class ... Args >
483 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
487 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
490 static_assert( ! return_type::has_pointer
491 ,
"Cannot give pointer-to-memory for view allocation" );
493 return return_type( args... );
496 template<
class ... Args >
497 KOKKOS_INLINE_FUNCTION
498 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
499 view_wrap( Args
const & ... args )
502 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
505 static_assert( ! return_type::has_memory_space &&
506 ! return_type::has_execution_space &&
507 ! return_type::has_label &&
508 return_type::has_pointer
509 ,
"Must only give pointer-to-memory for view wrapping" );
511 return return_type( args... );
521 template<
class DataType ,
class ... Properties >
524 template<
class >
struct is_view :
public std::false_type {};
526 template<
class D,
class ... P >
527 struct is_view< View<D,P...> > :
public std::true_type {};
529 template<
class D,
class ... P >
530 struct is_view< const View<D,P...> > :
public std::true_type {};
532 template<
class DataType ,
class ... Properties >
533 class View :
public ViewTraits< DataType , Properties ... > {
536 template< class ,
class ... >
friend class View ;
537 template< class ,
class ... >
friend class Kokkos::Impl::ViewMapping ;
541 typedef ViewTraits< DataType , Properties ... > traits ;
545 typedef Kokkos::Impl::ViewMapping< traits , void > map_type ;
546 typedef Kokkos::Impl::SharedAllocationTracker track_type ;
555 typedef View<
typename traits::scalar_array_type ,
556 typename traits::array_layout ,
557 typename traits::device_type ,
558 typename traits::memory_traits >
562 typedef View<
typename traits::const_data_type ,
563 typename traits::array_layout ,
564 typename traits::device_type ,
565 typename traits::memory_traits >
569 typedef View<
typename traits::non_const_data_type ,
570 typename traits::array_layout ,
571 typename traits::device_type ,
572 typename traits::memory_traits >
576 typedef View<
typename traits::non_const_data_type ,
577 typename traits::array_layout ,
578 typename traits::host_mirror_space >
582 typedef View<
typename traits::non_const_data_type ,
583 typename traits::array_layout ,
584 typename traits::host_mirror_space >
589 typedef typename Impl::ViewUniformType<View,0>::const_type uniform_const_type;
590 typedef typename Impl::ViewUniformType<View,0>::runtime_type uniform_runtime_type;
591 typedef typename Impl::ViewUniformType<View,0>::runtime_const_type uniform_runtime_const_type;
592 typedef typename Impl::ViewUniformType<View,0>::nomemspace_type uniform_nomemspace_type;
593 typedef typename Impl::ViewUniformType<View,0>::const_nomemspace_type uniform_const_nomemspace_type;
594 typedef typename Impl::ViewUniformType<View,0>::runtime_nomemspace_type uniform_runtime_nomemspace_type;
595 typedef typename Impl::ViewUniformType<View,0>::runtime_const_nomemspace_type uniform_runtime_const_nomemspace_type;
600 enum { Rank = map_type::Rank };
608 template<
typename iType >
609 KOKKOS_INLINE_FUNCTION constexpr
610 typename std::enable_if< std::is_integral<iType>::value ,
size_t >::type
612 {
return m_map.extent(r); }
614 template<
typename iType >
615 KOKKOS_INLINE_FUNCTION constexpr
616 typename std::enable_if< std::is_integral<iType>::value ,
int >::type
617 extent_int(
const iType & r )
const 618 {
return static_cast<int>(m_map.extent(r)); }
620 KOKKOS_INLINE_FUNCTION constexpr
621 typename traits::array_layout layout()
const 622 {
return m_map.layout(); }
629 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 631 template<
typename iType >
632 KOKKOS_INLINE_FUNCTION constexpr
633 typename std::enable_if< std::is_integral<iType>::value ,
size_t >::type
634 dimension(
const iType & r )
const {
return extent( r ); }
636 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_0()
const {
return m_map.dimension_0(); }
637 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_1()
const {
return m_map.dimension_1(); }
638 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_2()
const {
return m_map.dimension_2(); }
639 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_3()
const {
return m_map.dimension_3(); }
640 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_4()
const {
return m_map.dimension_4(); }
641 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_5()
const {
return m_map.dimension_5(); }
642 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_6()
const {
return m_map.dimension_6(); }
643 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_7()
const {
return m_map.dimension_7(); }
649 KOKKOS_INLINE_FUNCTION constexpr
size_t size()
const {
return m_map.dimension_0() *
650 m_map.dimension_1() *
651 m_map.dimension_2() *
652 m_map.dimension_3() *
653 m_map.dimension_4() *
654 m_map.dimension_5() *
655 m_map.dimension_6() *
656 m_map.dimension_7(); }
658 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_0()
const {
return m_map.stride_0(); }
659 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_1()
const {
return m_map.stride_1(); }
660 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_2()
const {
return m_map.stride_2(); }
661 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_3()
const {
return m_map.stride_3(); }
662 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_4()
const {
return m_map.stride_4(); }
663 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_5()
const {
return m_map.stride_5(); }
664 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_6()
const {
return m_map.stride_6(); }
665 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_7()
const {
return m_map.stride_7(); }
667 template<
typename iType >
668 KOKKOS_INLINE_FUNCTION constexpr
669 typename std::enable_if< std::is_integral<iType>::value ,
size_t >::type
670 stride(iType r)
const {
671 return (r == 0 ? m_map.stride_0() :
672 (r == 1 ? m_map.stride_1() :
673 (r == 2 ? m_map.stride_2() :
674 (r == 3 ? m_map.stride_3() :
675 (r == 4 ? m_map.stride_4() :
676 (r == 5 ? m_map.stride_5() :
677 (r == 6 ? m_map.stride_6() :
678 m_map.stride_7())))))));
681 template<
typename iType >
682 KOKKOS_INLINE_FUNCTION
void stride( iType *
const s )
const { m_map.stride(s); }
687 typedef typename map_type::reference_type reference_type ;
688 typedef typename map_type::pointer_type pointer_type ;
690 enum { reference_type_is_lvalue_reference = std::is_lvalue_reference< reference_type >::value };
692 KOKKOS_INLINE_FUNCTION constexpr
size_t span()
const {
return m_map.span(); }
693 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 695 KOKKOS_INLINE_FUNCTION constexpr
size_t capacity()
const {
return m_map.span(); }
697 KOKKOS_INLINE_FUNCTION
bool span_is_contiguous()
const {
return m_map.span_is_contiguous(); }
698 KOKKOS_INLINE_FUNCTION constexpr pointer_type data()
const {
return m_map.data(); }
700 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 702 KOKKOS_INLINE_FUNCTION constexpr
bool is_contiguous()
const {
return m_map.span_is_contiguous(); }
704 KOKKOS_INLINE_FUNCTION constexpr pointer_type ptr_on_device()
const {
return m_map.data(); }
710 KOKKOS_INLINE_FUNCTION
711 const Kokkos::Impl::ViewMapping< traits , void > &
712 implementation_map()
const {
return m_map ; }
719 is_layout_left = std::is_same<
typename traits::array_layout
722 is_layout_right = std::is_same<
typename traits::array_layout
725 is_layout_stride = std::is_same<
typename traits::array_layout
729 std::is_same< typename traits::specialize , void >::value &&
730 ( is_layout_left || is_layout_right || is_layout_stride )
733 template< class Space , bool = Kokkos::Impl::MemorySpaceAccess< Space , typename traits::memory_space >::accessible >
struct verify_space
734 { KOKKOS_FORCEINLINE_FUNCTION
static void check() {} };
736 template<
class Space >
struct verify_space<Space,false>
737 { KOKKOS_FORCEINLINE_FUNCTION
static void check()
738 { Kokkos::abort(
"Kokkos::View ERROR: attempt to access inaccessible memory space"); };
741 #if defined( KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK ) 743 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( ARG ) \ 744 View::template verify_space< Kokkos::Impl::ActiveExecutionMemorySpace >::check(); \ 745 Kokkos::Impl::view_verify_operator_bounds< typename traits::memory_space > ARG ; 749 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( ARG ) \ 750 View::template verify_space< Kokkos::Impl::ActiveExecutionMemorySpace >::check(); 756 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE 757 template<
class ... Args >
758 KOKKOS_FORCEINLINE_FUNCTION
759 typename std::enable_if<( Kokkos::Impl::are_integral<Args...>::value
761 ), reference_type >::type
762 operator()( Args ... args )
const 764 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,args...) )
765 return m_map.reference();
768 template< typename I0
770 KOKKOS_FORCEINLINE_FUNCTION
771 typename std::enable_if<
772 (
Kokkos::Impl::are_integral<I0,Args...>::value
775 ), reference_type >::type
776 operator()( const I0 & i0,
779 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
780 return m_map.reference(i0);
783 template< typename I0
785 KOKKOS_FORCEINLINE_FUNCTION
786 typename std::enable_if<
787 (
Kokkos::Impl::are_integral<I0,Args...>::value
790 && ! is_layout_stride
791 ), reference_type >::type
792 operator()( const I0 & i0
793 , Args ... args )
const 795 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
796 return m_map.m_handle[ i0 ];
799 template< typename I0
801 KOKKOS_FORCEINLINE_FUNCTION
802 typename std::enable_if<
803 (
Kokkos::Impl::are_integral<I0,Args...>::value
807 ), reference_type >::type
808 operator()( const I0 & i0
809 , Args ... args )
const 811 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
812 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
818 template< typename I0 >
819 KOKKOS_FORCEINLINE_FUNCTION
820 typename std::enable_if<
821 (
Kokkos::Impl::are_integral<I0>::value
824 ), reference_type >::type
825 operator[]( const I0 & i0 )
const 827 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
828 return m_map.reference(i0);
831 template<
typename I0 >
832 KOKKOS_FORCEINLINE_FUNCTION
833 typename std::enable_if<
834 ( Kokkos::Impl::are_integral<I0>::value
837 && ! is_layout_stride
838 ), reference_type >::type
839 operator[](
const I0 & i0 )
const 841 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
842 return m_map.m_handle[ i0 ];
845 template<
typename I0 >
846 KOKKOS_FORCEINLINE_FUNCTION
847 typename std::enable_if<
848 ( Kokkos::Impl::are_integral<I0>::value
852 ), reference_type >::type
853 operator[](
const I0 & i0 )
const 855 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
856 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
860 template<
typename I0 ,
typename I1
862 KOKKOS_FORCEINLINE_FUNCTION
863 typename std::enable_if<
864 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
867 ), reference_type >::type
868 operator()(
const I0 & i0 ,
const I1 & i1
869 , Args ... args )
const 871 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
872 return m_map.reference(i0,i1);
875 template< typename I0 , typename I1
877 KOKKOS_FORCEINLINE_FUNCTION
878 typename std::enable_if<
879 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
882 && is_layout_left && ( traits::rank_dynamic == 0 )
883 ), reference_type >::type
884 operator()( const I0 & i0 , const I1 & i1
885 , Args ... args )
const 887 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
888 return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
891 template< typename I0 , typename I1
893 KOKKOS_FORCEINLINE_FUNCTION
894 typename std::enable_if<
895 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
898 && is_layout_left && ( traits::rank_dynamic != 0 )
899 ), reference_type >::type
900 operator()( const I0 & i0 , const I1 & i1
901 , Args ... args )
const 903 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
904 return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
907 template< typename I0 , typename I1
909 KOKKOS_FORCEINLINE_FUNCTION
910 typename std::enable_if<
911 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
914 && is_layout_right && ( traits::rank_dynamic == 0 )
915 ), reference_type >::type
916 operator()( const I0 & i0 , const I1 & i1
917 , Args ... args )
const 919 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
920 return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
923 template< typename I0 , typename I1
925 KOKKOS_FORCEINLINE_FUNCTION
926 typename std::enable_if<
927 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
930 && is_layout_right && ( traits::rank_dynamic != 0 )
931 ), reference_type >::type
932 operator()( const I0 & i0 , const I1 & i1
933 , Args ... args )
const 935 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
936 return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
939 template< typename I0 , typename I1
941 KOKKOS_FORCEINLINE_FUNCTION
942 typename std::enable_if<
943 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
947 ), reference_type >::type
948 operator()( const I0 & i0 , const I1 & i1
949 , Args ... args )
const 951 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
952 return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
953 i1 * m_map.m_offset.m_stride.S1 ];
959 template< typename I0 , typename I1 , typename I2
961 KOKKOS_FORCEINLINE_FUNCTION
962 typename std::enable_if<
963 (
Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
966 ), reference_type >::type
967 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2
968 , Args ... args )
const 970 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,args...) )
971 return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
974 template< typename I0 , typename I1 , typename I2
976 KOKKOS_FORCEINLINE_FUNCTION
977 typename std::enable_if<
978 (
Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
981 ), reference_type >::type
982 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2
983 , Args ... args )
const 985 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,args...) )
986 return m_map.reference(i0,i1,i2);
992 template< typename I0 , typename I1 , typename I2 , typename I3
994 KOKKOS_FORCEINLINE_FUNCTION
995 typename std::enable_if<
996 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
999 ), reference_type >::type
1000 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1001 , Args ... args )
const 1003 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,args...) )
1004 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
1007 template< typename I0 , typename I1 , typename I2 , typename I3
1009 KOKKOS_FORCEINLINE_FUNCTION
1010 typename std::enable_if<
1011 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
1014 ), reference_type >::type
1015 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1016 , Args ... args )
const 1018 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,args...) )
1019 return m_map.reference(i0,i1,i2,i3);
1025 template< typename I0 , typename I1 , typename I2 , typename I3
1028 KOKKOS_FORCEINLINE_FUNCTION
1029 typename std::enable_if<
1030 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1033 ), reference_type >::type
1034 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1036 , Args ... args )
const 1038 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,args...) )
1039 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
1042 template< typename I0 , typename I1 , typename I2 , typename I3
1045 KOKKOS_FORCEINLINE_FUNCTION
1046 typename std::enable_if<
1047 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1050 ), reference_type >::type
1051 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1053 , Args ... args )
const 1055 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,args...) )
1056 return m_map.reference(i0,i1,i2,i3,i4);
1062 template< typename I0 , typename I1 , typename I2 , typename I3
1063 , typename I4 , typename I5
1065 KOKKOS_FORCEINLINE_FUNCTION
1066 typename std::enable_if<
1067 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1070 ), reference_type >::type
1071 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1072 , const I4 & i4 , const I5 & i5
1073 , Args ... args )
const 1075 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,args...) )
1076 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
1079 template< typename I0 , typename I1 , typename I2 , typename I3
1080 , typename I4 , typename I5
1082 KOKKOS_FORCEINLINE_FUNCTION
1083 typename std::enable_if<
1084 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1087 ), reference_type >::type
1088 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1089 , const I4 & i4 , const I5 & i5
1090 , Args ... args )
const 1092 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,args...) )
1093 return m_map.reference(i0,i1,i2,i3,i4,i5);
1099 template< typename I0 , typename I1 , typename I2 , typename I3
1100 , typename I4 , typename I5 , typename I6
1102 KOKKOS_FORCEINLINE_FUNCTION
1103 typename std::enable_if<
1104 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1107 ), reference_type >::type
1108 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1109 , const I4 & i4 , const I5 & i5 , const I6 & i6
1110 , Args ... args )
const 1112 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1113 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
1116 template< typename I0 , typename I1 , typename I2 , typename I3
1117 , typename I4 , typename I5 , typename I6
1119 KOKKOS_FORCEINLINE_FUNCTION
1120 typename std::enable_if<
1121 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1124 ), reference_type >::type
1125 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1126 , const I4 & i4 , const I5 & i5 , const I6 & i6
1127 , Args ... args )
const 1129 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1130 return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
1136 template< typename I0 , typename I1 , typename I2 , typename I3
1137 , typename I4 , typename I5 , typename I6 , typename I7
1139 KOKKOS_FORCEINLINE_FUNCTION
1140 typename std::enable_if<
1141 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1144 ), reference_type >::type
1145 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1146 , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1147 , Args ... args )
const 1149 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1150 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1153 template< typename I0 , typename I1 , typename I2 , typename I3
1154 , typename I4 , typename I5 , typename I6 , typename I7
1156 KOKKOS_FORCEINLINE_FUNCTION
1157 typename std::enable_if<
1158 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1161 ), reference_type >::type
1162 operator()( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1163 , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1164 , Args ... args )
const 1166 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1167 return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1175 KOKKOS_FORCEINLINE_FUNCTION
1179 return m_map.reference();
1185 template<
typename I0>
1186 KOKKOS_FORCEINLINE_FUNCTION
1187 typename std::enable_if<
1188 ( Kokkos::Impl::are_integral<I0>::value
1191 ), reference_type >::type
1192 operator()(
const I0 & i0)
const 1194 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1195 return m_map.reference(i0);
1198 template<
typename I0>
1199 KOKKOS_FORCEINLINE_FUNCTION
1200 typename std::enable_if<
1201 ( Kokkos::Impl::are_integral<I0>::value
1204 && ! is_layout_stride
1205 ), reference_type >::type
1206 operator()(
const I0 & i0 )
const 1208 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1209 return m_map.m_handle[ i0 ];
1212 template<
typename I0 >
1213 KOKKOS_FORCEINLINE_FUNCTION
1214 typename std::enable_if<
1215 ( Kokkos::Impl::are_integral<I0>::value
1219 ), reference_type >::type
1220 operator()(
const I0 & i0)
const 1222 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1223 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
1228 template<
typename I0 >
1229 KOKKOS_FORCEINLINE_FUNCTION
1230 typename std::enable_if<
1231 ( Kokkos::Impl::are_integral<I0>::value
1234 ), reference_type >::type
1235 operator[](
const I0 & i0 )
const 1237 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1238 return m_map.reference(i0);
1241 template<
typename I0 >
1242 KOKKOS_FORCEINLINE_FUNCTION
1243 typename std::enable_if<
1244 ( Kokkos::Impl::are_integral<I0>::value
1247 && ! is_layout_stride
1248 ), reference_type >::type
1249 operator[](
const I0 & i0 )
const 1251 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1252 return m_map.m_handle[ i0 ];
1255 template<
typename I0 >
1256 KOKKOS_FORCEINLINE_FUNCTION
1257 typename std::enable_if<
1258 ( Kokkos::Impl::are_integral<I0>::value
1262 ), reference_type >::type
1263 operator[](
const I0 & i0 )
const 1265 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0) )
1266 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
1273 template<
typename I0 ,
typename I1 >
1274 KOKKOS_FORCEINLINE_FUNCTION
1275 typename std::enable_if<
1276 ( Kokkos::Impl::are_integral<I0,I1>::value
1279 ), reference_type >::type
1280 operator()(
const I0 & i0 ,
const I1 & i1)
const 1282 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1283 return m_map.reference(i0,i1);
1286 template<
typename I0 ,
typename I1 >
1287 KOKKOS_FORCEINLINE_FUNCTION
1288 typename std::enable_if<
1289 ( Kokkos::Impl::are_integral<I0,I1>::value
1292 && is_layout_left && ( traits::rank_dynamic == 0 )
1293 ), reference_type >::type
1294 operator()(
const I0 & i0 ,
const I1 & i1)
const 1296 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1297 return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
1300 template<
typename I0 ,
typename I1>
1301 KOKKOS_FORCEINLINE_FUNCTION
1302 typename std::enable_if<
1303 ( Kokkos::Impl::are_integral<I0,I1>::value
1306 && is_layout_left && ( traits::rank_dynamic != 0 )
1307 ), reference_type >::type
1308 operator()(
const I0 & i0 ,
const I1 & i1)
const 1310 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1311 return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
1314 template<
typename I0 ,
typename I1 >
1315 KOKKOS_FORCEINLINE_FUNCTION
1316 typename std::enable_if<
1317 ( Kokkos::Impl::are_integral<I0,I1>::value
1320 && is_layout_right && ( traits::rank_dynamic == 0 )
1321 ), reference_type >::type
1322 operator()(
const I0 & i0 ,
const I1 & i1 )
const 1324 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1325 return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
1328 template<
typename I0 ,
typename I1 >
1329 KOKKOS_FORCEINLINE_FUNCTION
1330 typename std::enable_if<
1331 ( Kokkos::Impl::are_integral<I0,I1>::value
1334 && is_layout_right && ( traits::rank_dynamic != 0 )
1335 ), reference_type >::type
1336 operator()(
const I0 & i0 ,
const I1 & i1 )
const 1338 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1339 return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
1342 template<
typename I0 ,
typename I1>
1343 KOKKOS_FORCEINLINE_FUNCTION
1344 typename std::enable_if<
1345 ( Kokkos::Impl::are_integral<I0,I1>::value
1349 ), reference_type >::type
1350 operator()(
const I0 & i0 ,
const I1 & i1 )
const 1352 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1) )
1353 return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
1354 i1 * m_map.m_offset.m_stride.S1 ];
1360 template<
typename I0 ,
typename I1 ,
typename I2 >
1361 KOKKOS_FORCEINLINE_FUNCTION
1362 typename std::enable_if<
1363 ( Kokkos::Impl::are_integral<I0,I1,I2>::value
1366 ), reference_type >::type
1367 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2)
const 1369 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2) )
1370 return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
1373 template<
typename I0 ,
typename I1 ,
typename I2>
1374 KOKKOS_FORCEINLINE_FUNCTION
1375 typename std::enable_if<
1376 ( Kokkos::Impl::are_integral<I0,I1,I2>::value
1379 ), reference_type >::type
1380 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2)
const 1382 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2) )
1383 return m_map.reference(i0,i1,i2);
1389 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3>
1390 KOKKOS_FORCEINLINE_FUNCTION
1391 typename std::enable_if<
1392 ( Kokkos::Impl::are_integral<I0,I1,I2,I3>::value
1395 ), reference_type >::type
1396 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3)
const 1398 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3) )
1399 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
1402 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3 >
1403 KOKKOS_FORCEINLINE_FUNCTION
1404 typename std::enable_if<
1405 ( Kokkos::Impl::are_integral<I0,I1,I2,I3>::value
1408 ), reference_type >::type
1409 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3)
const 1411 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3) )
1412 return m_map.reference(i0,i1,i2,i3);
1418 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1420 KOKKOS_FORCEINLINE_FUNCTION
1421 typename std::enable_if<
1422 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4>::value
1425 ), reference_type >::type
1426 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1427 ,
const I4 & i4 )
const 1429 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4) )
1430 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
1433 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1435 KOKKOS_FORCEINLINE_FUNCTION
1436 typename std::enable_if<
1437 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4>::value
1440 ), reference_type >::type
1441 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1442 ,
const I4 & i4)
const 1444 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4) )
1445 return m_map.reference(i0,i1,i2,i3,i4);
1451 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1452 ,
typename I4 ,
typename I5 >
1453 KOKKOS_FORCEINLINE_FUNCTION
1454 typename std::enable_if<
1455 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5>::value
1458 ), reference_type >::type
1459 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1460 ,
const I4 & i4 ,
const I5 & i5 )
const 1462 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5) )
1463 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
1466 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1467 ,
typename I4 ,
typename I5>
1468 KOKKOS_FORCEINLINE_FUNCTION
1469 typename std::enable_if<
1470 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5>::value
1473 ), reference_type >::type
1474 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1475 ,
const I4 & i4 ,
const I5 & i5)
const 1477 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5) )
1478 return m_map.reference(i0,i1,i2,i3,i4,i5);
1484 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1485 ,
typename I4 ,
typename I5 ,
typename I6>
1486 KOKKOS_FORCEINLINE_FUNCTION
1487 typename std::enable_if<
1488 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6>::value
1491 ), reference_type >::type
1492 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1493 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6)
const 1495 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6) )
1496 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
1499 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1500 ,
typename I4 ,
typename I5 ,
typename I6 >
1501 KOKKOS_FORCEINLINE_FUNCTION
1502 typename std::enable_if<
1503 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6>::value
1506 ), reference_type >::type
1507 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1508 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6)
const 1510 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6) )
1511 return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
1517 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1518 ,
typename I4 ,
typename I5 ,
typename I6 ,
typename I7 >
1519 KOKKOS_FORCEINLINE_FUNCTION
1520 typename std::enable_if<
1521 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7>::value
1524 ), reference_type >::type
1525 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1526 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 ,
const I7 & i7)
const 1528 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7) )
1529 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1532 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1533 ,
typename I4 ,
typename I5 ,
typename I6 ,
typename I7>
1534 KOKKOS_FORCEINLINE_FUNCTION
1535 typename std::enable_if<
1536 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7>::value
1539 ), reference_type >::type
1540 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1541 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 ,
const I7 & i7 )
const 1543 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7) )
1544 return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1549 template<
class ... Args >
1550 KOKKOS_FORCEINLINE_FUNCTION
1551 typename std::enable_if<( Kokkos::Impl::are_integral<Args...>::value
1553 ), reference_type >::type
1554 access( Args ... args )
const 1556 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,args...) )
1557 return m_map.reference();
1560 template< typename I0
1562 KOKKOS_FORCEINLINE_FUNCTION
1563 typename std::enable_if<
1564 (
Kokkos::Impl::are_integral<I0,Args...>::value
1567 ), reference_type >::type
1568 access( const I0 & i0,
1569 Args ... args)
const 1571 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
1572 return m_map.reference(i0);
1575 template< typename I0
1577 KOKKOS_FORCEINLINE_FUNCTION
1578 typename std::enable_if<
1579 (
Kokkos::Impl::are_integral<I0,Args...>::value
1582 && ! is_layout_stride
1583 ), reference_type >::type
1584 access( const I0 & i0
1585 , Args ... args )
const 1587 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
1588 return m_map.m_handle[ i0 ];
1591 template< typename I0
1593 KOKKOS_FORCEINLINE_FUNCTION
1594 typename std::enable_if<
1595 (
Kokkos::Impl::are_integral<I0,Args...>::value
1599 ), reference_type >::type
1600 access( const I0 & i0
1601 , Args ... args )
const 1603 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,args...) )
1604 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
1607 template< typename I0 , typename I1
1609 KOKKOS_FORCEINLINE_FUNCTION
1610 typename std::enable_if<
1611 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
1614 ), reference_type >::type
1615 access( const I0 & i0 , const I1 & i1
1616 , Args ... args )
const 1618 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1619 return m_map.reference(i0,i1);
1622 template< typename I0 , typename I1
1624 KOKKOS_FORCEINLINE_FUNCTION
1625 typename std::enable_if<
1626 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
1629 && is_layout_left && ( traits::rank_dynamic == 0 )
1630 ), reference_type >::type
1631 access( const I0 & i0 , const I1 & i1
1632 , Args ... args )
const 1634 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1635 return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
1638 template< typename I0 , typename I1
1640 KOKKOS_FORCEINLINE_FUNCTION
1641 typename std::enable_if<
1642 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
1645 && is_layout_left && ( traits::rank_dynamic != 0 )
1646 ), reference_type >::type
1647 access( const I0 & i0 , const I1 & i1
1648 , Args ... args )
const 1650 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1651 return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
1654 template< typename I0 , typename I1
1656 KOKKOS_FORCEINLINE_FUNCTION
1657 typename std::enable_if<
1658 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
1661 && is_layout_right && ( traits::rank_dynamic == 0 )
1662 ), reference_type >::type
1663 access( const I0 & i0 , const I1 & i1
1664 , Args ... args )
const 1666 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1667 return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
1670 template< typename I0 , typename I1
1672 KOKKOS_FORCEINLINE_FUNCTION
1673 typename std::enable_if<
1674 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
1677 && is_layout_right && ( traits::rank_dynamic != 0 )
1678 ), reference_type >::type
1679 access( const I0 & i0 , const I1 & i1
1680 , Args ... args )
const 1682 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1683 return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
1686 template< typename I0 , typename I1
1688 KOKKOS_FORCEINLINE_FUNCTION
1689 typename std::enable_if<
1690 (
Kokkos::Impl::are_integral<I0,I1,Args...>::value
1694 ), reference_type >::type
1695 access( const I0 & i0 , const I1 & i1
1696 , Args ... args )
const 1698 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,args...) )
1699 return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
1700 i1 * m_map.m_offset.m_stride.S1 ];
1706 template< typename I0 , typename I1 , typename I2
1708 KOKKOS_FORCEINLINE_FUNCTION
1709 typename std::enable_if<
1710 (
Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
1713 ), reference_type >::type
1714 access( const I0 & i0 , const I1 & i1 , const I2 & i2
1715 , Args ... args )
const 1717 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,args...) )
1718 return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
1721 template< typename I0 , typename I1 , typename I2
1723 KOKKOS_FORCEINLINE_FUNCTION
1724 typename std::enable_if<
1725 (
Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
1728 ), reference_type >::type
1729 access( const I0 & i0 , const I1 & i1 , const I2 & i2
1730 , Args ... args )
const 1732 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,args...) )
1733 return m_map.reference(i0,i1,i2);
1739 template< typename I0 , typename I1 , typename I2 , typename I3
1741 KOKKOS_FORCEINLINE_FUNCTION
1742 typename std::enable_if<
1743 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
1746 ), reference_type >::type
1747 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1748 , Args ... args )
const 1750 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,args...) )
1751 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
1754 template< typename I0 , typename I1 , typename I2 , typename I3
1756 KOKKOS_FORCEINLINE_FUNCTION
1757 typename std::enable_if<
1758 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
1761 ), reference_type >::type
1762 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1763 , Args ... args )
const 1765 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,args...) )
1766 return m_map.reference(i0,i1,i2,i3);
1772 template< typename I0 , typename I1 , typename I2 , typename I3
1775 KOKKOS_FORCEINLINE_FUNCTION
1776 typename std::enable_if<
1777 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1780 ), reference_type >::type
1781 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1783 , Args ... args )
const 1785 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,args...) )
1786 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
1789 template< typename I0 , typename I1 , typename I2 , typename I3
1792 KOKKOS_FORCEINLINE_FUNCTION
1793 typename std::enable_if<
1794 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1797 ), reference_type >::type
1798 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1800 , Args ... args )
const 1802 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,args...) )
1803 return m_map.reference(i0,i1,i2,i3,i4);
1809 template< typename I0 , typename I1 , typename I2 , typename I3
1810 , typename I4 , typename I5
1812 KOKKOS_FORCEINLINE_FUNCTION
1813 typename std::enable_if<
1814 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1817 ), reference_type >::type
1818 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1819 , const I4 & i4 , const I5 & i5
1820 , Args ... args )
const 1822 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,args...) )
1823 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
1826 template< typename I0 , typename I1 , typename I2 , typename I3
1827 , typename I4 , typename I5
1829 KOKKOS_FORCEINLINE_FUNCTION
1830 typename std::enable_if<
1831 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1834 ), reference_type >::type
1835 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1836 , const I4 & i4 , const I5 & i5
1837 , Args ... args )
const 1839 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,args...) )
1840 return m_map.reference(i0,i1,i2,i3,i4,i5);
1846 template< typename I0 , typename I1 , typename I2 , typename I3
1847 , typename I4 , typename I5 , typename I6
1849 KOKKOS_FORCEINLINE_FUNCTION
1850 typename std::enable_if<
1851 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1854 ), reference_type >::type
1855 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1856 , const I4 & i4 , const I5 & i5 , const I6 & i6
1857 , Args ... args )
const 1859 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1860 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
1863 template< typename I0 , typename I1 , typename I2 , typename I3
1864 , typename I4 , typename I5 , typename I6
1866 KOKKOS_FORCEINLINE_FUNCTION
1867 typename std::enable_if<
1868 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1871 ), reference_type >::type
1872 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1873 , const I4 & i4 , const I5 & i5 , const I6 & i6
1874 , Args ... args )
const 1876 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1877 return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
1883 template< typename I0 , typename I1 , typename I2 , typename I3
1884 , typename I4 , typename I5 , typename I6 , typename I7
1886 KOKKOS_FORCEINLINE_FUNCTION
1887 typename std::enable_if<
1888 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1891 ), reference_type >::type
1892 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1893 , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1894 , Args ... args )
const 1896 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1897 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1900 template< typename I0 , typename I1 , typename I2 , typename I3
1901 , typename I4 , typename I5 , typename I6 , typename I7
1903 KOKKOS_FORCEINLINE_FUNCTION
1904 typename std::enable_if<
1905 (
Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1908 ), reference_type >::type
1909 access( const I0 & i0 , const I1 & i1 , const I2 & i2 , const I3 & i3
1910 , const I4 & i4 , const I5 & i5 , const I6 & i6 , const I7 & i7
1911 , Args ... args )
const 1913 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (m_track,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1914 return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1918 #undef KOKKOS_IMPL_VIEW_OPERATOR_VERIFY 1923 KOKKOS_INLINE_FUNCTION
1926 KOKKOS_INLINE_FUNCTION
1927 View() : m_track(), m_map() {}
1929 KOKKOS_INLINE_FUNCTION
1930 View(
const View & rhs ) : m_track( rhs.m_track, traits::is_managed ), m_map( rhs.m_map ) {}
1932 KOKKOS_INLINE_FUNCTION
1933 View( View && rhs ) : m_track( std::move(rhs.m_track) ), m_map( std::move(rhs.m_map) ) {}
1935 KOKKOS_INLINE_FUNCTION
1936 View & operator = (
const View & rhs ) { m_track = rhs.m_track ; m_map = rhs.m_map ;
return *this ; }
1938 KOKKOS_INLINE_FUNCTION
1939 View & operator = ( View && rhs ) { m_track = std::move(rhs.m_track) ; m_map = std::move(rhs.m_map) ;
return *this ; }
1945 template<
class RT ,
class ... RP >
1946 KOKKOS_INLINE_FUNCTION
1947 View(
const View<RT,RP...> & rhs )
1948 : m_track( rhs.m_track , traits::is_managed )
1951 typedef typename View<RT,RP...>::traits SrcTraits ;
1952 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1953 static_assert( Mapping::is_assignable ,
"Incompatible View copy construction" );
1954 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1957 template<
class RT ,
class ... RP >
1958 KOKKOS_INLINE_FUNCTION
1959 View & operator = (
const View<RT,RP...> & rhs )
1961 typedef typename View<RT,RP...>::traits SrcTraits ;
1962 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1963 static_assert( Mapping::is_assignable ,
"Incompatible View copy assignment" );
1964 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1965 m_track.assign( rhs.m_track , traits::is_managed );
1973 template<
class RT ,
class ... RP ,
class Arg0 ,
class ... Args >
1974 KOKKOS_INLINE_FUNCTION
1975 View(
const View< RT , RP... > & src_view
1976 ,
const Arg0 & arg0 , Args ... args )
1977 : m_track( src_view.m_track , traits::is_managed )
1980 typedef View< RT , RP... > SrcType ;
1982 typedef Kokkos::Impl::ViewMapping
1984 ,
typename SrcType::traits
1985 , Arg0 , Args... > Mapping ;
1987 typedef typename Mapping::type DstType ;
1989 static_assert( Kokkos::Impl::ViewMapping< traits , typename DstType::traits , void >::is_assignable
1990 ,
"Subview construction requires compatible view and subview arguments" );
1992 Mapping::assign( m_map, src_view.m_map, arg0 , args... );
1998 KOKKOS_INLINE_FUNCTION
1999 int use_count()
const 2000 {
return m_track.use_count(); }
2003 const std::string label()
const 2004 {
return m_track.template get_label< typename traits::memory_space >(); }
2009 template<
class ... P >
2011 View(
const Impl::ViewCtorProp< P ... > & arg_prop
2012 ,
typename std::enable_if< ! Impl::ViewCtorProp< P... >::has_pointer
2013 ,
typename traits::array_layout
2014 >::type
const & arg_layout
2020 typedef Impl::ViewCtorProp< P ... > alloc_prop_input ;
2024 typedef Impl::ViewCtorProp
2026 ,
typename std::conditional
2027 < alloc_prop_input::has_label
2028 , std::integral_constant<unsigned,0>
2029 ,
typename std::string
2031 ,
typename std::conditional
2032 < alloc_prop_input::has_memory_space
2033 , std::integral_constant<unsigned,1>
2034 ,
typename traits::device_type::memory_space
2036 ,
typename std::conditional
2037 < alloc_prop_input::has_execution_space
2038 , std::integral_constant<unsigned,2>
2039 ,
typename traits::device_type::execution_space
2043 static_assert( traits::is_managed
2044 ,
"View allocation constructor requires managed memory" );
2046 if ( alloc_prop::initialize &&
2047 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
2048 ! alloc_prop::execution_space::is_initialized()
2050 ! alloc_prop::execution_space::impl_is_initialized()
2055 Kokkos::Impl::throw_runtime_exception(
"Constructing View and initializing data with uninitialized execution space");
2059 alloc_prop prop( arg_prop );
2062 #if defined( KOKKOS_ENABLE_CUDA ) 2068 if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
2069 traits::device_type::memory_space::execution_space::fence();
2074 Kokkos::Impl::SharedAllocationRecord<> *
2075 record = m_map.allocate_shared( prop , arg_layout );
2078 #if defined( KOKKOS_ENABLE_CUDA ) 2079 if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
2080 traits::device_type::memory_space::execution_space::fence();
2086 m_track.assign_allocated_record_to_uninitialized( record );
2089 KOKKOS_INLINE_FUNCTION
2090 void assign_data( pointer_type arg_data )
2093 m_map.assign_data( arg_data );
2097 template<
class ... P >
2098 explicit KOKKOS_INLINE_FUNCTION
2099 View(
const Impl::ViewCtorProp< P ... > & arg_prop
2100 ,
typename std::enable_if< Impl::ViewCtorProp< P... >::has_pointer
2101 ,
typename traits::array_layout
2102 >::type
const & arg_layout
2105 , m_map( arg_prop , arg_layout )
2108 std::is_same< pointer_type
2109 ,
typename Impl::ViewCtorProp< P... >::pointer_type
2111 "Constructing View to wrap user memory must supply matching pointer type" );
2115 template<
class ... P >
2117 View(
const Impl::ViewCtorProp< P ... > & arg_prop
2118 ,
typename std::enable_if< ! Impl::ViewCtorProp< P... >::has_pointer
2120 >::type
const arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2121 ,
const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2122 ,
const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2123 ,
const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2124 ,
const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2125 ,
const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2126 ,
const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2127 ,
const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2130 , typename traits::array_layout
2131 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2132 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2135 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 2136 Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2137 arg_N4, arg_N5, arg_N6, arg_N7, label());
2139 Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2140 arg_N4, arg_N5, arg_N6, arg_N7);
2146 template<
class ... P >
2147 explicit KOKKOS_INLINE_FUNCTION
2148 View(
const Impl::ViewCtorProp< P ... > & arg_prop
2149 ,
typename std::enable_if< Impl::ViewCtorProp< P... >::has_pointer
2151 >::type
const arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2152 ,
const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2153 ,
const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2154 ,
const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2155 ,
const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2156 ,
const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2157 ,
const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2158 ,
const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2161 , typename traits::array_layout
2162 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2163 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2166 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 2167 Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2168 arg_N4, arg_N5, arg_N6, arg_N7, label());
2170 Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2171 arg_N4, arg_N5, arg_N6, arg_N7);
2178 template<
typename Label >
2180 View(
const Label & arg_label
2181 ,
typename std::enable_if<
2182 Kokkos::Impl::is_view_label<Label>::value ,
2183 typename traits::array_layout >::type
const & arg_layout
2185 : View( Impl::ViewCtorProp< std::string >( arg_label ) , arg_layout )
2189 template<
typename Label >
2191 View(
const Label & arg_label
2192 ,
typename std::enable_if<
2193 Kokkos::Impl::is_view_label<Label>::value ,
2194 const size_t >::type arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2195 ,
const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2196 ,
const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2197 ,
const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2198 ,
const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2199 ,
const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2200 ,
const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2201 ,
const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2203 : View( Impl::ViewCtorProp< std::string >( arg_label )
2204 , typename traits::array_layout
2205 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2206 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2210 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 2211 Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2212 arg_N4, arg_N5, arg_N6, arg_N7, label());
2214 Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2215 arg_N4, arg_N5, arg_N6, arg_N7);
2225 View(
const ViewAllocateWithoutInitializing & arg_prop
2226 ,
const typename traits::array_layout & arg_layout
2228 : View( Impl::ViewCtorProp< std::string ,
Kokkos::Impl::WithoutInitializing_t >( arg_prop.label ,
Kokkos::WithoutInitializing )
2234 View(
const ViewAllocateWithoutInitializing & arg_prop
2235 ,
const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2236 ,
const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2237 ,
const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2238 ,
const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2239 ,
const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2240 ,
const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2241 ,
const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2242 ,
const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2244 : View( Impl::ViewCtorProp< std::string ,
Kokkos::Impl::WithoutInitializing_t >( arg_prop.label ,
Kokkos::WithoutInitializing )
2245 , typename traits::array_layout
2246 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2247 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2250 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 2251 Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2252 arg_N4, arg_N5, arg_N6, arg_N7, label());
2254 Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2255 arg_N4, arg_N5, arg_N6, arg_N7);
2263 static constexpr
size_t required_allocation_size(
2264 const size_t arg_N0 = 0
2265 ,
const size_t arg_N1 = 0
2266 ,
const size_t arg_N2 = 0
2267 ,
const size_t arg_N3 = 0
2268 ,
const size_t arg_N4 = 0
2269 ,
const size_t arg_N5 = 0
2270 ,
const size_t arg_N6 = 0
2271 ,
const size_t arg_N7 = 0
2274 return map_type::memory_span(
2275 typename traits::array_layout
2276 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2277 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
2280 explicit KOKKOS_INLINE_FUNCTION
2281 View( pointer_type arg_ptr
2282 ,
const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2283 ,
const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2284 ,
const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2285 ,
const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2286 ,
const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2287 ,
const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2288 ,
const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2289 ,
const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2291 : View( Impl::ViewCtorProp<pointer_type>(arg_ptr)
2292 , typename traits::array_layout
2293 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2294 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2297 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 2298 Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2299 arg_N4, arg_N5, arg_N6, arg_N7, label());
2301 Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2302 arg_N4, arg_N5, arg_N6, arg_N7);
2307 explicit KOKKOS_INLINE_FUNCTION
2308 View( pointer_type arg_ptr
2309 ,
const typename traits::array_layout & arg_layout
2311 : View( Impl::ViewCtorProp<pointer_type>(arg_ptr) , arg_layout )
2321 shmem_size(
const size_t arg_N0 = KOKKOS_INVALID_INDEX,
2322 const size_t arg_N1 = KOKKOS_INVALID_INDEX,
2323 const size_t arg_N2 = KOKKOS_INVALID_INDEX,
2324 const size_t arg_N3 = KOKKOS_INVALID_INDEX,
2325 const size_t arg_N4 = KOKKOS_INVALID_INDEX,
2326 const size_t arg_N5 = KOKKOS_INVALID_INDEX,
2327 const size_t arg_N6 = KOKKOS_INVALID_INDEX,
2328 const size_t arg_N7 = KOKKOS_INVALID_INDEX )
2330 if ( is_layout_stride ) {
2331 Kokkos::abort(
"Kokkos::View::shmem_size(extents...) doesn't work with LayoutStride. Pass a LayoutStride object instead" );
2333 const size_t num_passed_args = Impl::count_valid_integers(arg_N0, arg_N1, arg_N2, arg_N3,
2334 arg_N4, arg_N5, arg_N6, arg_N7);
2336 if ( std::is_same<typename traits::specialize,void>::value && num_passed_args != traits::rank_dynamic ) {
2337 Kokkos::abort(
"Kokkos::View::shmem_size() rank_dynamic != number of arguments.\n" );
2340 return View::shmem_size(
2341 typename traits::array_layout
2342 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2343 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
2347 size_t shmem_size(
typename traits::array_layout
const& arg_layout )
2349 return map_type::memory_span( arg_layout );
2352 explicit KOKKOS_INLINE_FUNCTION
2353 View(
const typename traits::execution_space::scratch_memory_space & arg_space
2354 ,
const typename traits::array_layout & arg_layout )
2355 : View( Impl::ViewCtorProp<pointer_type>(
2356 reinterpret_cast<pointer_type>(
2357 arg_space.get_shmem( map_type::memory_span( arg_layout ) ) ) )
2361 explicit KOKKOS_INLINE_FUNCTION
2362 View(
const typename traits::execution_space::scratch_memory_space & arg_space
2363 ,
const size_t arg_N0 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2364 ,
const size_t arg_N1 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2365 ,
const size_t arg_N2 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2366 ,
const size_t arg_N3 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2367 ,
const size_t arg_N4 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2368 ,
const size_t arg_N5 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2369 ,
const size_t arg_N6 = KOKKOS_IMPL_CTOR_DEFAULT_ARG
2370 ,
const size_t arg_N7 = KOKKOS_IMPL_CTOR_DEFAULT_ARG )
2371 : View( Impl::ViewCtorProp<pointer_type>(
2372 reinterpret_cast<pointer_type>(
2373 arg_space.get_shmem(
2374 map_type::memory_span(
2375 typename traits::array_layout
2376 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2377 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) ) ) ) )
2378 , typename traits::array_layout
2379 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
2380 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
2384 #ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 2385 Impl::runtime_check_rank_host(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2386 arg_N4, arg_N5, arg_N6, arg_N7, label());
2388 Impl::runtime_check_rank_device(traits::rank_dynamic, std::is_same<typename traits::specialize,void>::value, arg_N0, arg_N1, arg_N2, arg_N3,
2389 arg_N4, arg_N5, arg_N6, arg_N7);
2400 template <
typename D ,
class ... P >
2401 KOKKOS_INLINE_FUNCTION
2407 template<
class V ,
class ... Args >
2409 typename Kokkos::Impl::ViewMapping
2411 ,
typename V::traits
2415 template<
class D,
class ... P ,
class ... Args >
2416 KOKKOS_INLINE_FUNCTION
2417 typename Kokkos::Impl::ViewMapping
2419 , ViewTraits< D , P... >
2422 subview(
const View< D, P... > & src , Args ... args )
2424 static_assert( View< D , P... >::Rank ==
sizeof...(Args) ,
2425 "subview requires one argument for each source View rank" );
2428 Kokkos::Impl::ViewMapping
2430 , ViewTraits< D , P ... >
2431 , Args ... >::type( src , args ... );
2434 template<
class MemoryTraits ,
class D,
class ... P ,
class ... Args >
2435 KOKKOS_INLINE_FUNCTION
2436 typename Kokkos::Impl::ViewMapping
2438 , ViewTraits< D , P... >
2440 >::template apply< MemoryTraits >::type
2441 subview(
const View< D, P... > & src , Args ... args )
2443 static_assert( View< D , P... >::Rank ==
sizeof...(Args) ,
2444 "subview requires one argument for each source View rank" );
2447 Kokkos::Impl::ViewMapping
2449 , ViewTraits< D , P ... >
2451 ::template apply< MemoryTraits >
2452 ::type( src , args ... );
2462 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
2463 KOKKOS_INLINE_FUNCTION
2465 const View<RT,RP...> & rhs )
2468 typedef ViewTraits<LT,LP...> lhs_traits ;
2469 typedef ViewTraits<RT,RP...> rhs_traits ;
2472 std::is_same<
typename lhs_traits::const_value_type ,
2473 typename rhs_traits::const_value_type >::value &&
2474 std::is_same<
typename lhs_traits::array_layout ,
2475 typename rhs_traits::array_layout >::value &&
2476 std::is_same<
typename lhs_traits::memory_space ,
2477 typename rhs_traits::memory_space >::value &&
2478 unsigned(lhs_traits::rank) == unsigned(rhs_traits::rank) &&
2479 lhs.data() == rhs.data() &&
2480 lhs.span() == rhs.span() &&
2481 lhs.extent(0) == rhs.extent(0) &&
2482 lhs.extent(1) == rhs.extent(1) &&
2483 lhs.extent(2) == rhs.extent(2) &&
2484 lhs.extent(3) == rhs.extent(3) &&
2485 lhs.extent(4) == rhs.extent(4) &&
2486 lhs.extent(5) == rhs.extent(5) &&
2487 lhs.extent(6) == rhs.extent(6) &&
2488 lhs.extent(7) == rhs.extent(7);
2491 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
2492 KOKKOS_INLINE_FUNCTION
2494 const View<RT,RP...> & rhs )
2508 void shared_allocation_tracking_disable()
2509 { Kokkos::Impl::SharedAllocationRecord<void,void>::tracking_disable(); }
2512 void shared_allocation_tracking_enable()
2513 { Kokkos::Impl::SharedAllocationRecord<void,void>::tracking_enable(); }
2521 namespace Kokkos {
namespace Impl {
2523 template <
class Specialize,
typename A,
typename B >
2524 struct CommonViewValueType;
2526 template <
typename A,
typename B >
2527 struct CommonViewValueType< void, A, B >
2529 using value_type =
typename std::common_type< A , B >::type;
2533 template <
class Specialize,
class ValueType >
2534 struct CommonViewAllocProp;
2536 template <
class ValueType >
2537 struct CommonViewAllocProp< void, ValueType >
2539 using value_type = ValueType;
2540 using scalar_array_type = ValueType;
2542 template <
class ... Views >
2543 KOKKOS_INLINE_FUNCTION
2544 CommonViewAllocProp(
const Views & ... ) {}
2548 template <
class ... Views >
2549 struct DeduceCommonViewAllocProp;
2553 template <
class FirstView >
2554 struct DeduceCommonViewAllocProp< FirstView >
2556 using specialize =
typename FirstView::traits::specialize;
2558 using value_type =
typename FirstView::traits::value_type;
2560 enum :
bool { is_view = is_view< FirstView >::value };
2562 using prop_type = CommonViewAllocProp< specialize, value_type >;
2566 template <
class FirstView,
class ... NextViews >
2567 struct DeduceCommonViewAllocProp< FirstView, NextViews... >
2569 using NextTraits = DeduceCommonViewAllocProp< NextViews... >;
2571 using first_specialize =
typename FirstView::traits::specialize;
2572 using first_value_type =
typename FirstView::traits::value_type;
2574 enum :
bool { first_is_view = is_view< FirstView >::value };
2576 using next_specialize =
typename NextTraits::specialize;
2577 using next_value_type =
typename NextTraits::value_type;
2579 enum :
bool { next_is_view = NextTraits::is_view };
2585 static_assert( !(!std::is_same< first_specialize, next_specialize >::value && !std::is_same< first_specialize, void>::value && !std::is_same< void, next_specialize >::value) ,
"Kokkos DeduceCommonViewAllocProp ERROR: Only one non-void specialize trait allowed" );
2588 using specialize =
typename std::conditional< std::is_same< first_specialize, next_specialize >::value
2590 ,
typename std::conditional< ( std::is_same< first_specialize, void >::value
2591 && !std::is_same< next_specialize, void >::value)
2597 using value_type =
typename CommonViewValueType< specialize, first_value_type, next_value_type >::value_type;
2599 enum :
bool { is_view = (first_is_view && next_is_view) };
2601 using prop_type = CommonViewAllocProp< specialize, value_type >;
2606 template <
class ... Views >
2607 using DeducedCommonPropsType =
typename Impl::DeduceCommonViewAllocProp<Views...>::prop_type ;
2610 template <
class ... Views >
2611 KOKKOS_INLINE_FUNCTION
2612 DeducedCommonPropsType<Views...>
2613 common_view_alloc_prop( Views
const & ... views )
2615 return DeducedCommonPropsType<Views...>( views... );
2624 using Kokkos::is_view ;
2629 #include <impl/Kokkos_ViewUniformType.hpp> 2630 #include <impl/Kokkos_Atomic_View.hpp> KOKKOS_INLINE_FUNCTION bool operator==(const complex< RealType1 > &x, const complex< RealType2 > &y)
Equality operator for two complex numbers.
KOKKOS_INLINE_FUNCTION bool operator!=(const complex< RealType1 > &x, const complex< RealType2 > &y)
Inequality operator for two complex numbers.
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
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.
Memory layout tag indicated arbitrarily strided multi-index mapping into contiguous memory...
View to an array of data.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::host_mirror_space > host_mirror_type
Compatible HostMirror view.
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > non_const_type
Compatible view of non-const data type.
Impl::ViewUniformType< View, 0 >::type uniform_type
Unified types.
Impl::ViewCtorProp< typename Impl::ViewCtorProp< void, Args >::type ... > view_alloc(Args const &... args)
Create View allocation parameter bundle from argument list.
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::host_mirror_space > HostMirror
Compatible HostMirror view.
Traits class for accessing attributes of a View.
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< std::is_integral< iType >::value, size_t >::type extent(const iType &r) const
rank() to be implemented
View< typename traits::const_data_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > const_type
Compatible view of const data type.