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> 64 template<
class DataType >
65 struct ViewArrayAnalysis ;
67 template<
class DataType ,
class ArrayLayout
68 ,
typename ValueType =
69 typename ViewArrayAnalysis< DataType >::non_const_value_type
71 struct ViewDataAnalysis ;
73 template< class ,
class ... >
74 class ViewMapping {
public:
enum { is_assignable =
false }; };
83 using Kokkos::Experimental::Impl::ViewMapping ;
84 using Kokkos::Experimental::Impl::ViewDataAnalysis ;
111 template<
class DataType ,
class ... Properties >
117 typedef void execution_space ;
118 typedef void memory_space ;
119 typedef void HostMirrorSpace ;
120 typedef void array_layout ;
121 typedef void memory_traits ;
124 template<
class ... Prop >
128 typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
129 typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
130 typedef typename ViewTraits<void,Prop...>::HostMirrorSpace HostMirrorSpace ;
131 typedef typename ViewTraits<void,Prop...>::array_layout array_layout ;
132 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
135 template<
class ArrayLayout ,
class ... Prop >
136 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_array_layout<ArrayLayout>::value >::type , ArrayLayout , Prop ... >
140 typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
141 typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
142 typedef typename ViewTraits<void,Prop...>::HostMirrorSpace HostMirrorSpace ;
143 typedef ArrayLayout array_layout ;
144 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
147 template<
class Space ,
class ... Prop >
148 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_space<Space>::value >::type , Space , Prop ... >
152 static_assert( std::is_same<
typename ViewTraits<void,Prop...>::execution_space ,
void >::value &&
153 std::is_same<
typename ViewTraits<void,Prop...>::memory_space ,
void >::value &&
154 std::is_same<
typename ViewTraits<void,Prop...>::HostMirrorSpace ,
void >::value &&
155 std::is_same<
typename ViewTraits<void,Prop...>::array_layout ,
void >::value
156 ,
"Only one View Execution or Memory Space template argument" );
158 typedef typename Space::execution_space execution_space ;
159 typedef typename Space::memory_space memory_space ;
160 typedef typename Kokkos::Impl::HostMirror< Space >::Space HostMirrorSpace ;
161 typedef typename execution_space::array_layout array_layout ;
162 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
165 template<
class MemoryTraits ,
class ... Prop >
166 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_memory_traits<MemoryTraits>::value >::type , MemoryTraits , Prop ... >
170 static_assert( std::is_same<
typename ViewTraits<void,Prop...>::execution_space ,
void >::value &&
171 std::is_same<
typename ViewTraits<void,Prop...>::memory_space ,
void >::value &&
172 std::is_same<
typename ViewTraits<void,Prop...>::array_layout ,
void >::value &&
173 std::is_same<
typename ViewTraits<void,Prop...>::memory_traits ,
void >::value
174 ,
"MemoryTrait is the final optional template argument for a View" );
176 typedef void execution_space ;
177 typedef void memory_space ;
178 typedef void HostMirrorSpace ;
179 typedef void array_layout ;
180 typedef MemoryTraits memory_traits ;
184 template<
class DataType ,
class ... Properties >
189 typedef ViewTraits< void , Properties ... > prop ;
192 std::conditional< ! std::is_same< typename prop::execution_space , void >::value
193 ,
typename prop::execution_space
194 , Kokkos::DefaultExecutionSpace
199 std::conditional< ! std::is_same< typename prop::memory_space , void >::value
200 ,
typename prop::memory_space
201 ,
typename ExecutionSpace::memory_space
206 std::conditional< ! std::is_same< typename prop::array_layout , void >::value
207 ,
typename prop::array_layout
208 ,
typename ExecutionSpace::array_layout
214 < ! std::is_same< typename prop::HostMirrorSpace , void >::value
215 ,
typename prop::HostMirrorSpace
216 ,
typename Kokkos::Impl::HostMirror< ExecutionSpace >::Space
221 std::conditional< ! std::is_same< typename prop::memory_traits , void >::value
222 ,
typename prop::memory_traits
223 ,
typename Kokkos::MemoryManaged
229 typedef Kokkos::Impl::ViewDataAnalysis< DataType , ArrayLayout > data_analysis ;
236 typedef typename data_analysis::type data_type ;
237 typedef typename data_analysis::const_type const_data_type ;
238 typedef typename data_analysis::non_const_type non_const_data_type ;
243 typedef typename data_analysis::scalar_array_type scalar_array_type ;
244 typedef typename data_analysis::const_scalar_array_type const_scalar_array_type ;
245 typedef typename data_analysis::non_const_scalar_array_type non_const_scalar_array_type ;
250 typedef typename data_analysis::value_type value_type ;
251 typedef typename data_analysis::const_value_type const_value_type ;
252 typedef typename data_analysis::non_const_value_type non_const_value_type ;
257 typedef ArrayLayout array_layout ;
258 typedef typename data_analysis::dimension dimension ;
259 typedef typename data_analysis::specialize specialize ;
261 enum { rank = dimension::rank };
262 enum { rank_dynamic = dimension::rank_dynamic };
267 typedef ExecutionSpace execution_space ;
268 typedef MemorySpace memory_space ;
270 typedef MemoryTraits memory_traits ;
271 typedef HostMirrorSpace host_mirror_space ;
273 typedef typename MemorySpace::size_type size_type ;
275 enum { is_hostspace = std::is_same< MemorySpace , HostSpace >::value };
276 enum { is_managed = MemoryTraits::Unmanaged == 0 };
277 enum { is_random_access = MemoryTraits::RandomAccess == 1 };
364 template<
class DataType ,
class ... Properties >
372 #include <impl/Kokkos_ViewMapping.hpp> 373 #include <impl/Kokkos_ViewArray.hpp> 382 constexpr Kokkos::Impl::ALL_t
383 ALL = Kokkos::Impl::ALL_t();
385 constexpr Kokkos::Impl::WithoutInitializing_t
386 WithoutInitializing = Kokkos::Impl::WithoutInitializing_t();
388 constexpr Kokkos::Impl::AllowPadding_t
389 AllowPadding = Kokkos::Impl::AllowPadding_t();
402 template<
class ... Args >
404 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
408 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
411 static_assert( ! return_type::has_pointer
412 ,
"Cannot give pointer-to-memory for view allocation" );
414 return return_type( args... );
417 template<
class ... Args >
419 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
420 view_wrap( Args
const & ... args )
423 Impl::ViewCtorProp< typename Impl::ViewCtorProp< void , Args >::type ... >
426 static_assert( ! return_type::has_memory_space &&
427 ! return_type::has_execution_space &&
428 ! return_type::has_label &&
429 return_type::has_pointer
430 ,
"Must only give pointer-to-memory for view wrapping" );
432 return return_type( args... );
442 template<
class DataType ,
class ... Properties >
445 template<
class >
struct is_view :
public std::false_type {};
447 template<
class D,
class ... P >
448 struct is_view< View<D,P...> > :
public std::true_type {};
450 template<
class D,
class ... P >
451 struct is_view< const View<D,P...> > :
public std::true_type {};
453 template<
class DataType ,
class ... Properties >
454 class View :
public ViewTraits< DataType , Properties ... > {
457 template< class ,
class ... >
friend class View ;
458 template< class ,
class ... >
friend class Kokkos::Impl::ViewMapping ;
462 typedef ViewTraits< DataType , Properties ... > traits ;
466 typedef Kokkos::Impl::ViewMapping< traits , void > map_type ;
467 typedef Kokkos::Impl::SharedAllocationTracker track_type ;
476 typedef View<
typename traits::scalar_array_type ,
477 typename traits::array_layout ,
478 typename traits::device_type ,
479 typename traits::memory_traits >
483 typedef View<
typename traits::const_data_type ,
484 typename traits::array_layout ,
486 typename traits::memory_traits >
490 typedef View<
typename traits::non_const_data_type ,
491 typename traits::array_layout ,
493 typename traits::memory_traits >
497 typedef View<
typename traits::non_const_data_type ,
498 typename traits::array_layout ,
499 typename traits::host_mirror_space >
505 enum { Rank = map_type::Rank };
513 template<
typename iType >
514 KOKKOS_INLINE_FUNCTION constexpr
515 typename std::enable_if< std::is_integral<iType>::value ,
size_t >::type
517 {
return m_map.extent(r); }
519 template<
typename iType >
520 KOKKOS_INLINE_FUNCTION constexpr
521 typename std::enable_if< std::is_integral<iType>::value ,
int >::type
522 extent_int(
const iType & r )
const 523 {
return static_cast<int>(m_map.extent(r)); }
525 KOKKOS_INLINE_FUNCTION constexpr
526 typename traits::array_layout layout()
const 527 {
return m_map.layout(); }
534 template<
typename iType >
535 KOKKOS_INLINE_FUNCTION constexpr
536 typename std::enable_if< std::is_integral<iType>::value ,
size_t >::type
537 dimension(
const iType & r )
const {
return extent( r ); }
539 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_0()
const {
return m_map.dimension_0(); }
540 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_1()
const {
return m_map.dimension_1(); }
541 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_2()
const {
return m_map.dimension_2(); }
542 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_3()
const {
return m_map.dimension_3(); }
543 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_4()
const {
return m_map.dimension_4(); }
544 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_5()
const {
return m_map.dimension_5(); }
545 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_6()
const {
return m_map.dimension_6(); }
546 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_7()
const {
return m_map.dimension_7(); }
550 KOKKOS_INLINE_FUNCTION constexpr
size_t size()
const {
return m_map.dimension_0() *
551 m_map.dimension_1() *
552 m_map.dimension_2() *
553 m_map.dimension_3() *
554 m_map.dimension_4() *
555 m_map.dimension_5() *
556 m_map.dimension_6() *
557 m_map.dimension_7(); }
559 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_0()
const {
return m_map.stride_0(); }
560 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_1()
const {
return m_map.stride_1(); }
561 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_2()
const {
return m_map.stride_2(); }
562 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_3()
const {
return m_map.stride_3(); }
563 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_4()
const {
return m_map.stride_4(); }
564 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_5()
const {
return m_map.stride_5(); }
565 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_6()
const {
return m_map.stride_6(); }
566 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_7()
const {
return m_map.stride_7(); }
568 template<
typename iType >
569 KOKKOS_INLINE_FUNCTION
void stride( iType *
const s )
const { m_map.stride(s); }
574 typedef typename map_type::reference_type reference_type ;
575 typedef typename map_type::pointer_type pointer_type ;
577 enum { reference_type_is_lvalue_reference = std::is_lvalue_reference< reference_type >::value };
579 KOKKOS_INLINE_FUNCTION constexpr
size_t span()
const {
return m_map.span(); }
581 KOKKOS_INLINE_FUNCTION constexpr
size_t capacity()
const {
return m_map.span(); }
582 KOKKOS_INLINE_FUNCTION constexpr
bool span_is_contiguous()
const {
return m_map.span_is_contiguous(); }
583 KOKKOS_INLINE_FUNCTION constexpr pointer_type data()
const {
return m_map.data(); }
586 KOKKOS_INLINE_FUNCTION constexpr
bool is_contiguous()
const {
return m_map.span_is_contiguous(); }
588 KOKKOS_INLINE_FUNCTION constexpr pointer_type ptr_on_device()
const {
return m_map.data(); }
593 KOKKOS_INLINE_FUNCTION
594 const Kokkos::Impl::ViewMapping< traits , void > &
595 implementation_map()
const {
return m_map ; }
602 is_layout_left = std::is_same<
typename traits::array_layout
605 is_layout_right = std::is_same<
typename traits::array_layout
608 is_layout_stride = std::is_same<
typename traits::array_layout
612 std::is_same< typename traits::specialize , void >::value &&
613 ( is_layout_left || is_layout_right || is_layout_stride )
616 #if defined( KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK ) 618 #define KOKKOS_VIEW_OPERATOR_VERIFY( ARG ) \ 619 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace \ 620 < Kokkos::Impl::ActiveExecutionMemorySpace , typename traits::memory_space >::verify(); \ 621 Kokkos::Impl::view_verify_operator_bounds ARG ; 625 #define KOKKOS_VIEW_OPERATOR_VERIFY( ARG ) \ 626 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace \ 627 < Kokkos::Impl::ActiveExecutionMemorySpace , typename traits::memory_space >::verify(); 636 template<
class ... Args >
637 KOKKOS_FORCEINLINE_FUNCTION
638 typename std::enable_if<( Kokkos::Impl::are_integral<Args...>::value
640 ), reference_type >::type
641 operator()( Args ... args )
const 643 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 644 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,args...) )
646 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,args...) )
649 return m_map.reference();
655 template<
typename I0
657 KOKKOS_FORCEINLINE_FUNCTION
658 typename std::enable_if<
659 ( Kokkos::Impl::are_integral<I0,Args...>::value
662 ), reference_type >::type
663 operator()(
const I0 & i0
664 , Args ... args )
const 666 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 667 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,args...) )
669 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,args...) )
672 return m_map.reference(i0);
675 template<
typename I0
677 KOKKOS_FORCEINLINE_FUNCTION
678 typename std::enable_if<
679 ( Kokkos::Impl::are_integral<I0,Args...>::value
682 && ! is_layout_stride
683 ), reference_type >::type
684 operator()(
const I0 & i0
685 , Args ... args )
const 688 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 689 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,args...) )
691 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,args...) )
694 return m_map.m_handle[ i0 ];
697 template<
typename I0
699 KOKKOS_FORCEINLINE_FUNCTION
700 typename std::enable_if<
701 ( Kokkos::Impl::are_integral<I0,Args...>::value
705 ), reference_type >::type
706 operator()(
const I0 & i0
707 , Args ... args )
const 709 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 710 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,args...) )
712 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,args...) )
715 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
721 template<
typename I0 >
722 KOKKOS_FORCEINLINE_FUNCTION
723 typename std::enable_if<
724 ( Kokkos::Impl::are_integral<I0>::value
727 ), reference_type >::type
728 operator[](
const I0 & i0 )
const 730 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 731 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0) )
733 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0) )
736 return m_map.reference(i0);
739 template<
typename I0 >
740 KOKKOS_FORCEINLINE_FUNCTION
741 typename std::enable_if<
742 ( Kokkos::Impl::are_integral<I0>::value
745 && ! is_layout_stride
746 ), reference_type >::type
747 operator[](
const I0 & i0 )
const 749 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 750 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0) )
752 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0) )
755 return m_map.m_handle[ i0 ];
758 template<
typename I0 >
759 KOKKOS_FORCEINLINE_FUNCTION
760 typename std::enable_if<
761 ( Kokkos::Impl::are_integral<I0>::value
765 ), reference_type >::type
766 operator[](
const I0 & i0 )
const 768 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 769 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0) )
771 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0) )
774 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
780 template<
typename I0 ,
typename I1
782 KOKKOS_FORCEINLINE_FUNCTION
783 typename std::enable_if<
784 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
787 ), reference_type >::type
788 operator()(
const I0 & i0 ,
const I1 & i1
789 , Args ... args )
const 791 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 792 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,args...) )
794 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,args...) )
797 return m_map.reference(i0,i1);
800 template<
typename I0 ,
typename I1
802 KOKKOS_FORCEINLINE_FUNCTION
803 typename std::enable_if<
804 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
807 && is_layout_left && ( traits::rank_dynamic == 0 )
808 ), reference_type >::type
809 operator()(
const I0 & i0 ,
const I1 & i1
810 , Args ... args )
const 812 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 813 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,args...) )
815 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,args...) )
818 return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
821 template<
typename I0 ,
typename I1
823 KOKKOS_FORCEINLINE_FUNCTION
824 typename std::enable_if<
825 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
828 && is_layout_left && ( traits::rank_dynamic != 0 )
829 ), reference_type >::type
830 operator()(
const I0 & i0 ,
const I1 & i1
831 , Args ... args )
const 833 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 834 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,args...) )
836 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,args...) )
839 return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
842 template<
typename I0 ,
typename I1
844 KOKKOS_FORCEINLINE_FUNCTION
845 typename std::enable_if<
846 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
849 && is_layout_right && ( traits::rank_dynamic == 0 )
850 ), reference_type >::type
851 operator()(
const I0 & i0 ,
const I1 & i1
852 , Args ... args )
const 854 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 855 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,args...) )
857 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,args...) )
860 return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
863 template<
typename I0 ,
typename I1
865 KOKKOS_FORCEINLINE_FUNCTION
866 typename std::enable_if<
867 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
870 && is_layout_right && ( traits::rank_dynamic != 0 )
871 ), reference_type >::type
872 operator()(
const I0 & i0 ,
const I1 & i1
873 , Args ... args )
const 875 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 876 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,args...) )
878 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,args...) )
881 return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
884 template<
typename I0 ,
typename I1
886 KOKKOS_FORCEINLINE_FUNCTION
887 typename std::enable_if<
888 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
892 ), reference_type >::type
893 operator()(
const I0 & i0 ,
const I1 & i1
894 , Args ... args )
const 896 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 897 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,args...) )
899 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,args...) )
902 return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
903 i1 * m_map.m_offset.m_stride.S1 ];
909 template<
typename I0 ,
typename I1 ,
typename I2
911 KOKKOS_FORCEINLINE_FUNCTION
912 typename std::enable_if<
913 ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
916 ), reference_type >::type
917 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2
918 , Args ... args )
const 920 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 921 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,args...) )
923 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,args...) )
926 return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
929 template<
typename I0 ,
typename I1 ,
typename I2
931 KOKKOS_FORCEINLINE_FUNCTION
932 typename std::enable_if<
933 ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
936 ), reference_type >::type
937 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2
938 , Args ... args )
const 940 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 941 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,args...) )
943 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,args...) )
946 return m_map.reference(i0,i1,i2);
952 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
954 KOKKOS_FORCEINLINE_FUNCTION
955 typename std::enable_if<
956 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
959 ), reference_type >::type
960 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
961 , Args ... args )
const 963 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 964 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,args...) )
966 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,args...) )
969 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
972 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
974 KOKKOS_FORCEINLINE_FUNCTION
975 typename std::enable_if<
976 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
979 ), reference_type >::type
980 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
981 , Args ... args )
const 983 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 984 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,args...) )
986 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,args...) )
989 return m_map.reference(i0,i1,i2,i3);
995 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
998 KOKKOS_FORCEINLINE_FUNCTION
999 typename std::enable_if<
1000 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1003 ), reference_type >::type
1004 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1006 , Args ... args )
const 1008 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 1009 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,i4,args...) )
1011 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,i4,args...) )
1014 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
1017 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1020 KOKKOS_FORCEINLINE_FUNCTION
1021 typename std::enable_if<
1022 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
1025 ), reference_type >::type
1026 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1028 , Args ... args )
const 1030 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 1031 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,i4,args...) )
1033 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,i4,args...) )
1036 return m_map.reference(i0,i1,i2,i3,i4);
1042 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1043 ,
typename I4 ,
typename I5
1045 KOKKOS_FORCEINLINE_FUNCTION
1046 typename std::enable_if<
1047 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1050 ), reference_type >::type
1051 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1052 ,
const I4 & i4 ,
const I5 & i5
1053 , Args ... args )
const 1055 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 1056 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,i4,i5,args...) )
1058 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,i4,i5,args...) )
1061 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
1064 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1065 ,
typename I4 ,
typename I5
1067 KOKKOS_FORCEINLINE_FUNCTION
1068 typename std::enable_if<
1069 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
1072 ), reference_type >::type
1073 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1074 ,
const I4 & i4 ,
const I5 & i5
1075 , Args ... args )
const 1077 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 1078 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,i4,i5,args...) )
1080 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,i4,i5,args...) )
1083 return m_map.reference(i0,i1,i2,i3,i4,i5);
1089 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1090 ,
typename I4 ,
typename I5 ,
typename I6
1092 KOKKOS_FORCEINLINE_FUNCTION
1093 typename std::enable_if<
1094 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1097 ), reference_type >::type
1098 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1099 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6
1100 , Args ... args )
const 1102 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 1103 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1105 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1108 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
1111 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1112 ,
typename I4 ,
typename I5 ,
typename I6
1114 KOKKOS_FORCEINLINE_FUNCTION
1115 typename std::enable_if<
1116 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
1119 ), reference_type >::type
1120 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1121 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6
1122 , Args ... args )
const 1124 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 1125 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
1127 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),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 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 1150 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1152 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1155 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1158 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1159 ,
typename I4 ,
typename I5 ,
typename I6 ,
typename I7
1161 KOKKOS_FORCEINLINE_FUNCTION
1162 typename std::enable_if<
1163 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1166 ), reference_type >::type
1167 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1168 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 ,
const I7 & i7
1169 , Args ... args )
const 1171 #ifndef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST 1172 KOKKOS_VIEW_OPERATOR_VERIFY( (NULL,m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1174 KOKKOS_VIEW_OPERATOR_VERIFY( (m_track.template get_label<typename traits::memory_space>().c_str(),m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1177 return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1180 #undef KOKKOS_VIEW_OPERATOR_VERIFY 1185 KOKKOS_INLINE_FUNCTION
1188 KOKKOS_INLINE_FUNCTION
1189 View() : m_track(), m_map() {}
1191 KOKKOS_INLINE_FUNCTION
1192 View(
const View & rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ) {}
1194 KOKKOS_INLINE_FUNCTION
1195 View( View && rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ) {}
1197 KOKKOS_INLINE_FUNCTION
1198 View & operator = (
const View & rhs ) { m_track = rhs.m_track ; m_map = rhs.m_map ;
return *this ; }
1200 KOKKOS_INLINE_FUNCTION
1201 View & operator = ( View && rhs ) { m_track = rhs.m_track ; m_map = rhs.m_map ;
return *this ; }
1207 template<
class RT ,
class ... RP >
1208 KOKKOS_INLINE_FUNCTION
1209 View(
const View<RT,RP...> & rhs )
1210 : m_track( rhs.m_track , traits::is_managed )
1213 typedef typename View<RT,RP...>::traits SrcTraits ;
1214 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1215 static_assert( Mapping::is_assignable ,
"Incompatible View copy construction" );
1216 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1219 template<
class RT ,
class ... RP >
1220 KOKKOS_INLINE_FUNCTION
1221 View & operator = (
const View<RT,RP...> & rhs )
1223 typedef typename View<RT,RP...>::traits SrcTraits ;
1224 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1225 static_assert( Mapping::is_assignable ,
"Incompatible View copy assignment" );
1226 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1227 m_track.assign( rhs.m_track , traits::is_managed );
1235 template<
class RT ,
class ... RP ,
class Arg0 ,
class ... Args >
1236 KOKKOS_INLINE_FUNCTION
1237 View(
const View< RT , RP... > & src_view
1238 ,
const Arg0 & arg0 , Args ... args )
1239 : m_track( src_view.m_track , traits::is_managed )
1242 typedef View< RT , RP... > SrcType ;
1244 typedef Kokkos::Impl::ViewMapping
1246 ,
typename SrcType::traits
1247 , Arg0 , Args... > Mapping ;
1249 typedef typename Mapping::type DstType ;
1251 static_assert( Kokkos::Impl::ViewMapping< traits , typename DstType::traits , void >::is_assignable
1252 ,
"Subview construction requires compatible view and subview arguments" );
1254 Mapping::assign( m_map, src_view.m_map, arg0 , args... );
1260 KOKKOS_INLINE_FUNCTION
1261 int use_count()
const 1262 {
return m_track.use_count(); }
1265 const std::string label()
const 1266 {
return m_track.template get_label< typename traits::memory_space >(); }
1271 template<
class ... P >
1273 View(
const Impl::ViewCtorProp< P ... > & arg_prop
1274 ,
typename std::enable_if< ! Impl::ViewCtorProp< P... >::has_pointer
1275 ,
typename traits::array_layout
1276 >::type
const & arg_layout
1282 typedef Impl::ViewCtorProp< P ... > alloc_prop_input ;
1286 typedef Impl::ViewCtorProp
1288 ,
typename std::conditional
1289 < alloc_prop_input::has_label
1290 , std::integral_constant<unsigned,0>
1291 ,
typename std::string
1293 ,
typename std::conditional
1294 < alloc_prop_input::has_memory_space
1295 , std::integral_constant<unsigned,1>
1296 ,
typename traits::device_type::memory_space
1298 ,
typename std::conditional
1299 < alloc_prop_input::has_execution_space
1300 , std::integral_constant<unsigned,2>
1301 ,
typename traits::device_type::execution_space
1305 static_assert( traits::is_managed
1306 ,
"View allocation constructor requires managed memory" );
1308 if ( alloc_prop::initialize &&
1309 ! alloc_prop::execution_space::is_initialized() ) {
1312 Kokkos::Impl::throw_runtime_exception(
"Constructing View and initializing data with uninitialized execution space");
1316 alloc_prop prop( arg_prop );
1319 #if defined( KOKKOS_HAVE_CUDA ) 1325 if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
1326 traits::device_type::memory_space::execution_space::fence();
1331 Kokkos::Impl::SharedAllocationRecord<> *
1332 record = m_map.allocate_shared( prop , arg_layout );
1335 #if defined( KOKKOS_HAVE_CUDA ) 1336 if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
1337 traits::device_type::memory_space::execution_space::fence();
1343 m_track.assign_allocated_record_to_uninitialized( record );
1347 template<
class ... P >
1348 explicit KOKKOS_INLINE_FUNCTION
1349 View(
const Impl::ViewCtorProp< P ... > & arg_prop
1350 ,
typename std::enable_if< Impl::ViewCtorProp< P... >::has_pointer
1351 ,
typename traits::array_layout
1352 >::type
const & arg_layout
1355 , m_map( arg_prop , arg_layout )
1358 std::is_same< pointer_type
1359 ,
typename Impl::ViewCtorProp< P... >::pointer_type
1361 "Constructing View to wrap user memory must supply matching pointer type" );
1365 template<
class ... P >
1367 View(
const Impl::ViewCtorProp< P ... > & arg_prop
1368 ,
typename std::enable_if< ! Impl::ViewCtorProp< P... >::has_pointer
1370 >::type
const arg_N0 = 0
1371 ,
const size_t arg_N1 = 0
1372 ,
const size_t arg_N2 = 0
1373 ,
const size_t arg_N3 = 0
1374 ,
const size_t arg_N4 = 0
1375 ,
const size_t arg_N5 = 0
1376 ,
const size_t arg_N6 = 0
1377 ,
const size_t arg_N7 = 0
1380 , typename traits::array_layout
1381 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1382 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1386 template<
class ... P >
1387 explicit KOKKOS_INLINE_FUNCTION
1388 View(
const Impl::ViewCtorProp< P ... > & arg_prop
1389 ,
typename std::enable_if< Impl::ViewCtorProp< P... >::has_pointer
1391 >::type
const arg_N0 = 0
1392 ,
const size_t arg_N1 = 0
1393 ,
const size_t arg_N2 = 0
1394 ,
const size_t arg_N3 = 0
1395 ,
const size_t arg_N4 = 0
1396 ,
const size_t arg_N5 = 0
1397 ,
const size_t arg_N6 = 0
1398 ,
const size_t arg_N7 = 0
1401 , typename traits::array_layout
1402 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1403 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1408 template<
typename Label >
1410 View(
const Label & arg_label
1411 ,
typename std::enable_if<
1412 Kokkos::Impl::is_view_label<Label>::value ,
1413 typename traits::array_layout >::type
const & arg_layout
1415 : View( Impl::ViewCtorProp< std::string >( arg_label ) , arg_layout )
1419 template<
typename Label >
1421 View(
const Label & arg_label
1422 ,
typename std::enable_if<
1423 Kokkos::Impl::is_view_label<Label>::value ,
1424 const size_t >::type arg_N0 = 0
1425 ,
const size_t arg_N1 = 0
1426 ,
const size_t arg_N2 = 0
1427 ,
const size_t arg_N3 = 0
1428 ,
const size_t arg_N4 = 0
1429 ,
const size_t arg_N5 = 0
1430 ,
const size_t arg_N6 = 0
1431 ,
const size_t arg_N7 = 0
1433 : View( Impl::ViewCtorProp< std::string >( arg_label )
1434 , typename traits::array_layout
1435 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1436 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1442 View(
const ViewAllocateWithoutInitializing & arg_prop
1443 ,
const typename traits::array_layout & arg_layout
1445 : View( Impl::ViewCtorProp< std::string ,
Kokkos::Impl::WithoutInitializing_t >( arg_prop.label ,
Kokkos::WithoutInitializing )
1451 View(
const ViewAllocateWithoutInitializing & arg_prop
1452 ,
const size_t arg_N0 = 0
1453 ,
const size_t arg_N1 = 0
1454 ,
const size_t arg_N2 = 0
1455 ,
const size_t arg_N3 = 0
1456 ,
const size_t arg_N4 = 0
1457 ,
const size_t arg_N5 = 0
1458 ,
const size_t arg_N6 = 0
1459 ,
const size_t arg_N7 = 0
1461 : View( Impl::ViewCtorProp< std::string ,
Kokkos::Impl::WithoutInitializing_t >( arg_prop.label ,
Kokkos::WithoutInitializing )
1462 , typename traits::array_layout
1463 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1464 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1470 static constexpr
size_t required_allocation_size(
1471 const size_t arg_N0 = 0
1472 ,
const size_t arg_N1 = 0
1473 ,
const size_t arg_N2 = 0
1474 ,
const size_t arg_N3 = 0
1475 ,
const size_t arg_N4 = 0
1476 ,
const size_t arg_N5 = 0
1477 ,
const size_t arg_N6 = 0
1478 ,
const size_t arg_N7 = 0
1481 return map_type::memory_span(
1482 typename traits::array_layout
1483 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1484 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
1487 explicit KOKKOS_INLINE_FUNCTION
1488 View( pointer_type arg_ptr
1489 ,
const size_t arg_N0 = 0
1490 ,
const size_t arg_N1 = 0
1491 ,
const size_t arg_N2 = 0
1492 ,
const size_t arg_N3 = 0
1493 ,
const size_t arg_N4 = 0
1494 ,
const size_t arg_N5 = 0
1495 ,
const size_t arg_N6 = 0
1496 ,
const size_t arg_N7 = 0
1498 : View( Impl::ViewCtorProp<pointer_type>(arg_ptr)
1499 , typename traits::array_layout
1500 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1501 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1505 explicit KOKKOS_INLINE_FUNCTION
1506 View( pointer_type arg_ptr
1507 ,
const typename traits::array_layout & arg_layout
1509 : View( Impl::ViewCtorProp<pointer_type>(arg_ptr) , arg_layout )
1516 size_t shmem_size(
const size_t arg_N0 = ~
size_t(0) ,
1517 const size_t arg_N1 = ~
size_t(0) ,
1518 const size_t arg_N2 = ~
size_t(0) ,
1519 const size_t arg_N3 = ~
size_t(0) ,
1520 const size_t arg_N4 = ~
size_t(0) ,
1521 const size_t arg_N5 = ~
size_t(0) ,
1522 const size_t arg_N6 = ~
size_t(0) ,
1523 const size_t arg_N7 = ~
size_t(0) )
1525 const size_t num_passed_args =
1526 ( arg_N0 != ~size_t(0) ) + ( arg_N1 != ~
size_t(0) ) + ( arg_N2 != ~
size_t(0) ) +
1527 ( arg_N3 != ~
size_t(0) ) + ( arg_N4 != ~
size_t(0) ) + ( arg_N5 != ~
size_t(0) ) +
1528 ( arg_N6 != ~
size_t(0) ) + ( arg_N7 != ~
size_t(0) );
1530 if ( std::is_same<typename traits::specialize,void>::value && num_passed_args != traits::rank_dynamic ) {
1531 Kokkos::abort(
"Kokkos::View::shmem_size() rank_dynamic != number of arguments.\n" );
1534 return map_type::memory_span(
1535 typename traits::array_layout
1536 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1537 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
1540 explicit KOKKOS_INLINE_FUNCTION
1541 View(
const typename traits::execution_space::scratch_memory_space & arg_space
1542 ,
const typename traits::array_layout & arg_layout )
1543 : View( Impl::ViewCtorProp<pointer_type>(
1544 reinterpret_cast<pointer_type>(
1545 arg_space.get_shmem( map_type::memory_span( arg_layout ) ) ) )
1549 explicit KOKKOS_INLINE_FUNCTION
1550 View(
const typename traits::execution_space::scratch_memory_space & arg_space
1551 ,
const size_t arg_N0 = 0
1552 ,
const size_t arg_N1 = 0
1553 ,
const size_t arg_N2 = 0
1554 ,
const size_t arg_N3 = 0
1555 ,
const size_t arg_N4 = 0
1556 ,
const size_t arg_N5 = 0
1557 ,
const size_t arg_N6 = 0
1558 ,
const size_t arg_N7 = 0 )
1559 : View( Impl::ViewCtorProp<pointer_type>(
1560 reinterpret_cast<pointer_type>(
1561 arg_space.get_shmem(
1562 map_type::memory_span(
1563 typename traits::array_layout
1564 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1565 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) ) ) ) )
1566 , typename traits::array_layout
1567 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1568 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1578 template <
typename D ,
class ... P >
1579 KOKKOS_INLINE_FUNCTION
1585 template<
class V ,
class ... Args >
1587 typename Kokkos::Impl::ViewMapping
1589 ,
typename V::traits
1593 template<
class D,
class ... P ,
class ... Args >
1594 KOKKOS_INLINE_FUNCTION
1595 typename Kokkos::Impl::ViewMapping
1597 , ViewTraits< D , P... >
1600 subview(
const View< D, P... > & src , Args ... args )
1602 static_assert( View< D , P... >::Rank ==
sizeof...(Args) ,
1603 "subview requires one argument for each source View rank" );
1606 Kokkos::Impl::ViewMapping
1608 , ViewTraits< D , P ... >
1609 , Args ... >::type( src , args ... );
1612 template<
class MemoryTraits ,
class D,
class ... P ,
class ... Args >
1613 KOKKOS_INLINE_FUNCTION
1614 typename Kokkos::Impl::ViewMapping
1616 , ViewTraits< D , P... >
1618 >::template apply< MemoryTraits >::type
1619 subview(
const View< D, P... > & src , Args ... args )
1621 static_assert( View< D , P... >::Rank ==
sizeof...(Args) ,
1622 "subview requires one argument for each source View rank" );
1625 Kokkos::Impl::ViewMapping
1627 , ViewTraits< D , P ... >
1629 ::template apply< MemoryTraits >
1630 ::type( src , args ... );
1640 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
1641 KOKKOS_INLINE_FUNCTION
1643 const View<RT,RP...> & rhs )
1646 typedef ViewTraits<LT,LP...> lhs_traits ;
1647 typedef ViewTraits<RT,RP...> rhs_traits ;
1650 std::is_same<
typename lhs_traits::const_value_type ,
1651 typename rhs_traits::const_value_type >::value &&
1652 std::is_same<
typename lhs_traits::array_layout ,
1653 typename rhs_traits::array_layout >::value &&
1654 std::is_same<
typename lhs_traits::memory_space ,
1655 typename rhs_traits::memory_space >::value &&
1656 unsigned(lhs_traits::rank) == unsigned(rhs_traits::rank) &&
1657 lhs.data() == rhs.data() &&
1658 lhs.span() == rhs.span() &&
1659 lhs.dimension_0() == rhs.dimension_0() &&
1660 lhs.dimension_1() == rhs.dimension_1() &&
1661 lhs.dimension_2() == rhs.dimension_2() &&
1662 lhs.dimension_3() == rhs.dimension_3() &&
1663 lhs.dimension_4() == rhs.dimension_4() &&
1664 lhs.dimension_5() == rhs.dimension_5() &&
1665 lhs.dimension_6() == rhs.dimension_6() &&
1666 lhs.dimension_7() == rhs.dimension_7();
1669 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
1670 KOKKOS_INLINE_FUNCTION
1672 const View<RT,RP...> & rhs )
1686 void shared_allocation_tracking_claim_and_disable()
1687 { Kokkos::Impl::SharedAllocationRecord<void,void>::tracking_claim_and_disable(); }
1690 void shared_allocation_tracking_release_and_enable()
1691 { Kokkos::Impl::SharedAllocationRecord<void,void>::tracking_release_and_enable(); }
1702 template<
class OutputView ,
typename Enable =
void >
1705 typedef typename OutputView::const_value_type const_value_type ;
1707 const OutputView output ;
1708 const_value_type input ;
1710 KOKKOS_INLINE_FUNCTION
1711 void operator()(
const size_t i0 )
const 1713 const size_t n1 = output.dimension_1();
1714 const size_t n2 = output.dimension_2();
1715 const size_t n3 = output.dimension_3();
1716 const size_t n4 = output.dimension_4();
1717 const size_t n5 = output.dimension_5();
1718 const size_t n6 = output.dimension_6();
1719 const size_t n7 = output.dimension_7();
1721 for (
size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1722 for (
size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1723 for (
size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1724 for (
size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1725 for (
size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1726 for (
size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1727 for (
size_t i7 = 0 ; i7 < n7 ; ++i7 ) {
1728 output(i0,i1,i2,i3,i4,i5,i6,i7) = input ;
1732 ViewFill(
const OutputView & arg_out , const_value_type & arg_in )
1733 : output( arg_out ), input( arg_in )
1735 typedef typename OutputView::execution_space execution_space ;
1742 execution_space::fence();
1746 template<
class OutputView >
1747 struct ViewFill< OutputView , typename std::enable_if< OutputView::Rank == 0 >::type > {
1748 ViewFill(
const OutputView & dst ,
const typename OutputView::const_value_type & src )
1750 Kokkos::Impl::DeepCopy< typename OutputView::memory_space , Kokkos::HostSpace >
1751 ( dst.data() , & src ,
sizeof(
typename OutputView::const_value_type) );
1755 template<
class OutputView ,
class InputView ,
class ExecSpace =
typename OutputView::execution_space >
1758 const OutputView output ;
1759 const InputView input ;
1769 ViewRemap(
const OutputView & arg_out ,
const InputView & arg_in )
1770 : output( arg_out ), input( arg_in )
1771 , n0( std::min( (size_t)arg_out.dimension_0() , (size_t)arg_in.dimension_0() ) )
1772 , n1( std::min( (size_t)arg_out.dimension_1() , (size_t)arg_in.dimension_1() ) )
1773 , n2( std::min( (size_t)arg_out.dimension_2() , (size_t)arg_in.dimension_2() ) )
1774 , n3( std::min( (size_t)arg_out.dimension_3() , (size_t)arg_in.dimension_3() ) )
1775 , n4( std::min( (size_t)arg_out.dimension_4() , (size_t)arg_in.dimension_4() ) )
1776 , n5( std::min( (size_t)arg_out.dimension_5() , (size_t)arg_in.dimension_5() ) )
1777 , n6( std::min( (size_t)arg_out.dimension_6() , (size_t)arg_in.dimension_6() ) )
1778 , n7( std::min( (size_t)arg_out.dimension_7() , (size_t)arg_in.dimension_7() ) )
1785 KOKKOS_INLINE_FUNCTION
1786 void operator()(
const size_t i0 )
const 1788 for (
size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1789 for (
size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1790 for (
size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1791 for (
size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1792 for (
size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1793 for (
size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1794 for (
size_t i7 = 0 ; i7 < n7 ; ++i7 ) {
1795 output(i0,i1,i2,i3,i4,i5,i6,i7) = input(i0,i1,i2,i3,i4,i5,i6,i7);
1809 template<
class DT ,
class ... DP >
1813 ,
typename ViewTraits<DT,DP...>::const_value_type & value
1814 ,
typename std::enable_if<
1815 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value
1819 std::is_same<
typename ViewTraits<DT,DP...>::non_const_value_type ,
1820 typename ViewTraits<DT,DP...>::value_type >::value
1821 ,
"deep_copy requires non-const type" );
1823 Kokkos::Impl::ViewFill<
View<DT,DP...> >( dst , value );
1827 template<
class ST ,
class ... SP >
1830 (
typename ViewTraits<ST,SP...>::non_const_value_type & dst
1832 ,
typename std::enable_if<
1833 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value
1837 ,
"ERROR: Non-rank-zero view in deep_copy( value , View )" );
1840 typedef typename src_traits::memory_space src_memory_space ;
1841 Kokkos::Impl::DeepCopy< HostSpace , src_memory_space >( & dst , src.data() ,
sizeof(ST) );
1846 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
1851 ,
typename std::enable_if<(
1852 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
1853 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
1859 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1860 typename ViewTraits<ST,SP...>::non_const_value_type >::value
1861 ,
"deep_copy requires matching non-const destination type" );
1863 typedef View<DT,DP...> dst_type ;
1864 typedef View<ST,SP...> src_type ;
1866 typedef typename dst_type::value_type value_type ;
1867 typedef typename dst_type::memory_space dst_memory_space ;
1868 typedef typename src_type::memory_space src_memory_space ;
1870 if ( dst.data() != src.data() ) {
1871 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() ,
sizeof(value_type) );
1879 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
1884 ,
typename std::enable_if<(
1885 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
1886 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
1892 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1893 typename ViewTraits<DT,DP...>::non_const_value_type >::value
1894 ,
"deep_copy requires non-const destination type" );
1899 ,
"deep_copy requires Views of equal rank" );
1901 typedef View<DT,DP...> dst_type ;
1902 typedef View<ST,SP...> src_type ;
1904 typedef typename dst_type::execution_space dst_execution_space ;
1905 typedef typename src_type::execution_space src_execution_space ;
1906 typedef typename dst_type::memory_space dst_memory_space ;
1907 typedef typename src_type::memory_space src_memory_space ;
1909 enum { DstExecCanAccessSrc =
1910 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace< typename dst_execution_space::memory_space , src_memory_space >::value };
1912 enum { SrcExecCanAccessDst =
1913 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace< typename src_execution_space::memory_space , dst_memory_space >::value };
1916 if ( (
void *) dst.data() != (
void*) src.data() ) {
1923 if ( std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1924 typename ViewTraits<ST,SP...>::non_const_value_type >::value &&
1926 ( std::is_same<
typename ViewTraits<DT,DP...>::array_layout ,
1927 typename ViewTraits<ST,SP...>::array_layout >::value
1929 ( std::is_same<
typename ViewTraits<DT,DP...>::array_layout ,
1932 std::is_same<
typename ViewTraits<DT,DP...>::array_layout ,
1940 dst.span_is_contiguous() &&
1941 src.span_is_contiguous() &&
1942 dst.span() == src.span() &&
1943 dst.dimension_0() == src.dimension_0() &&
1944 dst.dimension_1() == src.dimension_1() &&
1945 dst.dimension_2() == src.dimension_2() &&
1946 dst.dimension_3() == src.dimension_3() &&
1947 dst.dimension_4() == src.dimension_4() &&
1948 dst.dimension_5() == src.dimension_5() &&
1949 dst.dimension_6() == src.dimension_6() &&
1950 dst.dimension_7() == src.dimension_7() ) {
1952 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1954 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
1956 else if ( std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1957 typename ViewTraits<ST,SP...>::non_const_value_type >::value &&
1959 ( std::is_same<
typename ViewTraits<DT,DP...>::array_layout ,
1960 typename ViewTraits<ST,SP...>::array_layout >::value
1962 std::is_same<
typename ViewTraits<DT,DP...>::array_layout ,
1969 dst.span_is_contiguous() &&
1970 src.span_is_contiguous() &&
1971 dst.span() == src.span() &&
1972 dst.dimension_0() == src.dimension_0() &&
1973 dst.dimension_1() == src.dimension_1() &&
1974 dst.dimension_2() == src.dimension_2() &&
1975 dst.dimension_3() == src.dimension_3() &&
1976 dst.dimension_4() == src.dimension_4() &&
1977 dst.dimension_5() == src.dimension_5() &&
1978 dst.dimension_6() == src.dimension_6() &&
1979 dst.dimension_7() == src.dimension_7() &&
1980 dst.stride_0() == src.stride_0() &&
1981 dst.stride_1() == src.stride_1() &&
1982 dst.stride_2() == src.stride_2() &&
1983 dst.stride_3() == src.stride_3() &&
1984 dst.stride_4() == src.stride_4() &&
1985 dst.stride_5() == src.stride_5() &&
1986 dst.stride_6() == src.stride_6() &&
1987 dst.stride_7() == src.stride_7()
1990 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1992 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
1994 else if ( DstExecCanAccessSrc ) {
1996 Kokkos::Impl::ViewRemap< dst_type , src_type >( dst , src );
1998 else if ( SrcExecCanAccessDst ) {
2000 Kokkos::Impl::ViewRemap< dst_type , src_type , src_execution_space >( dst , src );
2003 Kokkos::Impl::throw_runtime_exception(
"deep_copy given views that would require a temporary allocation");
2016 template<
class ExecSpace ,
class DT ,
class ... DP >
2021 ,
typename ViewTraits<DT,DP...>::const_value_type & value
2022 ,
typename std::enable_if<
2023 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
2024 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value
2028 std::is_same<
typename ViewTraits<DT,DP...>::non_const_value_type ,
2029 typename ViewTraits<DT,DP...>::value_type >::value
2030 ,
"deep_copy requires non-const type" );
2032 Kokkos::Impl::ViewFill<
View<DT,DP...> >( dst , value );
2036 template<
class ExecSpace ,
class ST ,
class ... SP >
2039 (
const ExecSpace & exec_space
2040 ,
typename ViewTraits<ST,SP...>::non_const_value_type & dst
2042 ,
typename std::enable_if<
2043 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
2044 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value
2048 ,
"ERROR: Non-rank-zero view in deep_copy( value , View )" );
2051 typedef typename src_traits::memory_space src_memory_space ;
2052 Kokkos::Impl::DeepCopy< HostSpace , src_memory_space , ExecSpace >
2053 ( exec_space , & dst , src.data() ,
sizeof(ST) );
2058 template<
class ExecSpace ,
class DT ,
class ... DP ,
class ST ,
class ... SP >
2061 (
const ExecSpace & exec_space
2064 ,
typename std::enable_if<(
2065 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
2066 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
2067 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
2073 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
2074 typename ViewTraits<ST,SP...>::non_const_value_type >::value
2075 ,
"deep_copy requires matching non-const destination type" );
2077 typedef View<DT,DP...> dst_type ;
2078 typedef View<ST,SP...> src_type ;
2080 typedef typename dst_type::value_type value_type ;
2081 typedef typename dst_type::memory_space dst_memory_space ;
2082 typedef typename src_type::memory_space src_memory_space ;
2084 if ( dst.data() != src.data() ) {
2085 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space , ExecSpace >
2086 ( exec_space , dst.data() , src.data() ,
sizeof(value_type) );
2094 template<
class ExecSpace ,
class DT,
class ... DP,
class ST,
class ... SP >
2097 (
const ExecSpace & exec_space
2100 ,
typename std::enable_if<(
2101 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
2102 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
2103 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
2109 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
2110 typename ViewTraits<DT,DP...>::non_const_value_type >::value
2111 ,
"deep_copy requires non-const destination type" );
2116 ,
"deep_copy requires Views of equal rank" );
2118 typedef View<DT,DP...> dst_type ;
2119 typedef View<ST,SP...> src_type ;
2121 typedef typename dst_type::execution_space dst_execution_space ;
2122 typedef typename src_type::execution_space src_execution_space ;
2123 typedef typename dst_type::memory_space dst_memory_space ;
2124 typedef typename src_type::memory_space src_memory_space ;
2126 enum { DstExecCanAccessSrc =
2127 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace< typename dst_execution_space::memory_space , src_memory_space >::value };
2129 enum { SrcExecCanAccessDst =
2130 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace< typename src_execution_space::memory_space , dst_memory_space >::value };
2132 if ( (
void *) dst.data() != (
void*) src.data() ) {
2139 if ( std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
2140 typename ViewTraits<ST,SP...>::non_const_value_type >::value &&
2142 std::is_same<
typename ViewTraits<DT,DP...>::array_layout ,
2143 typename ViewTraits<ST,SP...>::array_layout >::value
2148 dst.span_is_contiguous() &&
2149 src.span_is_contiguous() &&
2150 dst.span() == src.span() &&
2151 dst.dimension_0() == src.dimension_0() &&
2152 dst.dimension_1() == src.dimension_1() &&
2153 dst.dimension_2() == src.dimension_2() &&
2154 dst.dimension_3() == src.dimension_3() &&
2155 dst.dimension_4() == src.dimension_4() &&
2156 dst.dimension_5() == src.dimension_5() &&
2157 dst.dimension_6() == src.dimension_6() &&
2158 dst.dimension_7() == src.dimension_7() ) {
2160 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
2162 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space , ExecSpace >
2163 ( exec_space , dst.data() , src.data() , nbytes );
2165 else if ( DstExecCanAccessSrc ) {
2167 Kokkos::Impl::ViewRemap< dst_type , src_type >( dst , src );
2169 else if ( SrcExecCanAccessDst ) {
2171 Kokkos::Impl::ViewRemap< dst_type , src_type , src_execution_space >( dst , src );
2174 Kokkos::Impl::throw_runtime_exception(
"deep_copy given views that would require a temporary allocation");
2188 template<
class Space,
class T,
class ... P>
2189 struct MirrorViewType {
2193 typedef typename Space::memory_space memory_space;
2195 enum { is_same_memspace = std::is_same<memory_space,typename src_view_type::memory_space>::value };
2197 typedef typename src_view_type::array_layout array_layout;
2199 typedef typename src_view_type::non_const_data_type data_type;
2204 typedef typename std::conditional<is_same_memspace,src_view_type,dest_view_type>::type view_type;
2207 template<
class Space,
class T,
class ... P>
2212 typedef typename Space::memory_space memory_space;
2214 enum { is_same_memspace = std::is_same<memory_space,typename src_view_type::memory_space>::value };
2216 typedef typename src_view_type::array_layout array_layout;
2218 typedef typename src_view_type::non_const_data_type data_type;
2225 template<
class T ,
class ... P >
2229 ,
typename std::enable_if<
2230 ! std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
2235 typedef View<T,P...> src_type ;
2236 typedef typename src_type::HostMirror dst_type ;
2238 return dst_type( std::string( src.label() ).append(
"_mirror")
2246 , src.dimension_7() );
2249 template<
class T ,
class ... P >
2253 ,
typename std::enable_if<
2254 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
2259 typedef View<T,P...> src_type ;
2260 typedef typename src_type::HostMirror dst_type ;
2264 layout.dimension[0] = src.dimension_0();
2265 layout.dimension[1] = src.dimension_1();
2266 layout.dimension[2] = src.dimension_2();
2267 layout.dimension[3] = src.dimension_3();
2268 layout.dimension[4] = src.dimension_4();
2269 layout.dimension[5] = src.dimension_5();
2270 layout.dimension[6] = src.dimension_6();
2271 layout.dimension[7] = src.dimension_7();
2273 layout.stride[0] = src.stride_0();
2274 layout.stride[1] = src.stride_1();
2275 layout.stride[2] = src.stride_2();
2276 layout.stride[3] = src.stride_3();
2277 layout.stride[4] = src.stride_4();
2278 layout.stride[5] = src.stride_5();
2279 layout.stride[6] = src.stride_6();
2280 layout.stride[7] = src.stride_7();
2282 return dst_type( std::string( src.label() ).append(
"_mirror") , layout );
2287 template<
class Space,
class T,
class ... P>
2288 typename Impl::MirrorType<Space,T,P ...>::view_type create_mirror(
const Space& ,
const Kokkos::View<T,P...> & src) {
2289 return typename Impl::MirrorType<Space,T,P ...>::view_type(src.label(),src.layout());
2292 template<
class T ,
class ... P >
2296 ,
typename std::enable_if<(
2297 std::is_same<
typename Kokkos::View<T,P...>::memory_space
2298 ,
typename Kokkos::View<T,P...>::HostMirror::memory_space
2301 std::is_same<
typename Kokkos::View<T,P...>::data_type
2302 ,
typename Kokkos::View<T,P...>::HostMirror::data_type
2310 template<
class T ,
class ... P >
2314 ,
typename std::enable_if< ! (
2315 std::is_same<
typename Kokkos::View<T,P...>::memory_space
2316 ,
typename Kokkos::View<T,P...>::HostMirror::memory_space
2319 std::is_same<
typename Kokkos::View<T,P...>::data_type
2320 ,
typename Kokkos::View<T,P...>::HostMirror::data_type
2325 return Kokkos::create_mirror( src );
2329 template<
class Space,
class T,
class ... P>
2330 typename Impl::MirrorViewType<Space,T,P ...>::view_type
2332 ,
typename std::enable_if<Impl::MirrorViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
2337 template<
class Space,
class T,
class ... P>
2338 typename Impl::MirrorViewType<Space,T,P ...>::view_type
2340 ,
typename std::enable_if<!Impl::MirrorViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
2341 return typename Impl::MirrorViewType<Space,T,P ...>::view_type(src.label(),src.layout());
2352 template<
class T ,
class ... P >
2354 typename std::enable_if<
2359 const size_t n0 = 0 ,
2360 const size_t n1 = 0 ,
2361 const size_t n2 = 0 ,
2362 const size_t n3 = 0 ,
2363 const size_t n4 = 0 ,
2364 const size_t n5 = 0 ,
2365 const size_t n6 = 0 ,
2366 const size_t n7 = 0 )
2372 view_type v_resized( v.label(), n0, n1, n2, n3, n4, n5, n6, n7 );
2374 Kokkos::Impl::ViewRemap< view_type , view_type >( v_resized , v );
2380 template<
class T ,
class ... P >
2383 const typename Kokkos::View<T,P...>::array_layout & layout)
2389 view_type v_resized( v.label(), layout );
2391 Kokkos::Impl::ViewRemap< view_type , view_type >( v_resized , v );
2397 template<
class T ,
class ... P >
2399 typename std::enable_if<
2404 const size_t n0 = 0 ,
2405 const size_t n1 = 0 ,
2406 const size_t n2 = 0 ,
2407 const size_t n3 = 0 ,
2408 const size_t n4 = 0 ,
2409 const size_t n5 = 0 ,
2410 const size_t n6 = 0 ,
2411 const size_t n7 = 0 )
2417 const std::string label = v.label();
2420 v = view_type( label, n0, n1, n2, n3, n4, n5, n6, n7 );
2424 template<
class T ,
class ... P >
2427 const typename Kokkos::View<T,P...>::array_layout & layout)
2433 const std::string label = v.label();
2436 v = view_type( label, layout );
2449 using Kokkos::Subview ;
2450 using Kokkos::is_view ;
2451 using Kokkos::subview ;
2453 using Kokkos::WithoutInitializing ;
2454 using Kokkos::AllowPadding ;
2456 using Kokkos::view_wrap ;
2458 using Kokkos::create_mirror ;
2459 using Kokkos::create_mirror_view ;
2465 using Kokkos::Impl::ViewFill ;
2466 using Kokkos::Impl::ViewRemap ;
2467 using Kokkos::Impl::ViewCtorProp ;
2468 using Kokkos::Impl::is_view_label ;
2469 using Kokkos::Impl::WithoutInitializing_t ;
2470 using Kokkos::Impl::AllowPadding_t ;
2471 using Kokkos::Impl::SharedAllocationRecord ;
2472 using Kokkos::Impl::SharedAllocationTracker ;
2481 using Kokkos::is_view ;
2483 template<
class SrcViewType
2493 struct ViewSubview ;
2498 #include <impl/Kokkos_Atomic_View.hpp>
std::enable_if< std::is_same< typename Kokkos::View< T, P... >::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::View< T, P... >::array_layout, Kokkos::LayoutRight >::value >::type resize(Kokkos::View< T, P... > &v, const size_t n0=0, const size_t n1=0, const size_t n2=0, const size_t n3=0, const size_t n4=0, const size_t n5=0, const size_t n6=0, const size_t n7=0)
Resize a view with copying old data to new data at the corresponding indices.
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
std::enable_if< std::is_same< typename Kokkos::View< T, P... >::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::View< T, P... >::array_layout, Kokkos::LayoutRight >::value >::type realloc(Kokkos::View< T, P... > &v, const size_t n0=0, const size_t n1=0, const size_t n2=0, const size_t n3=0, const size_t n4=0, const size_t n5=0, const size_t n6=0, const size_t n7=0)
Resize a view with discarding old data.
KOKKOS_INLINE_FUNCTION bool operator!=(const complex< RealType > &x, const complex< RealType > &y)
Inequality operator for two complex numbers.
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 space for main process and CPU execution spaces.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
Implementation of the ParallelFor operator that has a partial specialization for the device...
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::ViewCtorProp< typename Impl::ViewCtorProp< void, Args >::type ... > view_alloc(Args const &... args)
Create View allocation parameter bundle from argument list.
KOKKOS_INLINE_FUNCTION bool operator==(const complex< RealType > &x, const complex< RealType > &y)
Equality operator for two complex numbers.
void deep_copy(const View< DT, DP... > &dst, typename ViewTraits< DT, DP... >::const_value_type &value, typename std::enable_if< std::is_same< typename ViewTraits< DT, DP... >::specialize, void >::value >::type *=0)
Deep copy a value from Host memory into a view.
Execution policy for work over a range of an integral type.
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
KOKKOS_INLINE_FUNCTION constexpr unsigned rank(const View< D, P... > &V)
Temporary free function rank() until rank() is implemented in the View.
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.