44 #ifndef KOKKOS_EXPERIMENTAL_VIEW_HPP 45 #define KOKKOS_EXPERIMENTAL_VIEW_HPP 49 #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 DstMemorySpace ,
class SrcMemorySpace >
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 }; };
79 template<
class MemorySpace >
80 struct ViewOperatorBoundsErrorAbort ;
83 struct ViewOperatorBoundsErrorAbort<
Kokkos::HostSpace > {
84 static void apply(
const size_t rank
85 ,
const size_t n0 ,
const size_t n1
86 ,
const size_t n2 ,
const size_t n3
87 ,
const size_t n4 ,
const size_t n5
88 ,
const size_t n6 ,
const size_t n7
89 ,
const size_t i0 ,
const size_t i1
90 ,
const size_t i2 ,
const size_t i3
91 ,
const size_t i4 ,
const size_t i5
92 ,
const size_t i6 ,
const size_t i7 );
122 template<
class DataType ,
class ... Properties >
128 typedef void execution_space ;
129 typedef void memory_space ;
130 typedef void array_layout ;
131 typedef void memory_traits ;
134 template<
class ... Prop >
138 typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
139 typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
140 typedef typename ViewTraits<void,Prop...>::array_layout array_layout ;
141 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
144 template<
class ArrayLayout ,
class ... Prop >
145 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_array_layout<ArrayLayout>::value >::type , ArrayLayout , Prop ... >
149 typedef typename ViewTraits<void,Prop...>::execution_space execution_space ;
150 typedef typename ViewTraits<void,Prop...>::memory_space memory_space ;
151 typedef ArrayLayout array_layout ;
152 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
155 template<
class Space ,
class ... Prop >
156 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_space<Space>::value >::type , Space , Prop ... >
160 static_assert( std::is_same<
typename ViewTraits<void,Prop...>::execution_space ,
void >::value ||
161 std::is_same<
typename ViewTraits<void,Prop...>::memory_space ,
void >::value ||
162 std::is_same<
typename ViewTraits<void,Prop...>::array_layout ,
void >::value
163 ,
"Only one View Execution or Memory Space template argument" );
165 typedef typename Space::execution_space execution_space ;
166 typedef typename Space::memory_space memory_space ;
167 typedef typename execution_space::array_layout array_layout ;
168 typedef typename ViewTraits<void,Prop...>::memory_traits memory_traits ;
171 template<
class MemoryTraits ,
class ... Prop >
172 struct ViewTraits< typename std::enable_if< Kokkos::Impl::is_memory_traits<MemoryTraits>::value >::type , MemoryTraits , Prop ... >
176 static_assert( std::is_same<
typename ViewTraits<void,Prop...>::execution_space ,
void >::value ||
177 std::is_same<
typename ViewTraits<void,Prop...>::memory_space ,
void >::value ||
178 std::is_same<
typename ViewTraits<void,Prop...>::array_layout ,
void >::value ||
179 std::is_same<
typename ViewTraits<void,Prop...>::memory_traits ,
void >::value
180 ,
"MemoryTrait is the final optional template argument for a View" );
182 typedef void execution_space ;
183 typedef void memory_space ;
184 typedef void array_layout ;
185 typedef MemoryTraits memory_traits ;
189 template<
class DataType ,
class ... Properties >
197 std::conditional< ! std::is_same< typename prop::execution_space , void >::value
198 ,
typename prop::execution_space
199 , Kokkos::DefaultExecutionSpace
204 std::conditional< ! std::is_same< typename prop::memory_space , void >::value
205 ,
typename prop::memory_space
206 ,
typename ExecutionSpace::memory_space
211 std::conditional< ! std::is_same< typename prop::array_layout , void >::value
212 ,
typename prop::array_layout
213 ,
typename ExecutionSpace::array_layout
217 typedef typename Kokkos::Impl::is_space< ExecutionSpace >::host_mirror_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::Experimental::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::array_scalar_type array_scalar_type ;
244 typedef typename data_analysis::const_array_scalar_type const_array_scalar_type ;
245 typedef typename data_analysis::non_const_array_scalar_type non_const_array_scalar_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 >
373 #include <impl/KokkosExp_ViewMapping.hpp> 374 #include <impl/KokkosExp_ViewAllocProp.hpp> 375 #include <impl/KokkosExp_ViewArray.hpp> 385 constexpr Kokkos::Experimental::Impl::ALL_t
386 ALL = Kokkos::Experimental::Impl::ALL_t();
388 constexpr Kokkos::Experimental::Impl::WithoutInitializing_t
389 WithoutInitializing = Kokkos::Experimental::Impl::WithoutInitializing_t();
391 constexpr Kokkos::Experimental::Impl::AllowPadding_t
392 AllowPadding = Kokkos::Experimental::Impl::AllowPadding_t();
405 template<
class ... Args >
407 Kokkos::Experimental::Impl::ViewAllocProp< Args ... >
408 view_alloc( Args ... args )
410 return Kokkos::Experimental::Impl::ViewAllocProp< Args ... >( args ... );
422 template<
class DataType ,
class ... Properties >
425 template<
class >
struct is_view :
public std::false_type {};
427 template<
class D,
class ... P >
428 struct is_view<
View<D,P...> > :
public std::true_type {};
430 template<
class DataType ,
class ... Properties >
434 template< class ,
class ... >
friend class View ;
435 template< class ,
class ... >
friend class Impl::ViewMapping ;
438 typedef Kokkos::Experimental::Impl::ViewMapping< traits , void > map_type ;
439 typedef Kokkos::Experimental::Impl::SharedAllocationTracker track_type ;
448 typedef View<
typename traits::array_scalar_type ,
449 typename traits::array_layout ,
451 typename traits::memory_traits >
455 typedef View<
typename traits::const_data_type ,
456 typename traits::array_layout ,
457 typename traits::device_type ,
458 typename traits::memory_traits >
462 typedef View<
typename traits::non_const_data_type ,
463 typename traits::array_layout ,
464 typename traits::device_type ,
465 typename traits::memory_traits >
469 typedef View<
typename traits::non_const_data_type ,
470 typename traits::array_layout ,
471 typename traits::host_mirror_space >
477 enum { Rank = map_type::Rank };
479 template<
typename iType >
480 KOKKOS_INLINE_FUNCTION constexpr
481 typename std::enable_if< std::is_integral<iType>::value ,
size_t >::type
482 extent(
const iType & r )
const 483 {
return m_map.extent(r); }
485 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_0()
const {
return m_map.dimension_0(); }
486 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_1()
const {
return m_map.dimension_1(); }
487 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_2()
const {
return m_map.dimension_2(); }
488 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_3()
const {
return m_map.dimension_3(); }
489 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_4()
const {
return m_map.dimension_4(); }
490 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_5()
const {
return m_map.dimension_5(); }
491 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_6()
const {
return m_map.dimension_6(); }
492 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_7()
const {
return m_map.dimension_7(); }
494 KOKKOS_INLINE_FUNCTION constexpr
size_t size()
const {
return m_map.dimension_0() *
495 m_map.dimension_1() *
496 m_map.dimension_2() *
497 m_map.dimension_3() *
498 m_map.dimension_4() *
499 m_map.dimension_5() *
500 m_map.dimension_6() *
501 m_map.dimension_7(); }
503 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_0()
const {
return m_map.stride_0(); }
504 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_1()
const {
return m_map.stride_1(); }
505 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_2()
const {
return m_map.stride_2(); }
506 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_3()
const {
return m_map.stride_3(); }
507 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_4()
const {
return m_map.stride_4(); }
508 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_5()
const {
return m_map.stride_5(); }
509 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_6()
const {
return m_map.stride_6(); }
510 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_7()
const {
return m_map.stride_7(); }
512 template<
typename iType >
513 KOKKOS_INLINE_FUNCTION
void stride( iType *
const s )
const { m_map.stride(s); }
518 typedef typename map_type::reference_type reference_type ;
519 typedef typename map_type::pointer_type pointer_type ;
521 enum { reference_type_is_lvalue_reference = std::is_lvalue_reference< reference_type >::value };
523 KOKKOS_INLINE_FUNCTION constexpr
size_t span()
const {
return m_map.span(); }
525 KOKKOS_INLINE_FUNCTION constexpr
size_t capacity()
const {
return m_map.span(); }
526 KOKKOS_INLINE_FUNCTION constexpr
bool span_is_contiguous()
const {
return m_map.span_is_contiguous(); }
527 KOKKOS_INLINE_FUNCTION constexpr pointer_type data()
const {
return m_map.data(); }
530 KOKKOS_INLINE_FUNCTION constexpr
bool is_contiguous()
const {
return m_map.span_is_contiguous(); }
532 KOKKOS_INLINE_FUNCTION constexpr pointer_type ptr_on_device()
const {
return m_map.data(); }
537 KOKKOS_INLINE_FUNCTION
538 const map_type & implementation_map()
const {
return m_map ; }
545 is_layout_left = std::is_same<
typename traits::array_layout
548 is_layout_right = std::is_same<
typename traits::array_layout
551 is_layout_stride = std::is_same<
typename traits::array_layout
555 std::is_same< typename traits::specialize , void >::value &&
556 ( is_layout_left || is_layout_right || is_layout_stride )
559 #if defined( KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK ) 561 #define KOKKOS_VIEW_OPERATOR_VERIFY( ARG ) \ 562 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace \ 563 < Kokkos::Impl::ActiveExecutionMemorySpace , typename traits::memory_space >::verify(); \ 564 Kokkos::Experimental::Impl::view_verify_operator_bounds ARG ; 568 #define KOKKOS_VIEW_OPERATOR_VERIFY( ARG ) \ 569 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace \ 570 < Kokkos::Impl::ActiveExecutionMemorySpace , typename traits::memory_space >::verify(); 579 template<
class ... Args >
580 KOKKOS_FORCEINLINE_FUNCTION
581 typename std::enable_if<( Kokkos::Impl::are_integral<Args...>::value
583 ), reference_type >::type
584 operator()( Args ... args )
const 586 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,args...) )
588 return m_map.reference();
594 template<
typename I0
596 KOKKOS_FORCEINLINE_FUNCTION
597 typename std::enable_if<
598 ( Kokkos::Impl::are_integral<I0,Args...>::value
601 ), reference_type >::type
602 operator()(
const I0 & i0
603 , Args ... args )
const 605 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,args...) )
607 return m_map.reference(i0);
610 template<
typename I0
612 KOKKOS_FORCEINLINE_FUNCTION
613 typename std::enable_if<
614 ( Kokkos::Impl::are_integral<I0,Args...>::value
617 && ! is_layout_stride
618 ), reference_type >::type
619 operator()(
const I0 & i0
620 , Args ... args )
const 622 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,args...) )
624 return m_map.m_handle[ i0 ];
627 template<
typename I0
629 KOKKOS_FORCEINLINE_FUNCTION
630 typename std::enable_if<
631 ( Kokkos::Impl::are_integral<I0,Args...>::value
635 ), reference_type >::type
636 operator()(
const I0 & i0
637 , Args ... args )
const 639 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,args...) )
641 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
647 template<
typename I0 >
648 KOKKOS_FORCEINLINE_FUNCTION
649 typename std::enable_if<
650 ( Kokkos::Impl::are_integral<I0>::value
653 ), reference_type >::type
654 operator[](
const I0 & i0 )
const 656 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0) )
658 return m_map.reference(i0);
661 template<
typename I0 >
662 KOKKOS_FORCEINLINE_FUNCTION
663 typename std::enable_if<
664 ( Kokkos::Impl::are_integral<I0>::value
667 && ! is_layout_stride
668 ), reference_type >::type
669 operator[](
const I0 & i0 )
const 671 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0) )
673 return m_map.m_handle[ i0 ];
676 template<
typename I0 >
677 KOKKOS_FORCEINLINE_FUNCTION
678 typename std::enable_if<
679 ( Kokkos::Impl::are_integral<I0>::value
683 ), reference_type >::type
684 operator[](
const I0 & i0 )
const 686 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0) )
688 return m_map.m_handle[ m_map.m_offset.m_stride.S0 * i0 ];
694 template<
typename I0 ,
typename I1
696 KOKKOS_FORCEINLINE_FUNCTION
697 typename std::enable_if<
698 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
701 ), reference_type >::type
702 operator()(
const I0 & i0 ,
const I1 & i1
703 , Args ... args )
const 705 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
707 return m_map.reference(i0,i1);
710 template<
typename I0 ,
typename I1
712 KOKKOS_FORCEINLINE_FUNCTION
713 typename std::enable_if<
714 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
717 && is_layout_left && ( traits::rank_dynamic == 0 )
718 ), reference_type >::type
719 operator()(
const I0 & i0 ,
const I1 & i1
720 , Args ... args )
const 722 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
724 return m_map.m_handle[ i0 + m_map.m_offset.m_dim.N0 * i1 ];
727 template<
typename I0 ,
typename I1
729 KOKKOS_FORCEINLINE_FUNCTION
730 typename std::enable_if<
731 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
734 && is_layout_left && ( traits::rank_dynamic != 0 )
735 ), reference_type >::type
736 operator()(
const I0 & i0 ,
const I1 & i1
737 , Args ... args )
const 739 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
741 return m_map.m_handle[ i0 + m_map.m_offset.m_stride * i1 ];
744 template<
typename I0 ,
typename I1
746 KOKKOS_FORCEINLINE_FUNCTION
747 typename std::enable_if<
748 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
751 && is_layout_right && ( traits::rank_dynamic == 0 )
752 ), reference_type >::type
753 operator()(
const I0 & i0 ,
const I1 & i1
754 , Args ... args )
const 756 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
758 return m_map.m_handle[ i1 + m_map.m_offset.m_dim.N1 * i0 ];
761 template<
typename I0 ,
typename I1
763 KOKKOS_FORCEINLINE_FUNCTION
764 typename std::enable_if<
765 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
768 && is_layout_right && ( traits::rank_dynamic != 0 )
769 ), reference_type >::type
770 operator()(
const I0 & i0 ,
const I1 & i1
771 , Args ... args )
const 773 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
775 return m_map.m_handle[ i1 + m_map.m_offset.m_stride * i0 ];
778 template<
typename I0 ,
typename I1
780 KOKKOS_FORCEINLINE_FUNCTION
781 typename std::enable_if<
782 ( Kokkos::Impl::are_integral<I0,I1,Args...>::value
786 ), reference_type >::type
787 operator()(
const I0 & i0 ,
const I1 & i1
788 , Args ... args )
const 790 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,args...) )
792 return m_map.m_handle[ i0 * m_map.m_offset.m_stride.S0 +
793 i1 * m_map.m_offset.m_stride.S1 ];
799 template<
typename I0 ,
typename I1 ,
typename I2
801 KOKKOS_FORCEINLINE_FUNCTION
802 typename std::enable_if<
803 ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
806 ), reference_type >::type
807 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2
808 , Args ... args )
const 810 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,args...) )
812 return m_map.m_handle[ m_map.m_offset(i0,i1,i2) ];
815 template<
typename I0 ,
typename I1 ,
typename I2
817 KOKKOS_FORCEINLINE_FUNCTION
818 typename std::enable_if<
819 ( Kokkos::Impl::are_integral<I0,I1,I2,Args...>::value
822 ), reference_type >::type
823 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2
824 , Args ... args )
const 826 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,args...) )
828 return m_map.reference(i0,i1,i2);
834 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
836 KOKKOS_FORCEINLINE_FUNCTION
837 typename std::enable_if<
838 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
841 ), reference_type >::type
842 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
843 , Args ... args )
const 845 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,args...) )
847 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3) ];
850 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
852 KOKKOS_FORCEINLINE_FUNCTION
853 typename std::enable_if<
854 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,Args...>::value
857 ), reference_type >::type
858 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
859 , Args ... args )
const 861 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,args...) )
863 return m_map.reference(i0,i1,i2,i3);
869 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
872 KOKKOS_FORCEINLINE_FUNCTION
873 typename std::enable_if<
874 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
877 ), reference_type >::type
878 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
880 , Args ... args )
const 882 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,args...) )
884 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4) ];
887 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
890 KOKKOS_FORCEINLINE_FUNCTION
891 typename std::enable_if<
892 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,Args...>::value
895 ), reference_type >::type
896 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
898 , Args ... args )
const 900 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,args...) )
902 return m_map.reference(i0,i1,i2,i3,i4);
908 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
909 ,
typename I4 ,
typename I5
911 KOKKOS_FORCEINLINE_FUNCTION
912 typename std::enable_if<
913 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
916 ), reference_type >::type
917 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
918 ,
const I4 & i4 ,
const I5 & i5
919 , Args ... args )
const 921 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,args...) )
923 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5) ];
926 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
927 ,
typename I4 ,
typename I5
929 KOKKOS_FORCEINLINE_FUNCTION
930 typename std::enable_if<
931 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,Args...>::value
934 ), reference_type >::type
935 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
936 ,
const I4 & i4 ,
const I5 & i5
937 , Args ... args )
const 939 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,args...) )
941 return m_map.reference(i0,i1,i2,i3,i4,i5);
947 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
948 ,
typename I4 ,
typename I5 ,
typename I6
950 KOKKOS_FORCEINLINE_FUNCTION
951 typename std::enable_if<
952 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
955 ), reference_type >::type
956 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
957 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6
958 , Args ... args )
const 960 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
962 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6) ];
965 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
966 ,
typename I4 ,
typename I5 ,
typename I6
968 KOKKOS_FORCEINLINE_FUNCTION
969 typename std::enable_if<
970 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,Args...>::value
973 ), reference_type >::type
974 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
975 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6
976 , Args ... args )
const 978 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,i6,args...) )
980 return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
986 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
987 ,
typename I4 ,
typename I5 ,
typename I6 ,
typename I7
989 KOKKOS_FORCEINLINE_FUNCTION
990 typename std::enable_if<
991 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
994 ), reference_type >::type
995 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
996 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 ,
const I7 & i7
997 , Args ... args )
const 999 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1001 return m_map.m_handle[ m_map.m_offset(i0,i1,i2,i3,i4,i5,i6,i7) ];
1004 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1005 ,
typename I4 ,
typename I5 ,
typename I6 ,
typename I7
1007 KOKKOS_FORCEINLINE_FUNCTION
1008 typename std::enable_if<
1009 ( Kokkos::Impl::are_integral<I0,I1,I2,I3,I4,I5,I6,I7,Args...>::value
1012 ), reference_type >::type
1013 operator()(
const I0 & i0 ,
const I1 & i1 ,
const I2 & i2 ,
const I3 & i3
1014 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 ,
const I7 & i7
1015 , Args ... args )
const 1017 KOKKOS_VIEW_OPERATOR_VERIFY( (m_map,i0,i1,i2,i3,i4,i5,i6,i7,args...) )
1019 return m_map.reference(i0,i1,i2,i3,i4,i5,i6,i7);
1022 #undef KOKKOS_VIEW_OPERATOR_VERIFY 1027 KOKKOS_INLINE_FUNCTION
1030 KOKKOS_INLINE_FUNCTION
1031 View() : m_track(), m_map() {}
1033 KOKKOS_INLINE_FUNCTION
1034 View(
const View & rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ) {}
1036 KOKKOS_INLINE_FUNCTION
1037 View( View && rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ) {}
1039 KOKKOS_INLINE_FUNCTION
1040 View & operator = (
const View & rhs ) { m_track = rhs.m_track ; m_map = rhs.m_map ;
return *this ; }
1042 KOKKOS_INLINE_FUNCTION
1043 View & operator = ( View && rhs ) { m_track = rhs.m_track ; m_map = rhs.m_map ;
return *this ; }
1049 template<
class RT ,
class ... RP >
1050 KOKKOS_INLINE_FUNCTION
1052 : m_track( rhs.m_track , traits::is_managed )
1055 typedef typename View<RT,RP...>
::traits SrcTraits ;
1056 typedef Kokkos::Experimental::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1057 static_assert( Mapping::is_assignable ,
"Incompatible View copy construction" );
1058 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1061 template<
class RT ,
class ... RP >
1062 KOKKOS_INLINE_FUNCTION
1065 typedef typename View<RT,RP...>
::traits SrcTraits ;
1066 typedef Kokkos::Experimental::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
1067 static_assert( Mapping::is_assignable ,
"Incompatible View copy assignment" );
1068 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
1069 m_track.assign( rhs.m_track , traits::is_managed );
1077 template<
class RT ,
class ... RP ,
class Arg0 ,
class ... Args >
1078 KOKKOS_INLINE_FUNCTION
1080 ,
const Arg0 & arg0 , Args ... args )
1081 : m_track( src_view.m_track , traits::is_managed )
1084 typedef View< RT , RP... > SrcType ;
1086 typedef Kokkos::Experimental::Impl::ViewMapping
1088 ,
typename SrcType::traits
1089 , Arg0 , Args... > Mapping ;
1091 typedef typename Mapping::type DstType ;
1093 static_assert( Kokkos::Experimental::Impl::ViewMapping< View , DstType , void >::is_assignable
1094 ,
"Subview construction requires compatible view and subview arguments" );
1096 Mapping::assign( m_map, src_view.m_map, arg0 , args... );
1105 template<
class ExecSpace >
1106 struct DestroyFunctor {
1110 void destroy_shared_allocation() { m_map.destroy( m_space ); }
1115 KOKKOS_INLINE_FUNCTION
1116 int use_count()
const {
return m_track.use_count(); }
1119 const std::string label()
const {
return m_track.template get_label< typename traits::memory_space >(); }
1122 template<
class Prop >
1124 View(
const Prop & arg_prop
1125 ,
typename std::enable_if< ! is_view<Prop>::value ,
1126 const size_t >::type arg_N0 = 0
1127 ,
const size_t arg_N1 = 0
1128 ,
const size_t arg_N2 = 0
1129 ,
const size_t arg_N3 = 0
1130 ,
const size_t arg_N4 = 0
1131 ,
const size_t arg_N5 = 0
1132 ,
const size_t arg_N6 = 0
1133 ,
const size_t arg_N7 = 0
1139 typedef Kokkos::Experimental::Impl::ViewAllocProp< typename traits::device_type , Prop > alloc_prop ;
1141 typedef typename alloc_prop::execution_space execution_space ;
1142 typedef typename traits::memory_space memory_space ;
1143 typedef DestroyFunctor< execution_space > destroy_functor ;
1144 typedef Kokkos::Experimental::Impl::SharedAllocationRecord< memory_space , destroy_functor > record_type ;
1146 static_assert( traits::is_managed ,
"View allocation constructor requires managed memory" );
1148 const alloc_prop
prop( arg_prop );
1151 if ( prop.initialize.value && ! prop.execution.is_initialized() ) {
1152 Kokkos::Impl::throw_runtime_exception(
"Constructing View and initializing data with uninitialized execution space");
1156 const size_t alloc_size = map_type::memory_span( prop.allow_padding
1157 , arg_N0 , arg_N1 , arg_N2 , arg_N3
1158 , arg_N4 , arg_N5 , arg_N6 , arg_N7 );
1161 record_type *
const record = record_type::allocate( prop.memory , prop.label , alloc_size );
1165 m_map = map_type( reinterpret_cast< pointer_type >( record->data() )
1166 , prop.allow_padding
1167 , arg_N0 , arg_N1 , arg_N2 , arg_N3
1168 , arg_N4 , arg_N5 , arg_N6 , arg_N7 );
1173 if ( prop.initialize.value ) {
1174 m_map.construct( prop.execution );
1176 record->m_destroy.m_map = m_map ;
1177 record->m_destroy.m_space = prop.execution ;
1181 m_track.assign_allocated_record_to_uninitialized( record );
1184 template<
class Prop >
1186 View(
const Prop & arg_prop
1187 ,
const typename traits::array_layout & arg_layout
1193 typedef Kokkos::Experimental::Impl::ViewAllocProp< typename traits::device_type , Prop > alloc_prop ;
1195 typedef typename alloc_prop::execution_space execution_space ;
1196 typedef typename traits::memory_space memory_space ;
1197 typedef DestroyFunctor< execution_space > destroy_functor ;
1198 typedef Kokkos::Experimental::Impl::SharedAllocationRecord< memory_space , destroy_functor > record_type ;
1200 static_assert( traits::is_managed ,
"View allocation constructor requires managed memory" );
1202 const alloc_prop
prop( arg_prop );
1205 if ( prop.initialize.value && ! prop.execution.is_initialized() ) {
1206 Kokkos::Impl::throw_runtime_exception(
"Constructing View and initializing data with uninitialized execution space");
1210 const size_t alloc_size = map_type::memory_span( prop.allow_padding , arg_layout );
1213 record_type *
const record = record_type::allocate( prop.memory , prop.label , alloc_size );
1217 m_map = map_type( reinterpret_cast< pointer_type >( record->data() ) , prop.allow_padding , arg_layout );
1221 if ( prop.initialize.value ) {
1222 m_map.construct( prop.execution );
1224 record->m_destroy.m_map = m_map ;
1225 record->m_destroy.m_space = prop.execution ;
1229 m_track.assign_allocated_record_to_uninitialized( record );
1234 static constexpr
size_t memory_span(
const size_t arg_N0 = 0
1235 ,
const size_t arg_N1 = 0
1236 ,
const size_t arg_N2 = 0
1237 ,
const size_t arg_N3 = 0
1238 ,
const size_t arg_N4 = 0
1239 ,
const size_t arg_N5 = 0
1240 ,
const size_t arg_N6 = 0
1241 ,
const size_t arg_N7 = 0
1244 return map_type::memory_span( std::integral_constant<bool,false>()
1245 , arg_N0 , arg_N1 , arg_N2 , arg_N3
1246 , arg_N4 , arg_N5 , arg_N6 , arg_N7 );
1250 View( pointer_type arg_ptr
1251 ,
const size_t arg_N0 = 0
1252 ,
const size_t arg_N1 = 0
1253 ,
const size_t arg_N2 = 0
1254 ,
const size_t arg_N3 = 0
1255 ,
const size_t arg_N4 = 0
1256 ,
const size_t arg_N5 = 0
1257 ,
const size_t arg_N6 = 0
1258 ,
const size_t arg_N7 = 0
1261 , m_map( arg_ptr , std::integral_constant<bool,false>()
1262 , arg_N0 , arg_N1 , arg_N2 , arg_N3
1263 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1267 View( pointer_type arg_ptr
1268 ,
typename traits::array_layout & arg_layout
1271 , m_map( arg_ptr , std::integral_constant<bool,false>(), arg_layout )
1278 size_t shmem_size(
const size_t arg_N0 = 0 ,
1279 const size_t arg_N1 = 0 ,
1280 const size_t arg_N2 = 0 ,
1281 const size_t arg_N3 = 0 ,
1282 const size_t arg_N4 = 0 ,
1283 const size_t arg_N5 = 0 ,
1284 const size_t arg_N6 = 0 ,
1285 const size_t arg_N7 = 0 )
1287 return map_type::memory_span( std::integral_constant<bool,false>()
1288 , arg_N0 , arg_N1 , arg_N2 , arg_N3
1289 , arg_N4 , arg_N5 , arg_N6 , arg_N7 );
1292 explicit KOKKOS_INLINE_FUNCTION
1293 View(
const typename traits::execution_space::scratch_memory_space & arg_space
1294 ,
const size_t arg_N0 = 0
1295 ,
const size_t arg_N1 = 0
1296 ,
const size_t arg_N2 = 0
1297 ,
const size_t arg_N3 = 0
1298 ,
const size_t arg_N4 = 0
1299 ,
const size_t arg_N5 = 0
1300 ,
const size_t arg_N6 = 0
1301 ,
const size_t arg_N7 = 0 )
1303 , m_map( reinterpret_cast<pointer_type>(
1304 arg_space.get_shmem(
1305 map_type::memory_span( std::integral_constant<bool,false>()
1306 , arg_N0 , arg_N1 , arg_N2 , arg_N3
1307 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) ) )
1308 , std::integral_constant<bool,false>()
1309 , arg_N0 , arg_N1 , arg_N2 , arg_N3
1310 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1317 template<
class V ,
class ... Args >
1319 typename Kokkos::Experimental::Impl::ViewMapping
1325 template<
class D,
class ... P ,
class ... Args >
1326 KOKKOS_INLINE_FUNCTION
1327 typename Kokkos::Experimental::Impl::ViewMapping
1335 "subview requires one argument for each source View rank" );
1338 Kokkos::Experimental::Impl::ViewMapping
1341 , Args ... >::type( src , args ... );
1344 template<
class MemoryTraits ,
class D,
class ... P ,
class ... Args >
1345 KOKKOS_INLINE_FUNCTION
1346 typename Kokkos::Experimental::Impl::ViewMapping
1350 >::template apply< MemoryTraits >::type
1354 "subview requires one argument for each source View rank" );
1357 Kokkos::Experimental::Impl::ViewMapping
1361 ::template apply< MemoryTraits >
1362 ::type( src , args ... );
1376 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
1377 KOKKOS_INLINE_FUNCTION
1386 std::is_same<
typename lhs_traits::const_value_type ,
1387 typename rhs_traits::const_value_type >::value &&
1388 std::is_same<
typename lhs_traits::array_layout ,
1389 typename rhs_traits::array_layout >::value &&
1390 std::is_same<
typename lhs_traits::memory_space ,
1391 typename rhs_traits::memory_space >::value &&
1392 lhs_traits::rank == rhs_traits::rank &&
1393 lhs.data() == rhs.data() &&
1394 lhs.span() == rhs.span() &&
1395 lhs.dimension_0() == rhs.dimension_0() &&
1396 lhs.dimension_1() == rhs.dimension_1() &&
1397 lhs.dimension_2() == rhs.dimension_2() &&
1398 lhs.dimension_3() == rhs.dimension_3() &&
1399 lhs.dimension_4() == rhs.dimension_4() &&
1400 lhs.dimension_5() == rhs.dimension_5() &&
1401 lhs.dimension_6() == rhs.dimension_6() &&
1402 lhs.dimension_7() == rhs.dimension_7();
1405 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
1406 KOKKOS_INLINE_FUNCTION
1422 #if defined( KOKKOS_USING_EXPERIMENTAL_VIEW ) 1425 void shared_allocation_tracking_claim_and_disable()
1426 { Kokkos::Experimental::Impl::SharedAllocationRecord<void,void>::tracking_claim_and_disable(); }
1429 void shared_allocation_tracking_release_and_enable()
1430 { Kokkos::Experimental::Impl::SharedAllocationRecord<void,void>::tracking_release_and_enable(); }
1435 void shared_allocation_tracking_claim_and_disable()
1436 { Kokkos::Impl::AllocationTracker::disable_tracking(); }
1439 void shared_allocation_tracking_release_and_enable()
1440 { Kokkos::Impl::AllocationTracker::enable_tracking(); }
1454 template<
class OutputView ,
typename Enable =
void >
1457 typedef typename OutputView::const_value_type const_value_type ;
1459 const OutputView output ;
1460 const_value_type input ;
1462 KOKKOS_INLINE_FUNCTION
1463 void operator()(
const size_t i0 )
const 1465 const size_t n1 = output.dimension_1();
1466 const size_t n2 = output.dimension_2();
1467 const size_t n3 = output.dimension_3();
1468 const size_t n4 = output.dimension_4();
1469 const size_t n5 = output.dimension_5();
1470 const size_t n6 = output.dimension_6();
1471 const size_t n7 = output.dimension_7();
1473 for (
size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1474 for (
size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1475 for (
size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1476 for (
size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1477 for (
size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1478 for (
size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1479 for (
size_t i7 = 0 ; i7 < n7 ; ++i7 ) {
1480 output(i0,i1,i2,i3,i4,i5,i6,i7) = input ;
1484 ViewFill(
const OutputView & arg_out , const_value_type & arg_in )
1485 : output( arg_out ), input( arg_in )
1487 typedef typename OutputView::execution_space execution_space ;
1494 execution_space::fence();
1498 template<
class OutputView >
1499 struct ViewFill< OutputView , typename std::enable_if< OutputView::Rank == 0 >::type > {
1500 ViewFill(
const OutputView & dst ,
const typename OutputView::const_value_type & src )
1502 Kokkos::Impl::DeepCopy< typename OutputView::memory_space , Kokkos::HostSpace >
1503 ( dst.data() , & src ,
sizeof(
typename OutputView::const_value_type) );
1507 template<
class OutputView ,
class InputView >
1510 const OutputView output ;
1511 const InputView input ;
1521 ViewRemap(
const OutputView & arg_out ,
const InputView & arg_in )
1522 : output( arg_out ), input( arg_in )
1523 , n0( std::min( (
size_t)arg_out.dimension_0() , (size_t)arg_in.dimension_0() ) )
1524 , n1( std::min( (
size_t)arg_out.dimension_1() , (size_t)arg_in.dimension_1() ) )
1525 , n2( std::min( (
size_t)arg_out.dimension_2() , (size_t)arg_in.dimension_2() ) )
1526 , n3( std::min( (
size_t)arg_out.dimension_3() , (size_t)arg_in.dimension_3() ) )
1527 , n4( std::min( (
size_t)arg_out.dimension_4() , (size_t)arg_in.dimension_4() ) )
1528 , n5( std::min( (
size_t)arg_out.dimension_5() , (size_t)arg_in.dimension_5() ) )
1529 , n6( std::min( (
size_t)arg_out.dimension_6() , (size_t)arg_in.dimension_6() ) )
1530 , n7( std::min( (
size_t)arg_out.dimension_7() , (size_t)arg_in.dimension_7() ) )
1532 typedef typename OutputView::execution_space execution_space ;
1538 KOKKOS_INLINE_FUNCTION
1539 void operator()(
const size_t i0 )
const 1541 for (
size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1542 for (
size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1543 for (
size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1544 for (
size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1545 for (
size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1546 for (
size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1547 for (
size_t i7 = 0 ; i7 < n7 ; ++i7 ) {
1548 output(i0,i1,i2,i3,i4,i5,i6,i7) = input(i0,i1,i2,i3,i4,i5,i6,i7);
1564 template<
class DT ,
class ... DP >
1568 ,
typename ViewTraits<DT,DP...>::const_value_type & value
1569 ,
typename std::enable_if<
1570 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value
1574 std::is_same<
typename ViewTraits<DT,DP...>::non_const_value_type ,
1575 typename ViewTraits<DT,DP...>::value_type >::value
1576 ,
"deep_copy requires non-const type" );
1578 Kokkos::Experimental::Impl::ViewFill<
View<DT,DP...> >( dst , value );
1582 template<
class ST ,
class ... SP >
1587 ,
typename std::enable_if<
1588 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value
1592 ,
"ERROR: Non-rank-zero view in deep_copy( value , View )" );
1595 typedef typename src_traits::memory_space src_memory_space ;
1596 Kokkos::Impl::DeepCopy< HostSpace , src_memory_space >( & dst , src.data() ,
sizeof(ST) );
1601 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
1606 ,
typename std::enable_if<(
1607 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
1608 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
1614 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1615 typename ViewTraits<ST,SP...>::non_const_value_type >::value
1616 ,
"deep_copy requires matching non-const destination type" );
1618 typedef View<DT,DP...> dst_type ;
1619 typedef View<ST,SP...> src_type ;
1621 typedef typename dst_type::value_type value_type ;
1622 typedef typename dst_type::memory_space dst_memory_space ;
1623 typedef typename src_type::memory_space src_memory_space ;
1625 if ( dst.data() != src.data() ) {
1626 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() ,
sizeof(value_type) );
1634 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
1639 ,
typename std::enable_if<(
1640 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value &&
1641 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value &&
1647 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1648 typename ViewTraits<DT,DP...>::non_const_value_type >::value
1649 ,
"deep_copy requires non-const destination type" );
1654 ,
"deep_copy requires Views of equal rank" );
1656 typedef View<DT,DP...> dst_type ;
1657 typedef View<ST,SP...> src_type ;
1659 typedef typename dst_type::execution_space dst_execution_space ;
1660 typedef typename dst_type::memory_space dst_memory_space ;
1661 typedef typename src_type::memory_space src_memory_space ;
1663 enum { DstExecCanAccessSrc =
1664 Kokkos::Impl::VerifyExecutionCanAccessMemorySpace< typename dst_execution_space::memory_space , src_memory_space >::value };
1666 if ( (
void *) dst.data() != (
void*) src.data() ) {
1673 if ( std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
1674 typename ViewTraits<ST,SP...>::non_const_value_type >::value &&
1675 std::is_same<
typename ViewTraits<DT,DP...>::array_layout ,
1676 typename ViewTraits<ST,SP...>::array_layout >::value &&
1677 dst.span_is_contiguous() &&
1678 src.span_is_contiguous() &&
1679 dst.span() == src.span() &&
1680 dst.dimension_0() == src.dimension_0() &&
1681 dst.dimension_1() == src.dimension_1() &&
1682 dst.dimension_2() == src.dimension_2() &&
1683 dst.dimension_3() == src.dimension_3() &&
1684 dst.dimension_4() == src.dimension_4() &&
1685 dst.dimension_5() == src.dimension_5() &&
1686 dst.dimension_6() == src.dimension_6() &&
1687 dst.dimension_7() == src.dimension_7() ) {
1689 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1691 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
1693 else if ( DstExecCanAccessSrc ) {
1695 Kokkos::Experimental::Impl::ViewRemap< dst_type , src_type >( dst , src );
1698 Kokkos::Impl::throw_runtime_exception(
"deep_copy given views that would require a temporary allocation");
1712 template<
class T ,
class ... P >
1716 ,
typename std::enable_if<
1717 ! std::is_same<
typename Kokkos::Experimental::ViewTraits<T,P...>::array_layout
1722 typedef View<T,P...> src_type ;
1723 typedef typename src_type::HostMirror dst_type ;
1725 return dst_type( std::string( src.label() ).append(
"_mirror")
1733 , src.dimension_7() );
1736 template<
class T ,
class ... P >
1740 ,
typename std::enable_if<
1741 std::is_same<
typename Kokkos::Experimental::ViewTraits<T,P...>::array_layout
1746 typedef View<T,P...> src_type ;
1747 typedef typename src_type::HostMirror dst_type ;
1751 layout.dimension[0] = src.dimension_0();
1752 layout.dimension[1] = src.dimension_1();
1753 layout.dimension[2] = src.dimension_2();
1754 layout.dimension[3] = src.dimension_3();
1755 layout.dimension[4] = src.dimension_4();
1756 layout.dimension[5] = src.dimension_5();
1757 layout.dimension[6] = src.dimension_6();
1758 layout.dimension[7] = src.dimension_7();
1760 layout.stride[0] = src.stride_0();
1761 layout.stride[1] = src.stride_1();
1762 layout.stride[2] = src.stride_2();
1763 layout.stride[3] = src.stride_3();
1764 layout.stride[4] = src.stride_4();
1765 layout.stride[5] = src.stride_5();
1766 layout.stride[6] = src.stride_6();
1767 layout.stride[7] = src.stride_7();
1769 return dst_type( std::string( src.label() ).append(
"_mirror") , layout );
1772 template<
class T ,
class ... P >
1776 ,
typename std::enable_if<(
1777 std::is_same<
typename Kokkos::Experimental::View<T,P...>::memory_space
1778 ,
typename Kokkos::Experimental::View<T,P...>::HostMirror::memory_space
1781 std::is_same<
typename Kokkos::Experimental::View<T,P...>::data_type
1782 ,
typename Kokkos::Experimental::View<T,P...>::HostMirror::data_type
1790 template<
class T ,
class ... P >
1794 ,
typename std::enable_if< ! (
1795 std::is_same<
typename Kokkos::Experimental::View<T,P...>::memory_space
1796 ,
typename Kokkos::Experimental::View<T,P...>::HostMirror::memory_space
1799 std::is_same<
typename Kokkos::Experimental::View<T,P...>::data_type
1800 ,
typename Kokkos::Experimental::View<T,P...>::HostMirror::data_type
1805 return Kokkos::Experimental::create_mirror( src );
1818 template<
class T ,
class ... P >
1821 const size_t n0 = 0 ,
1822 const size_t n1 = 0 ,
1823 const size_t n2 = 0 ,
1824 const size_t n3 = 0 ,
1825 const size_t n4 = 0 ,
1826 const size_t n5 = 0 ,
1827 const size_t n6 = 0 ,
1828 const size_t n7 = 0 )
1834 view_type v_resized( v.label(), n0, n1, n2, n3, n4, n5, n6, n7 );
1836 Kokkos::Experimental::Impl::ViewRemap< view_type , view_type >( v_resized , v );
1842 template<
class T ,
class ... P >
1845 const size_t n0 = 0 ,
1846 const size_t n1 = 0 ,
1847 const size_t n2 = 0 ,
1848 const size_t n3 = 0 ,
1849 const size_t n4 = 0 ,
1850 const size_t n5 = 0 ,
1851 const size_t n6 = 0 ,
1852 const size_t n7 = 0 )
1858 const std::string label = v.label();
1861 v = view_type( label, n0, n1, n2, n3, n4, n5, n6, n7 );
1870 #if defined( KOKKOS_USING_EXPERIMENTAL_VIEW ) 1874 template<
class D ,
class ... P >
1877 template<
class D ,
class ... P >
1880 using Kokkos::Experimental::ALL ;
1881 using Kokkos::Experimental::deep_copy ;
1882 using Kokkos::Experimental::create_mirror ;
1883 using Kokkos::Experimental::create_mirror_view ;
1884 using Kokkos::Experimental::subview ;
1885 using Kokkos::Experimental::resize ;
1886 using Kokkos::Experimental::realloc ;
1887 using Kokkos::Experimental::is_view ;
1891 using Kokkos::Experimental::is_view ;
1893 class ViewDefault {};
1895 template<
class SrcViewType
1905 struct ViewSubview ;
1911 #include <impl/Kokkos_Atomic_View.hpp>
Tag denoting that a subview should capture all of a dimension.
void deep_copy(const View< DT, DL, DD, DM, DS > &dst, typename Impl::enable_if<(Impl::is_same< typename ViewTraits< DT, DL, DD, DM >::non_const_value_type, typename ViewTraits< DT, DL, DD, DM >::value_type >::value), typename ViewTraits< DT, DL, DD, DM >::const_value_type >::type &value)
Deep copy a value into a view.
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::host_mirror_space > HostMirror
Compatible HostMirror view.
KOKKOS_INLINE_FUNCTION bool operator!=(const complex< RealType > &x, const complex< RealType > &y)
Inequality operator for two complex numbers.
View< typename traits::array_scalar_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...
Memory space for main process and CPU execution spaces.
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.
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::const_data_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > const_type
Compatible view of const data type.
KOKKOS_INLINE_FUNCTION bool operator==(const complex< RealType > &x, const complex< RealType > &y)
Equality operator for two complex numbers.
Execution policy for work over a range of an integral type.
void resize(View< T, L, D, M, S > &v, const typename Impl::enable_if< ViewTraits< T, L, D, M >::is_managed, size_t >::type n0, 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.
Traits class for accessing attributes of a View.
void realloc(View< T, L, D, M, S > &v, const typename Impl::enable_if< ViewTraits< T, L, D, M >::is_managed, size_t >::type n0, 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)
Reallocate a view without copying old data to new data.
View to an array of data.