50 #ifndef KOKKOS_DYNRANKVIEW_HPP
51 #define KOKKOS_DYNRANKVIEW_HPP
53 #include <Kokkos_Core.hpp>
54 #include <impl/Kokkos_Error.hpp>
55 #include <type_traits>
59 template<
typename DataType ,
class ... Properties >
64 template <
typename Specialize>
65 struct DynRankDimTraits {
67 enum :
size_t{unspecified = KOKKOS_INVALID_INDEX};
70 KOKKOS_INLINE_FUNCTION
71 static size_t computeRank(
const size_t N0
81 ( (N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified && N1 == unspecified && N0 == unspecified) ? 0
82 : ( (N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified && N1 == unspecified) ? 1
83 : ( (N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified && N2 == unspecified) ? 2
84 : ( (N6 == unspecified && N5 == unspecified && N4 == unspecified && N3 == unspecified) ? 3
85 : ( (N6 == unspecified && N5 == unspecified && N4 == unspecified) ? 4
86 : ( (N6 == unspecified && N5 == unspecified) ? 5
87 : ( (N6 == unspecified) ? 6
92 template <
typename Layout>
93 KOKKOS_INLINE_FUNCTION
94 static size_t computeRank(
const Layout& layout )
96 return computeRank( layout.dimension[0]
100 , layout.dimension[4]
101 , layout.dimension[5]
102 , layout.dimension[6]
103 , layout.dimension[7] );
107 template <
typename Layout,
typename ... P>
108 KOKKOS_INLINE_FUNCTION
109 static size_t computeRank(
const Kokkos::Impl::ViewCtorProp<P...>& prop,
const Layout& layout )
111 return computeRank(layout);
116 template <
typename Layout>
117 KOKKOS_INLINE_FUNCTION
118 static typename std::enable_if< (std::is_same<Layout , Kokkos::LayoutRight>::value || std::is_same<Layout , Kokkos::LayoutLeft>::value) , Layout >::type createLayout(
const Layout& layout )
120 return Layout( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
121 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
122 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
123 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
124 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
125 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
126 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
127 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1
132 template <
typename Layout>
133 KOKKOS_INLINE_FUNCTION
134 static typename std::enable_if< (std::is_same<Layout , Kokkos::LayoutStride>::value) , Layout>::type createLayout(
const Layout& layout )
136 return Layout( layout.dimension[0] != unspecified ? layout.dimension[0] : 1
138 , layout.dimension[1] != unspecified ? layout.dimension[1] : 1
140 , layout.dimension[2] != unspecified ? layout.dimension[2] : 1
142 , layout.dimension[3] != unspecified ? layout.dimension[3] : 1
144 , layout.dimension[4] != unspecified ? layout.dimension[4] : 1
146 , layout.dimension[5] != unspecified ? layout.dimension[5] : 1
148 , layout.dimension[6] != unspecified ? layout.dimension[6] : 1
150 , layout.dimension[7] != unspecified ? layout.dimension[7] : 1
156 template <
typename Traits,
typename ... P>
157 KOKKOS_INLINE_FUNCTION
158 static typename std::enable_if< (std::is_same<typename Traits::array_layout , Kokkos::LayoutRight>::value || std::is_same<typename Traits::array_layout , Kokkos::LayoutLeft>::value || std::is_same<typename Traits::array_layout , Kokkos::LayoutStride>::value) ,
typename Traits::array_layout >::type createLayout(
const Kokkos::Impl::ViewCtorProp<P...>& prop,
const typename Traits::array_layout& layout )
160 return createLayout( layout );
166 template <
typename ViewType,
typename ViewArg>
167 static ViewType createView(
const ViewArg& arg
178 , N0 != unspecified ? N0 : 1
179 , N1 != unspecified ? N1 : 1
180 , N2 != unspecified ? N2 : 1
181 , N3 != unspecified ? N3 : 1
182 , N4 != unspecified ? N4 : 1
183 , N5 != unspecified ? N5 : 1
184 , N6 != unspecified ? N6 : 1
185 , N7 != unspecified ? N7 : 1 );
190 template <
typename Layout ,
typename iType>
191 KOKKOS_INLINE_FUNCTION
192 static typename std::enable_if< (std::is_same<Layout , Kokkos::LayoutRight>::value || std::is_same<Layout , Kokkos::LayoutLeft>::value) && std::is_integral<iType>::value , Layout >::type
193 reconstructLayout(
const Layout& layout , iType dynrank )
195 return Layout( dynrank > 0 ? layout.dimension[0] :KOKKOS_INVALID_INDEX
196 , dynrank > 1 ? layout.dimension[1] :KOKKOS_INVALID_INDEX
197 , dynrank > 2 ? layout.dimension[2] :KOKKOS_INVALID_INDEX
198 , dynrank > 3 ? layout.dimension[3] :KOKKOS_INVALID_INDEX
199 , dynrank > 4 ? layout.dimension[4] :KOKKOS_INVALID_INDEX
200 , dynrank > 5 ? layout.dimension[5] :KOKKOS_INVALID_INDEX
201 , dynrank > 6 ? layout.dimension[6] :KOKKOS_INVALID_INDEX
202 , dynrank > 7 ? layout.dimension[7] :KOKKOS_INVALID_INDEX
207 template <
typename Layout ,
typename iType>
208 KOKKOS_INLINE_FUNCTION
209 static typename std::enable_if< (std::is_same<Layout , Kokkos::LayoutStride>::value) && std::is_integral<iType>::value , Layout >::type
210 reconstructLayout(
const Layout& layout , iType dynrank )
212 return Layout( dynrank > 0 ? layout.dimension[0] :KOKKOS_INVALID_INDEX
213 , dynrank > 0 ? layout.stride[0] : (0)
214 , dynrank > 1 ? layout.dimension[1] :KOKKOS_INVALID_INDEX
215 , dynrank > 1 ? layout.stride[1] : (0)
216 , dynrank > 2 ? layout.dimension[2] :KOKKOS_INVALID_INDEX
217 , dynrank > 2 ? layout.stride[2] : (0)
218 , dynrank > 3 ? layout.dimension[3] :KOKKOS_INVALID_INDEX
219 , dynrank > 3 ? layout.stride[3] : (0)
220 , dynrank > 4 ? layout.dimension[4] :KOKKOS_INVALID_INDEX
221 , dynrank > 4 ? layout.stride[4] : (0)
222 , dynrank > 5 ? layout.dimension[5] :KOKKOS_INVALID_INDEX
223 , dynrank > 5 ? layout.stride[5] : (0)
224 , dynrank > 6 ? layout.dimension[6] :KOKKOS_INVALID_INDEX
225 , dynrank > 6 ? layout.stride[6] : (0)
226 , dynrank > 7 ? layout.dimension[7] :KOKKOS_INVALID_INDEX
227 , dynrank > 7 ? layout.stride[7] : (0)
235 template<
unsigned ,
typename iType0 ,
class MapType >
236 KOKKOS_INLINE_FUNCTION
237 bool dyn_rank_view_verify_operator_bounds(
const iType0 & ,
const MapType & )
240 template<
unsigned R ,
typename iType0 ,
class MapType ,
typename iType1 ,
class ... Args >
241 KOKKOS_INLINE_FUNCTION
242 bool dyn_rank_view_verify_operator_bounds
243 (
const iType0 &
rank
244 ,
const MapType & map
249 if ( static_cast<iType0>(R) < rank ) {
250 return (
size_t(i) < map.extent(R) )
251 && dyn_rank_view_verify_operator_bounds<R+1>( rank , map , args ... );
254 printf(
"DynRankView Debug Bounds Checking Error: at rank %u\n Extra arguments beyond the rank must be zero \n",R);
256 && dyn_rank_view_verify_operator_bounds<R+1>(
rank , map , args ... );
260 && dyn_rank_view_verify_operator_bounds<R+1>(
rank , map , args ... );
264 template<
unsigned ,
class MapType >
266 void dyn_rank_view_error_operator_bounds(
char * ,
int ,
const MapType & )
269 template<
unsigned R ,
class MapType ,
class iType ,
class ... Args >
271 void dyn_rank_view_error_operator_bounds
274 ,
const MapType & map
280 snprintf(buf,len,
" %ld < %ld %c"
281 , static_cast<unsigned long>(i)
282 , static_cast<unsigned long>( map.extent(R) )
283 , (
sizeof...(Args) ?
',' :
')' )
285 dyn_rank_view_error_operator_bounds<R+1>(buf+n,len-n,map,args...);
289 template<
typename MemorySpace
290 ,
typename iType0 ,
typename iType1 ,
class MapType ,
class ... Args >
291 KOKKOS_INLINE_FUNCTION
292 void dyn_rank_view_verify_operator_bounds
293 (
const iType0 & op_rank ,
const iType1 & rank
294 ,
const Kokkos::Impl::SharedAllocationTracker & tracker
295 ,
const MapType & map , Args ... args )
297 if ( static_cast<iType0>(rank) > op_rank ) {
298 Kokkos::abort(
"DynRankView Bounds Checking Error: Need at least rank arguments to the operator()" );
301 if ( ! dyn_rank_view_verify_operator_bounds<0>( rank , map , args ... ) ) {
302 #if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST )
305 const std::string label = tracker.template get_label<MemorySpace>();
306 int n = snprintf(buffer,LEN,
"DynRankView bounds error of view %s (", label.c_str());
307 dyn_rank_view_error_operator_bounds<0>( buffer + n , LEN - n , map , args ... );
308 Kokkos::Impl::throw_runtime_exception(std::string(buffer));
310 Kokkos::abort(
"DynRankView bounds error");
323 template<
class DstTraits ,
class SrcTraits >
324 class ViewMapping< DstTraits , SrcTraits ,
325 typename std::enable_if<(
326 std::is_same< typename DstTraits::memory_space , typename SrcTraits::memory_space >::value
328 std::is_same< typename DstTraits::specialize , void >::value
330 std::is_same< typename SrcTraits::specialize , void >::value
333 std::is_same< typename DstTraits::array_layout , typename SrcTraits::array_layout >::value
337 std::is_same< typename DstTraits::array_layout , Kokkos::LayoutLeft >::value ||
338 std::is_same< typename DstTraits::array_layout , Kokkos::LayoutRight >::value ||
339 std::is_same< typename DstTraits::array_layout , Kokkos::LayoutStride >::value
343 std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutLeft >::value ||
344 std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutRight >::value ||
345 std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutStride >::value
349 ) , Kokkos::Impl::ViewToDynRankViewTag >::type >
353 enum { is_assignable_value_type =
354 std::is_same<
typename DstTraits::value_type
355 ,
typename SrcTraits::value_type >::value ||
356 std::is_same<
typename DstTraits::value_type
357 ,
typename SrcTraits::const_value_type >::value };
359 enum { is_assignable_layout =
360 std::is_same<
typename DstTraits::array_layout
361 ,
typename SrcTraits::array_layout >::value ||
362 std::is_same<
typename DstTraits::array_layout
368 enum { is_assignable = is_assignable_value_type &&
369 is_assignable_layout };
371 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
372 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize > SrcType ;
374 template <
typename DT ,
typename ... DP ,
typename ST ,
typename ... SP >
375 KOKKOS_INLINE_FUNCTION
378 static_assert( is_assignable_value_type
379 ,
"View assignment must have same value type or const = non-const" );
381 static_assert( is_assignable_layout
382 ,
"View assignment must have compatible layout or have rank <= 1" );
386 typedef typename DstType::offset_type dst_offset_type ;
387 dst.m_map.m_impl_offset = dst_offset_type(std::integral_constant<unsigned,0>() , src.layout() );
388 dst.m_map.m_impl_handle = Kokkos::Impl::ViewDataHandle< DstTraits >::assign( src.m_map.m_impl_handle , src.m_track );
389 dst.m_track.assign( src.m_track , DstTraits::is_managed );
390 dst.m_rank = src.Rank ;
411 template<
class >
struct is_dyn_rank_view :
public std::false_type {};
413 template<
class D,
class ... P >
414 struct is_dyn_rank_view< Kokkos::DynRankView<D,P...> > :
public std::true_type {};
417 template<
typename DataType ,
class ... Properties >
418 class DynRankView :
public ViewTraits< DataType , Properties ... >
420 static_assert( !std::is_array<DataType>::value && !std::is_pointer<DataType>::value ,
"Cannot template DynRankView with array or pointer datatype - must be pod" );
423 template < class ,
class ... >
friend class DynRankView ;
424 template < class ,
class ... >
friend class Kokkos::Impl::ViewMapping ;
427 typedef ViewTraits< DataType , Properties ... > drvtraits ;
429 typedef View< DataType******* , Properties...> view_type ;
431 typedef ViewTraits< DataType******* , Properties ... > traits ;
435 typedef Kokkos::Impl::ViewMapping< traits , typename traits::specialize > map_type ;
436 typedef Kokkos::Impl::SharedAllocationTracker track_type ;
443 KOKKOS_INLINE_FUNCTION
444 view_type & DownCast()
const {
return ( view_type & ) (*this); }
445 KOKKOS_INLINE_FUNCTION
446 const view_type & ConstDownCast()
const {
return (
const view_type & ) (*this); }
451 typedef DynRankView<
typename drvtraits::scalar_array_type ,
452 typename drvtraits::array_layout ,
453 typename drvtraits::device_type ,
454 typename drvtraits::memory_traits >
458 typedef DynRankView<
typename drvtraits::const_data_type ,
459 typename drvtraits::array_layout ,
460 typename drvtraits::device_type ,
461 typename drvtraits::memory_traits >
465 typedef DynRankView<
typename drvtraits::non_const_data_type ,
466 typename drvtraits::array_layout ,
467 typename drvtraits::device_type ,
468 typename drvtraits::memory_traits >
472 typedef DynRankView<
typename drvtraits::non_const_data_type ,
473 typename drvtraits::array_layout ,
474 typename drvtraits::host_mirror_space >
483 template<
typename iType >
484 KOKKOS_INLINE_FUNCTION constexpr
485 typename std::enable_if< std::is_integral<iType>::value ,
size_t >::type
486 extent(
const iType & r )
const
487 {
return m_map.extent(r); }
489 template<
typename iType >
490 KOKKOS_INLINE_FUNCTION constexpr
491 typename std::enable_if< std::is_integral<iType>::value ,
int >::type
492 extent_int(
const iType & r )
const
493 {
return static_cast<int>(m_map.extent(r)); }
495 KOKKOS_INLINE_FUNCTION constexpr
496 typename traits::array_layout layout()
const
497 {
return m_map.layout(); }
504 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
505 template<
typename iType >
506 KOKKOS_INLINE_FUNCTION constexpr
507 typename std::enable_if< std::is_integral<iType>::value ,
size_t >::type
508 dimension(
const iType & r )
const {
return extent( r ); }
510 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_0()
const {
return m_map.dimension_0(); }
511 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_1()
const {
return m_map.dimension_1(); }
512 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_2()
const {
return m_map.dimension_2(); }
513 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_3()
const {
return m_map.dimension_3(); }
514 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_4()
const {
return m_map.dimension_4(); }
515 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_5()
const {
return m_map.dimension_5(); }
516 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_6()
const {
return m_map.dimension_6(); }
517 KOKKOS_INLINE_FUNCTION constexpr
size_t dimension_7()
const {
return m_map.dimension_7(); }
522 KOKKOS_INLINE_FUNCTION constexpr
size_t size()
const {
return m_map.extent(0) *
531 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_0()
const {
return m_map.stride_0(); }
532 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_1()
const {
return m_map.stride_1(); }
533 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_2()
const {
return m_map.stride_2(); }
534 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_3()
const {
return m_map.stride_3(); }
535 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_4()
const {
return m_map.stride_4(); }
536 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_5()
const {
return m_map.stride_5(); }
537 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_6()
const {
return m_map.stride_6(); }
538 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_7()
const {
return m_map.stride_7(); }
540 template<
typename iType >
541 KOKKOS_INLINE_FUNCTION
void stride( iType *
const s )
const { m_map.stride(s); }
546 typedef typename map_type::reference_type reference_type ;
547 typedef typename map_type::pointer_type pointer_type ;
549 enum { reference_type_is_lvalue_reference = std::is_lvalue_reference< reference_type >::value };
551 KOKKOS_INLINE_FUNCTION constexpr
size_t span()
const {
return m_map.span(); }
552 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
554 KOKKOS_INLINE_FUNCTION constexpr
size_t capacity()
const {
return m_map.span(); }
556 KOKKOS_INLINE_FUNCTION constexpr
bool span_is_contiguous()
const {
return m_map.span_is_contiguous(); }
557 KOKKOS_INLINE_FUNCTION constexpr pointer_type data()
const {
return m_map.data(); }
559 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
561 KOKKOS_INLINE_FUNCTION constexpr
bool is_contiguous()
const {
return m_map.span_is_contiguous(); }
563 KOKKOS_INLINE_FUNCTION constexpr pointer_type ptr_on_device()
const {
return m_map.data(); }
568 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
569 KOKKOS_INLINE_FUNCTION
570 const Kokkos::Impl::ViewMapping< traits , typename traits::specialize > &
571 implementation_map()
const {
return m_map ; }
573 KOKKOS_INLINE_FUNCTION
574 const Kokkos::Impl::ViewMapping< traits , typename traits::specialize > &
575 impl_map()
const {
return m_map ; }
582 is_layout_left = std::is_same<
typename traits::array_layout
585 is_layout_right = std::is_same<
typename traits::array_layout
588 is_layout_stride = std::is_same<
typename traits::array_layout
592 std::is_same< typename traits::specialize , void >::value &&
593 ( is_layout_left || is_layout_right || is_layout_stride )
596 template< class Space , bool = Kokkos::Impl::MemorySpaceAccess< Space , typename traits::memory_space >::accessible >
struct verify_space
597 { KOKKOS_FORCEINLINE_FUNCTION
static void check() {} };
599 template<
class Space >
struct verify_space<Space,false>
600 { KOKKOS_FORCEINLINE_FUNCTION
static void check()
601 { Kokkos::abort(
"Kokkos::DynRankView ERROR: attempt to access inaccessible memory space"); };
605 #if defined( KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK )
608 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( ARG ) \
609 DynRankView::template verify_space< Kokkos::Impl::ActiveExecutionMemorySpace >::check(); \
610 Kokkos::Impl::dyn_rank_view_verify_operator_bounds< typename traits::memory_space > ARG ;
614 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( ARG ) \
615 DynRankView::template verify_space< Kokkos::Impl::ActiveExecutionMemorySpace >::check();
621 KOKKOS_INLINE_FUNCTION
622 constexpr
unsigned rank()
const {
return m_rank; }
627 KOKKOS_INLINE_FUNCTION
628 reference_type operator()()
const
630 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (0 , this->
rank(), m_track, m_map) )
631 return impl_map().reference();
637 template< typename iType >
638 KOKKOS_INLINE_FUNCTION
639 typename std::enable_if< std::is_same<typename drvtraits::value_type, typename drvtraits::scalar_array_type>::value && std::is_integral<iType>::value, reference_type>::type
640 operator[](const iType & i0)
const
649 template<
typename iType >
650 KOKKOS_INLINE_FUNCTION
651 typename std::enable_if< !std::is_same<typename drvtraits::value_type, typename drvtraits::scalar_array_type>::value && std::is_integral<iType>::value, reference_type>::type
652 operator[](
const iType & i0)
const
655 const size_t dim_scalar = m_map.dimension_scalar();
656 const size_t bytes = this->span() / dim_scalar;
659 tmp_view_type rankone_view(this->data(), bytes, dim_scalar);
660 return rankone_view(i0);
664 template<
typename iType >
665 KOKKOS_INLINE_FUNCTION
666 typename std::enable_if< (std::is_same<typename traits::specialize , void>::value && std::is_integral<iType>::value), reference_type>::type
667 operator()(
const iType & i0 )
const
669 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (1 , this->
rank(), m_track, m_map, i0) )
670 return m_map.reference(i0);
673 template< typename iType >
674 KOKKOS_INLINE_FUNCTION
675 typename std::enable_if< !(std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType>::value), reference_type>::type
676 operator()(const iType & i0 )
const
678 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (1 , this->
rank(), m_track, m_map, i0) )
679 return m_map.reference(i0,0,0,0,0,0,0);
683 template< typename iType0 , typename iType1 >
684 KOKKOS_INLINE_FUNCTION
685 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value), reference_type>::type
686 operator()(const iType0 & i0 , const iType1 & i1 )
const
688 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (2 , this->
rank(), m_track, m_map, i0, i1) )
689 return m_map.reference(i0,i1);
692 template< typename iType0 , typename iType1 >
693 KOKKOS_INLINE_FUNCTION
694 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
695 operator()(const iType0 & i0 , const iType1 & i1 )
const
697 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (2 , this->
rank(), m_track, m_map, i0, i1) )
698 return m_map.reference(i0,i1,0,0,0,0,0);
702 template< typename iType0 , typename iType1 , typename iType2 >
703 KOKKOS_INLINE_FUNCTION
704 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value), reference_type>::type
705 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 )
const
707 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (3 , this->
rank(), m_track, m_map, i0, i1, i2) )
708 return m_map.reference(i0,i1,i2);
711 template< typename iType0 , typename iType1 , typename iType2 >
712 KOKKOS_INLINE_FUNCTION
713 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
714 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 )
const
716 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (3 , this->
rank(), m_track, m_map, i0, i1, i2) )
717 return m_map.reference(i0,i1,i2,0,0,0,0);
721 template< typename iType0 , typename iType1 , typename iType2 , typename iType3 >
722 KOKKOS_INLINE_FUNCTION
723 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value && std::is_integral<iType3>::value), reference_type>::type
724 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 )
const
726 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (4 , this->
rank(), m_track, m_map, i0, i1, i2, i3) )
727 return m_map.reference(i0,i1,i2,i3);
730 template< typename iType0 , typename iType1 , typename iType2 , typename iType3 >
731 KOKKOS_INLINE_FUNCTION
732 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
733 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 )
const
735 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (4 , this->
rank(), m_track, m_map, i0, i1, i2, i3) )
736 return m_map.reference(i0,i1,i2,i3,0,0,0);
740 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 >
741 KOKKOS_INLINE_FUNCTION
742 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value && std::is_integral<iType3>::value && std::is_integral<iType4>::value), reference_type>::type
743 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 )
const
745 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (5 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4) )
746 return m_map.reference(i0,i1,i2,i3,i4);
749 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 >
750 KOKKOS_INLINE_FUNCTION
751 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
752 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 )
const
754 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (5 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4) )
755 return m_map.reference(i0,i1,i2,i3,i4,0,0);
759 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 , typename iType5 >
760 KOKKOS_INLINE_FUNCTION
761 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value && std::is_integral<iType3>::value && std::is_integral<iType4>::value && std::is_integral<iType5>::value), reference_type>::type
762 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 , const iType5 & i5 )
const
764 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (6 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5) )
765 return m_map.reference(i0,i1,i2,i3,i4,i5);
768 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 , typename iType5 >
769 KOKKOS_INLINE_FUNCTION
770 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
771 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 , const iType5 & i5 )
const
773 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (6 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5) )
774 return m_map.reference(i0,i1,i2,i3,i4,i5,0);
778 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 , typename iType5 , typename iType6 >
779 KOKKOS_INLINE_FUNCTION
780 typename std::enable_if< (std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value && std::is_integral<iType3>::value && std::is_integral<iType4>::value && std::is_integral<iType5>::value && std::is_integral<iType6>::value), reference_type>::type
781 operator()(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 , const iType5 & i5 , const iType6 & i6 )
const
783 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (7 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5, i6) )
784 return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
788 KOKKOS_INLINE_FUNCTION
789 reference_type access()
const
791 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (0 , this->
rank(), m_track, m_map) )
792 return impl_map().reference();
798 template< typename iType >
799 KOKKOS_INLINE_FUNCTION
800 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType>::value), reference_type>::type
801 access(const iType & i0 )
const
803 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (1 , this->
rank(), m_track, m_map, i0) )
804 return m_map.reference(i0);
807 template< typename iType >
808 KOKKOS_INLINE_FUNCTION
809 typename std::enable_if< !(std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType>::value), reference_type>::type
810 access(const iType & i0 )
const
812 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (1 , this->
rank(), m_track, m_map, i0) )
813 return m_map.reference(i0,0,0,0,0,0,0);
817 template< typename iType0 , typename iType1 >
818 KOKKOS_INLINE_FUNCTION
819 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value), reference_type>::type
820 access(const iType0 & i0 , const iType1 & i1 )
const
822 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (2 , this->
rank(), m_track, m_map, i0, i1) )
823 return m_map.reference(i0,i1);
826 template< typename iType0 , typename iType1 >
827 KOKKOS_INLINE_FUNCTION
828 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
829 access(const iType0 & i0 , const iType1 & i1 )
const
831 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (2 , this->
rank(), m_track, m_map, i0, i1) )
832 return m_map.reference(i0,i1,0,0,0,0,0);
836 template< typename iType0 , typename iType1 , typename iType2 >
837 KOKKOS_INLINE_FUNCTION
838 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value), reference_type>::type
839 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 )
const
841 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (3 , this->
rank(), m_track, m_map, i0, i1, i2) )
842 return m_map.reference(i0,i1,i2);
845 template< typename iType0 , typename iType1 , typename iType2 >
846 KOKKOS_INLINE_FUNCTION
847 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
848 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 )
const
850 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (3 , this->
rank(), m_track, m_map, i0, i1, i2) )
851 return m_map.reference(i0,i1,i2,0,0,0,0);
855 template< typename iType0 , typename iType1 , typename iType2 , typename iType3 >
856 KOKKOS_INLINE_FUNCTION
857 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value && std::is_integral<iType3>::value), reference_type>::type
858 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 )
const
860 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (4 , this->
rank(), m_track, m_map, i0, i1, i2, i3) )
861 return m_map.reference(i0,i1,i2,i3);
864 template< typename iType0 , typename iType1 , typename iType2 , typename iType3 >
865 KOKKOS_INLINE_FUNCTION
866 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
867 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 )
const
869 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (4 , this->
rank(), m_track, m_map, i0, i1, i2, i3) )
870 return m_map.reference(i0,i1,i2,i3,0,0,0);
874 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 >
875 KOKKOS_INLINE_FUNCTION
876 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value && std::is_integral<iType3>::value && std::is_integral<iType4>::value), reference_type>::type
877 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 )
const
879 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (5 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4) )
880 return m_map.reference(i0,i1,i2,i3,i4);
883 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 >
884 KOKKOS_INLINE_FUNCTION
885 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
886 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 )
const
888 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (5 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4) )
889 return m_map.reference(i0,i1,i2,i3,i4,0,0);
893 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 , typename iType5 >
894 KOKKOS_INLINE_FUNCTION
895 typename std::enable_if< (std::is_same<typename traits::specialize ,
void>::value && std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value && std::is_integral<iType3>::value && std::is_integral<iType4>::value && std::is_integral<iType5>::value), reference_type>::type
896 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 , const iType5 & i5 )
const
898 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (6 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5) )
899 return m_map.reference(i0,i1,i2,i3,i4,i5);
902 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 , typename iType5 >
903 KOKKOS_INLINE_FUNCTION
904 typename std::enable_if< !(std::is_same<typename drvtraits::specialize ,
void>::value && std::is_integral<iType0>::value), reference_type>::type
905 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 , const iType5 & i5 )
const
907 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (6 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5) )
908 return m_map.reference(i0,i1,i2,i3,i4,i5,0);
912 template< typename iType0 , typename iType1 , typename iType2 , typename iType3, typename iType4 , typename iType5 , typename iType6 >
913 KOKKOS_INLINE_FUNCTION
914 typename std::enable_if< (std::is_integral<iType0>::value && std::is_integral<iType1>::value && std::is_integral<iType2>::value && std::is_integral<iType3>::value && std::is_integral<iType4>::value && std::is_integral<iType5>::value && std::is_integral<iType6>::value), reference_type>::type
915 access(const iType0 & i0 , const iType1 & i1 , const iType2 & i2 , const iType3 & i3 , const iType4 & i4 , const iType5 & i5 , const iType6 & i6 )
const
917 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (7 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5, i6) )
918 return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
921 #undef KOKKOS_IMPL_VIEW_OPERATOR_VERIFY
926 KOKKOS_INLINE_FUNCTION
929 KOKKOS_INLINE_FUNCTION
930 DynRankView() : m_track(), m_map(), m_rank() {}
932 KOKKOS_INLINE_FUNCTION
933 DynRankView(
const DynRankView & rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ), m_rank(rhs.m_rank) {}
935 KOKKOS_INLINE_FUNCTION
936 DynRankView( DynRankView && rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ), m_rank(rhs.m_rank) {}
938 KOKKOS_INLINE_FUNCTION
939 DynRankView & operator = (
const DynRankView & rhs ) { m_track = rhs.m_track; m_map = rhs.m_map; m_rank = rhs.m_rank;
return *
this; }
941 KOKKOS_INLINE_FUNCTION
942 DynRankView & operator = ( DynRankView && rhs ) { m_track = rhs.m_track; m_map = rhs.m_map; m_rank = rhs.m_rank;
return *
this; }
947 template<
class RT ,
class ... RP >
948 KOKKOS_INLINE_FUNCTION
949 DynRankView(
const DynRankView<RT,RP...> & rhs )
950 : m_track( rhs.m_track , traits::is_managed )
954 typedef typename DynRankView<RT,RP...> ::traits SrcTraits ;
955 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , typename traits::specialize > Mapping ;
956 static_assert( Mapping::is_assignable ,
"Incompatible DynRankView copy construction" );
957 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
960 template<
class RT ,
class ... RP >
961 KOKKOS_INLINE_FUNCTION
962 DynRankView & operator = (
const DynRankView<RT,RP...> & rhs )
964 typedef typename DynRankView<RT,RP...> ::traits SrcTraits ;
965 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , typename traits::specialize > Mapping ;
966 static_assert( Mapping::is_assignable ,
"Incompatible DynRankView copy construction" );
967 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
968 m_track.assign( rhs.m_track , traits::is_managed );
974 template<
class RT ,
class ... RP >
975 KOKKOS_INLINE_FUNCTION
976 DynRankView(
const View<RT,RP...> & rhs )
981 typedef typename View<RT,RP...>::traits SrcTraits ;
982 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , Kokkos::Impl::ViewToDynRankViewTag > Mapping ;
983 static_assert( Mapping::is_assignable ,
"Incompatible View to DynRankView copy construction" );
984 Mapping::assign( *
this , rhs );
987 template<
class RT ,
class ... RP >
988 KOKKOS_INLINE_FUNCTION
989 DynRankView & operator = (
const View<RT,RP...> & rhs )
991 typedef typename View<RT,RP...>::traits SrcTraits ;
992 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , Kokkos::Impl::ViewToDynRankViewTag > Mapping ;
993 static_assert( Mapping::is_assignable ,
"Incompatible View to DynRankView copy assignment" );
994 Mapping::assign( *
this , rhs );
1001 KOKKOS_INLINE_FUNCTION
1002 int use_count()
const
1003 {
return m_track.use_count(); }
1006 const std::string label()
const
1007 {
return m_track.template get_label< typename traits::memory_space >(); }
1012 template<
class ... P >
1014 DynRankView(
const Kokkos::Impl::ViewCtorProp< P ... > & arg_prop
1015 ,
typename std::enable_if< ! Kokkos::Impl::ViewCtorProp< P... >::has_pointer
1016 ,
typename traits::array_layout
1017 >::type
const & arg_layout
1021 , m_rank( Impl::DynRankDimTraits<typename traits::specialize>::template computeRank< typename traits::array_layout, P...>(arg_prop, arg_layout) )
1024 typedef Kokkos::Impl::ViewCtorProp< P ... > alloc_prop_input ;
1028 typedef Kokkos::Impl::ViewCtorProp
1030 ,
typename std::conditional
1031 < alloc_prop_input::has_label
1032 , std::integral_constant<unsigned,0>
1033 ,
typename std::string
1035 ,
typename std::conditional
1036 < alloc_prop_input::has_memory_space
1037 , std::integral_constant<unsigned,1>
1038 ,
typename traits::device_type::memory_space
1040 ,
typename std::conditional
1041 < alloc_prop_input::has_execution_space
1042 , std::integral_constant<unsigned,2>
1043 ,
typename traits::device_type::execution_space
1047 static_assert( traits::is_managed
1048 ,
"View allocation constructor requires managed memory" );
1050 if ( alloc_prop::initialize &&
1051 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
1052 ! alloc_prop::execution_space::is_initialized()
1054 ! alloc_prop::execution_space::impl_is_initialized()
1059 Kokkos::Impl::throw_runtime_exception(
"Constructing DynRankView and initializing data with uninitialized execution space");
1063 alloc_prop prop( arg_prop );
1066 #if defined( KOKKOS_ENABLE_CUDA )
1072 if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
1073 traits::device_type::memory_space::execution_space::fence();
1078 Kokkos::Impl::SharedAllocationRecord<> *
1079 record = m_map.allocate_shared( prop , Impl::DynRankDimTraits<typename traits::specialize>::template createLayout<traits, P...>(arg_prop, arg_layout) );
1082 #if defined( KOKKOS_ENABLE_CUDA )
1083 if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
1084 traits::device_type::memory_space::execution_space::fence();
1090 m_track.assign_allocated_record_to_uninitialized( record );
1095 template<
class ... P >
1096 explicit KOKKOS_INLINE_FUNCTION
1097 DynRankView(
const Kokkos::Impl::ViewCtorProp< P ... > & arg_prop
1098 ,
typename std::enable_if< Kokkos::Impl::ViewCtorProp< P... >::has_pointer
1099 ,
typename traits::array_layout
1100 >::type
const & arg_layout
1103 , m_map( arg_prop , Impl::DynRankDimTraits<typename traits::specialize>::template createLayout<traits, P...>(arg_prop, arg_layout) )
1104 , m_rank( Impl::DynRankDimTraits<typename traits::specialize>::template computeRank< typename traits::array_layout, P...>(arg_prop, arg_layout) )
1107 std::is_same< pointer_type
1108 ,
typename Impl::ViewCtorProp< P... >::pointer_type
1110 "Constructing DynRankView to wrap user memory must supply matching pointer type" );
1117 template<
class ... P >
1119 DynRankView(
const Kokkos::Impl::ViewCtorProp< P ... > & arg_prop
1120 ,
typename std::enable_if< ! Kokkos::Impl::ViewCtorProp< P... >::has_pointer
1122 >::type
const arg_N0 =KOKKOS_INVALID_INDEX
1123 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1124 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1125 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1126 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1127 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1128 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1129 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1131 : DynRankView( arg_prop
1132 , typename traits::array_layout
1133 ( arg_N0 , arg_N1 , arg_N2 , arg_N3 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1137 template<
class ... P >
1138 explicit KOKKOS_INLINE_FUNCTION
1139 DynRankView(
const Kokkos::Impl::ViewCtorProp< P ... > & arg_prop
1140 ,
typename std::enable_if< Kokkos::Impl::ViewCtorProp< P... >::has_pointer
1142 >::type
const arg_N0 =KOKKOS_INVALID_INDEX
1143 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1144 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1145 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1146 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1147 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1148 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1149 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1151 : DynRankView( arg_prop
1152 , typename traits::array_layout
1153 ( arg_N0 , arg_N1 , arg_N2 , arg_N3 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1158 template<
typename Label >
1160 DynRankView(
const Label & arg_label
1161 ,
typename std::enable_if<
1162 Kokkos::Impl::is_view_label<Label>::value ,
1163 typename traits::array_layout >::type
const & arg_layout
1165 : DynRankView( Kokkos::Impl::ViewCtorProp< std::string >( arg_label ) , arg_layout )
1169 template<
typename Label >
1171 DynRankView(
const Label & arg_label
1172 ,
typename std::enable_if<
1173 Kokkos::Impl::is_view_label<Label>::value ,
1174 const size_t >::type arg_N0 =KOKKOS_INVALID_INDEX
1175 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1176 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1177 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1178 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1179 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1180 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1181 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1183 : DynRankView( Kokkos::Impl::ViewCtorProp< std::string >( arg_label )
1184 , typename traits::array_layout
1185 ( arg_N0 , arg_N1 , arg_N2 , arg_N3 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1192 DynRankView(
const ViewAllocateWithoutInitializing & arg_prop
1193 ,
const typename traits::array_layout & arg_layout
1195 : DynRankView( Kokkos::Impl::ViewCtorProp< std::string , Kokkos::Impl::WithoutInitializing_t >( arg_prop.label , Kokkos::WithoutInitializing )
1201 DynRankView(
const ViewAllocateWithoutInitializing & arg_prop
1202 ,
const size_t arg_N0 =KOKKOS_INVALID_INDEX
1203 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1204 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1205 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1206 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1207 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1208 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1209 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1211 : DynRankView(Kokkos::Impl::ViewCtorProp< std::string , Kokkos::Impl::WithoutInitializing_t >( arg_prop.label , Kokkos::WithoutInitializing )
1212 , typename traits::array_layout(arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7)
1218 static constexpr
size_t required_allocation_size(
1219 const size_t arg_N0 = 0
1220 ,
const size_t arg_N1 = 0
1221 ,
const size_t arg_N2 = 0
1222 ,
const size_t arg_N3 = 0
1223 ,
const size_t arg_N4 = 0
1224 ,
const size_t arg_N5 = 0
1225 ,
const size_t arg_N6 = 0
1226 ,
const size_t arg_N7 = 0
1229 return map_type::memory_span(
1230 typename traits::array_layout
1231 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1232 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
1235 explicit KOKKOS_INLINE_FUNCTION
1236 DynRankView( pointer_type arg_ptr
1237 ,
const size_t arg_N0 =KOKKOS_INVALID_INDEX
1238 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1239 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1240 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1241 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1242 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1243 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1244 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1246 : DynRankView( Kokkos::Impl::ViewCtorProp<pointer_type>(arg_ptr) , arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7 )
1249 explicit KOKKOS_INLINE_FUNCTION
1250 DynRankView( pointer_type arg_ptr
1251 ,
typename traits::array_layout & arg_layout
1253 : DynRankView( Kokkos::Impl::ViewCtorProp<pointer_type>(arg_ptr) , arg_layout )
1261 size_t shmem_size(
const size_t arg_N0 =KOKKOS_INVALID_INDEX ,
1262 const size_t arg_N1 =KOKKOS_INVALID_INDEX ,
1263 const size_t arg_N2 =KOKKOS_INVALID_INDEX ,
1264 const size_t arg_N3 =KOKKOS_INVALID_INDEX ,
1265 const size_t arg_N4 =KOKKOS_INVALID_INDEX ,
1266 const size_t arg_N5 =KOKKOS_INVALID_INDEX ,
1267 const size_t arg_N6 =KOKKOS_INVALID_INDEX ,
1268 const size_t arg_N7 =KOKKOS_INVALID_INDEX )
1270 const size_t num_passed_args =
1271 ( arg_N0 !=KOKKOS_INVALID_INDEX ) + ( arg_N1 !=KOKKOS_INVALID_INDEX ) + ( arg_N2 !=KOKKOS_INVALID_INDEX ) +
1272 ( arg_N3 !=KOKKOS_INVALID_INDEX ) + ( arg_N4 !=KOKKOS_INVALID_INDEX ) + ( arg_N5 !=KOKKOS_INVALID_INDEX ) +
1273 ( arg_N6 !=KOKKOS_INVALID_INDEX ) + ( arg_N7 !=KOKKOS_INVALID_INDEX );
1275 if ( std::is_same<typename traits::specialize , void>::value && num_passed_args != traits::rank_dynamic ) {
1276 Kokkos::abort(
"Kokkos::View::shmem_size() rank_dynamic != number of arguments.\n" );
1280 return map_type::memory_span(
1281 typename traits::array_layout
1282 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1283 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
1286 explicit KOKKOS_INLINE_FUNCTION
1287 DynRankView(
const typename traits::execution_space::scratch_memory_space & arg_space
1288 ,
const typename traits::array_layout & arg_layout )
1289 : DynRankView( Kokkos::Impl::ViewCtorProp<pointer_type>(
1290 reinterpret_cast<pointer_type>(
1291 arg_space.get_shmem( map_type::memory_span(
1292 Impl::DynRankDimTraits<typename traits::specialize>::createLayout( arg_layout )
1297 explicit KOKKOS_INLINE_FUNCTION
1298 DynRankView(
const typename traits::execution_space::scratch_memory_space & arg_space
1299 ,
const size_t arg_N0 =KOKKOS_INVALID_INDEX
1300 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1301 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1302 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1303 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1304 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1305 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1306 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX )
1308 : DynRankView( Kokkos::Impl::ViewCtorProp<pointer_type>(
1309 reinterpret_cast<pointer_type>(
1310 arg_space.get_shmem(
1311 map_type::memory_span(
1312 Impl::DynRankDimTraits<typename traits::specialize>::createLayout(
1313 typename traits::array_layout
1314 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1315 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) ) ) ) )
1317 , typename traits::array_layout
1318 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1319 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1326 template <
typename D ,
class ... P >
1327 KOKKOS_INLINE_FUNCTION
1328 constexpr
unsigned rank(
const DynRankView<D , P...> & DRV ) {
return DRV.rank(); }
1336 struct DynRankSubviewTag {};
1342 template<
class SrcTraits ,
class ... Args >
1344 < typename std::enable_if<(
1345 std::is_same< typename SrcTraits::specialize , void >::value
1348 std::is_same< typename SrcTraits::array_layout
1349 , Kokkos::LayoutLeft >::value ||
1350 std::is_same< typename SrcTraits::array_layout
1351 , Kokkos::LayoutRight >::value ||
1352 std::is_same< typename SrcTraits::array_layout
1353 , Kokkos::LayoutStride >::value
1355 ), Kokkos::Impl::DynRankSubviewTag >::type
1363 , R0 = bool(is_integral_extent<0,Args...>::value)
1364 , R1 = bool(is_integral_extent<1,Args...>::value)
1365 , R2 = bool(is_integral_extent<2,Args...>::value)
1366 , R3 = bool(is_integral_extent<3,Args...>::value)
1367 , R4 = bool(is_integral_extent<4,Args...>::value)
1368 , R5 = bool(is_integral_extent<5,Args...>::value)
1369 , R6 = bool(is_integral_extent<6,Args...>::value)
1372 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
1373 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
1377 typedef typename SrcTraits::value_type value_type ;
1379 typedef value_type******* data_type ;
1386 ,
typename SrcTraits::device_type
1387 ,
typename SrcTraits::memory_traits > traits_type ;
1392 ,
typename SrcTraits::device_type
1393 ,
typename SrcTraits::memory_traits > type ;
1396 template<
class MemoryTraits >
1399 static_assert( Kokkos::Impl::is_memory_traits< MemoryTraits >::value ,
"" );
1404 ,
typename SrcTraits::device_type
1405 , MemoryTraits > traits_type ;
1410 ,
typename SrcTraits::device_type
1411 , MemoryTraits > type ;
1415 typedef typename SrcTraits::dimension dimension ;
1417 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
1418 struct ExtentGenerator {
1419 KOKKOS_INLINE_FUNCTION
1420 static SubviewExtents< 7 , rank > generator (
const dimension & dim , Arg0 arg0 = Arg0(), Arg1 arg1 = Arg1(), Arg2 arg2 = Arg2(), Arg3 arg3 = Arg3(), Arg4 arg4 = Arg4(), Arg5 arg5 = Arg5(), Arg6 arg6 = Arg6() )
1422 return SubviewExtents< 7 , rank>( dim , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 );
1427 typedef Kokkos::DynRankView< value_type , array_layout , typename SrcTraits::device_type , typename SrcTraits::memory_traits > ret_type;
1429 template <
typename T ,
class ... P >
1430 KOKKOS_INLINE_FUNCTION
1431 static ret_type subview(
const unsigned src_rank , Kokkos::DynRankView< T , P...>
const & src
1435 typedef ViewMapping< traits_type, typename traits_type::specialize > DstType ;
1437 typedef typename std::conditional< (rank==0) , ViewDimension<>
1438 ,
typename std::conditional< (rank==1) , ViewDimension<0>
1439 ,
typename std::conditional< (rank==2) , ViewDimension<0,0>
1440 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0>
1441 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0>
1442 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0>
1443 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0>
1444 , ViewDimension<0,0,0,0,0,0,0>
1445 >::type >::type >::type >::type >::type >::type >::type DstDimType ;
1447 typedef ViewOffset< DstDimType , Kokkos::LayoutStride > dst_offset_type ;
1448 typedef typename DstType::handle_type dst_handle_type ;
1452 const SubviewExtents< 7 , rank > extents =
1453 ExtentGenerator< Args ... >::generator( src.m_map.m_impl_offset.m_dim , args... ) ;
1455 dst_offset_type tempdst( src.m_map.m_impl_offset , extents ) ;
1457 dst.m_track = src.m_track ;
1459 dst.m_map.m_impl_offset.m_dim.N0 = tempdst.m_dim.N0 ;
1460 dst.m_map.m_impl_offset.m_dim.N1 = tempdst.m_dim.N1 ;
1461 dst.m_map.m_impl_offset.m_dim.N2 = tempdst.m_dim.N2 ;
1462 dst.m_map.m_impl_offset.m_dim.N3 = tempdst.m_dim.N3 ;
1463 dst.m_map.m_impl_offset.m_dim.N4 = tempdst.m_dim.N4 ;
1464 dst.m_map.m_impl_offset.m_dim.N5 = tempdst.m_dim.N5 ;
1465 dst.m_map.m_impl_offset.m_dim.N6 = tempdst.m_dim.N6 ;
1467 dst.m_map.m_impl_offset.m_stride.S0 = tempdst.m_stride.S0 ;
1468 dst.m_map.m_impl_offset.m_stride.S1 = tempdst.m_stride.S1 ;
1469 dst.m_map.m_impl_offset.m_stride.S2 = tempdst.m_stride.S2 ;
1470 dst.m_map.m_impl_offset.m_stride.S3 = tempdst.m_stride.S3 ;
1471 dst.m_map.m_impl_offset.m_stride.S4 = tempdst.m_stride.S4 ;
1472 dst.m_map.m_impl_offset.m_stride.S5 = tempdst.m_stride.S5 ;
1473 dst.m_map.m_impl_offset.m_stride.S6 = tempdst.m_stride.S6 ;
1475 dst.m_map.m_impl_handle = dst_handle_type( src.m_map.m_impl_handle +
1476 src.m_map.m_impl_offset( extents.domain_offset(0)
1477 , extents.domain_offset(1)
1478 , extents.domain_offset(2)
1479 , extents.domain_offset(3)
1480 , extents.domain_offset(4)
1481 , extents.domain_offset(5)
1482 , extents.domain_offset(6)
1485 dst.m_rank = ( src_rank > 0 ? unsigned(R0) : 0 )
1486 + ( src_rank > 1 ? unsigned(R1) : 0 )
1487 + ( src_rank > 2 ? unsigned(R2) : 0 )
1488 + ( src_rank > 3 ? unsigned(R3) : 0 )
1489 + ( src_rank > 4 ? unsigned(R4) : 0 )
1490 + ( src_rank > 5 ? unsigned(R5) : 0 )
1491 + ( src_rank > 6 ? unsigned(R6) : 0 ) ;
1500 template<
class V ,
class ... Args >
1501 using Subdynrankview =
typename Kokkos::Impl::ViewMapping< Kokkos::Impl::DynRankSubviewTag , V , Args... >::ret_type ;
1503 template<
class D ,
class ... P ,
class ...Args >
1504 KOKKOS_INLINE_FUNCTION
1505 Subdynrankview< ViewTraits<D******* , P...> , Args... >
1506 subdynrankview(
const Kokkos::DynRankView< D , P... > &src , Args...args)
1508 if ( src.rank() >
sizeof...(Args) )
1509 { Kokkos::abort(
"subdynrankview: num of args must be >= rank of the source DynRankView"); }
1511 typedef Kokkos::Impl::ViewMapping< Kokkos::Impl::DynRankSubviewTag ,
Kokkos::ViewTraits< D*******, P... > , Args... > metafcn ;
1513 return metafcn::subview( src.rank() , src , args... );
1517 template<
class D ,
class ... P ,
class ...Args >
1518 KOKKOS_INLINE_FUNCTION
1519 Subdynrankview< ViewTraits<D******* , P...> , Args... >
1520 subview(
const Kokkos::DynRankView< D , P... > &src , Args...args)
1522 return subdynrankview( src , args... );
1530 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
1531 KOKKOS_INLINE_FUNCTION
1532 bool operator == (
const DynRankView<LT,LP...> & lhs ,
1533 const DynRankView<RT,RP...> & rhs )
1536 typedef ViewTraits<LT,LP...> lhs_traits ;
1537 typedef ViewTraits<RT,RP...> rhs_traits ;
1540 std::is_same<
typename lhs_traits::const_value_type ,
1541 typename rhs_traits::const_value_type >::value &&
1542 std::is_same<
typename lhs_traits::array_layout ,
1543 typename rhs_traits::array_layout >::value &&
1544 std::is_same<
typename lhs_traits::memory_space ,
1545 typename rhs_traits::memory_space >::value &&
1546 lhs.rank() == rhs.rank() &&
1547 lhs.data() == rhs.data() &&
1548 lhs.span() == rhs.span() &&
1549 lhs.extent(0) == rhs.extent(0) &&
1550 lhs.extent(1) == rhs.extent(1) &&
1551 lhs.extent(2) == rhs.extent(2) &&
1552 lhs.extent(3) == rhs.extent(3) &&
1553 lhs.extent(4) == rhs.extent(4) &&
1554 lhs.extent(5) == rhs.extent(5) &&
1555 lhs.extent(6) == rhs.extent(6) &&
1556 lhs.extent(7) == rhs.extent(7);
1559 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
1560 KOKKOS_INLINE_FUNCTION
1561 bool operator != (
const DynRankView<LT,LP...> & lhs ,
1562 const DynRankView<RT,RP...> & rhs )
1574 template<
class OutputView ,
typename Enable =
void >
1575 struct DynRankViewFill {
1577 typedef typename OutputView::traits::const_value_type const_value_type ;
1579 const OutputView output ;
1580 const_value_type input ;
1582 KOKKOS_INLINE_FUNCTION
1583 void operator()(
const size_t i0 )
const
1585 const size_t n1 = output.extent(1);
1586 const size_t n2 = output.extent(2);
1587 const size_t n3 = output.extent(3);
1588 const size_t n4 = output.extent(4);
1589 const size_t n5 = output.extent(5);
1590 const size_t n6 = output.extent(6);
1592 for (
size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1593 for (
size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1594 for (
size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1595 for (
size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1596 for (
size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1597 for (
size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1598 output.access(i0,i1,i2,i3,i4,i5,i6) = input ;
1602 DynRankViewFill(
const OutputView & arg_out , const_value_type & arg_in )
1603 : output( arg_out ), input( arg_in )
1605 typedef typename OutputView::execution_space execution_space ;
1612 execution_space::fence();
1616 template<
class OutputView >
1617 struct DynRankViewFill< OutputView , typename std::enable_if< OutputView::Rank == 0 >::type > {
1618 DynRankViewFill(
const OutputView & dst ,
const typename OutputView::const_value_type & src )
1620 Kokkos::Impl::DeepCopy< typename OutputView::memory_space , Kokkos::HostSpace >
1621 ( dst.data() , & src ,
sizeof(
typename OutputView::const_value_type) );
1625 template<
class OutputView ,
class InputView ,
class ExecSpace =
typename OutputView::execution_space >
1626 struct DynRankViewRemap {
1628 const OutputView output ;
1629 const InputView input ;
1639 DynRankViewRemap(
const OutputView & arg_out ,
const InputView & arg_in )
1640 : output( arg_out ), input( arg_in )
1641 , n0( std::min( (size_t)arg_out.extent(0) , (size_t)arg_in.extent(0) ) )
1642 , n1( std::min( (size_t)arg_out.extent(1) , (size_t)arg_in.extent(1) ) )
1643 , n2( std::min( (size_t)arg_out.extent(2) , (size_t)arg_in.extent(2) ) )
1644 , n3( std::min( (size_t)arg_out.extent(3) , (size_t)arg_in.extent(3) ) )
1645 , n4( std::min( (size_t)arg_out.extent(4) , (size_t)arg_in.extent(4) ) )
1646 , n5( std::min( (size_t)arg_out.extent(5) , (size_t)arg_in.extent(5) ) )
1647 , n6( std::min( (size_t)arg_out.extent(6) , (size_t)arg_in.extent(6) ) )
1648 , n7( std::min( (size_t)arg_out.extent(7) , (size_t)arg_in.extent(7) ) )
1655 KOKKOS_INLINE_FUNCTION
1656 void operator()(
const size_t i0 )
const
1658 for (
size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1659 for (
size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1660 for (
size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1661 for (
size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1662 for (
size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1663 for (
size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1664 output.access(i0,i1,i2,i3,i4,i5,i6) = input.access(i0,i1,i2,i3,i4,i5,i6);
1676 template<
class DT ,
class ... DP >
1679 (
const DynRankView<DT,DP...> & dst
1680 ,
typename ViewTraits<DT,DP...>::const_value_type & value
1681 ,
typename std::enable_if<
1682 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value
1686 std::is_same<
typename ViewTraits<DT,DP...>::non_const_value_type ,
1687 typename ViewTraits<DT,DP...>::value_type >::value
1688 ,
"deep_copy requires non-const type" );
1690 Kokkos::Impl::DynRankViewFill< DynRankView<DT,DP...> >( dst , value );
1694 template<
class ST ,
class ... SP >
1697 (
typename ViewTraits<ST,SP...>::non_const_value_type & dst
1698 ,
const DynRankView<ST,SP...> & src
1699 ,
typename std::enable_if<
1700 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value
1703 if ( src.rank() != 0 )
1709 typedef typename src_traits::memory_space src_memory_space ;
1710 Kokkos::Impl::DeepCopy< HostSpace , src_memory_space >( & dst , src.data() ,
sizeof(ST) );
1717 template<
class DstType ,
class SrcType >
1720 (
const DstType & dst
1721 ,
const SrcType & src
1722 ,
typename std::enable_if<(
1723 std::is_same< typename DstType::traits::specialize , void >::value &&
1724 std::is_same< typename SrcType::traits::specialize , void >::value
1726 ( Kokkos::is_dyn_rank_view<DstType>::value || Kokkos::is_dyn_rank_view<SrcType>::value)
1730 std::is_same<
typename DstType::traits::value_type ,
1731 typename DstType::traits::non_const_value_type >::value
1732 ,
"deep_copy requires non-const destination type" );
1734 typedef DstType dst_type ;
1735 typedef SrcType src_type ;
1737 typedef typename dst_type::execution_space dst_execution_space ;
1738 typedef typename src_type::execution_space src_execution_space ;
1739 typedef typename dst_type::memory_space dst_memory_space ;
1740 typedef typename src_type::memory_space src_memory_space ;
1742 enum { DstExecCanAccessSrc =
1745 enum { SrcExecCanAccessDst =
1748 if ( (
void *) dst.data() != (
void*) src.data() ) {
1754 if (
rank(src) == 0 &&
rank(dst) == 0 )
1756 typedef typename dst_type::value_type value_type ;
1757 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() ,
sizeof(value_type) );
1759 else if ( std::is_same<
typename DstType::traits::value_type ,
1760 typename SrcType::traits::non_const_value_type >::value &&
1762 ( std::is_same<
typename DstType::traits::array_layout ,
1763 typename SrcType::traits::array_layout >::value
1765 ( std::is_same<
typename DstType::traits::array_layout ,
1768 std::is_same<
typename DstType::traits::array_layout ,
1779 dst.span_is_contiguous() &&
1780 src.span_is_contiguous() &&
1781 dst.span() == src.span() &&
1782 dst.extent(0) == src.extent(0) &&
1784 dst.extent(1) == src.extent(1) &&
1785 dst.extent(2) == src.extent(2) &&
1786 dst.extent(3) == src.extent(3) &&
1787 dst.extent(4) == src.extent(4) &&
1788 dst.extent(5) == src.extent(5) &&
1789 dst.extent(6) == src.extent(6) &&
1790 dst.extent(7) == src.extent(7) ) {
1792 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1794 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
1796 else if ( std::is_same<
typename DstType::traits::value_type ,
1797 typename SrcType::traits::non_const_value_type >::value &&
1799 ( std::is_same<
typename DstType::traits::array_layout ,
1800 typename SrcType::traits::array_layout >::value
1802 std::is_same<
typename DstType::traits::array_layout ,
1812 dst.span_is_contiguous() &&
1813 src.span_is_contiguous() &&
1814 dst.span() == src.span() &&
1815 dst.extent(0) == src.extent(0) &&
1816 dst.extent(1) == src.extent(1) &&
1817 dst.extent(2) == src.extent(2) &&
1818 dst.extent(3) == src.extent(3) &&
1819 dst.extent(4) == src.extent(4) &&
1820 dst.extent(5) == src.extent(5) &&
1821 dst.extent(6) == src.extent(6) &&
1822 dst.extent(7) == src.extent(7) &&
1823 dst.stride_0() == src.stride_0() &&
1824 dst.stride_1() == src.stride_1() &&
1825 dst.stride_2() == src.stride_2() &&
1826 dst.stride_3() == src.stride_3() &&
1827 dst.stride_4() == src.stride_4() &&
1828 dst.stride_5() == src.stride_5() &&
1829 dst.stride_6() == src.stride_6() &&
1830 dst.stride_7() == src.stride_7()
1833 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1835 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
1837 else if ( DstExecCanAccessSrc ) {
1839 Kokkos::Impl::DynRankViewRemap< dst_type , src_type >( dst , src );
1841 else if ( SrcExecCanAccessDst ) {
1843 Kokkos::Impl::DynRankViewRemap< dst_type , src_type , src_execution_space >( dst , src );
1846 Kokkos::Impl::throw_runtime_exception(
"deep_copy given views that would require a temporary allocation");
1862 template<
class Space,
class T,
class ... P>
1863 struct MirrorDRViewType {
1865 typedef typename Kokkos::DynRankView<T,P...> src_view_type;
1867 typedef typename Space::memory_space memory_space;
1869 enum { is_same_memspace = std::is_same<memory_space,typename src_view_type::memory_space>::value };
1871 typedef typename src_view_type::array_layout array_layout;
1873 typedef typename src_view_type::non_const_data_type data_type;
1875 typedef Kokkos::DynRankView<data_type,array_layout,Space> dest_view_type;
1878 typedef typename std::conditional<is_same_memspace,src_view_type,dest_view_type>::type view_type;
1881 template<
class Space,
class T,
class ... P>
1882 struct MirrorDRVType {
1884 typedef typename Kokkos::DynRankView<T,P...> src_view_type;
1886 typedef typename Space::memory_space memory_space;
1888 enum { is_same_memspace = std::is_same<memory_space,typename src_view_type::memory_space>::value };
1890 typedef typename src_view_type::array_layout array_layout;
1892 typedef typename src_view_type::non_const_data_type data_type;
1894 typedef Kokkos::DynRankView<data_type,array_layout,Space> view_type;
1899 template<
class T ,
class ... P >
1901 typename DynRankView<T,P...>::HostMirror
1902 create_mirror(
const DynRankView<T,P...> & src
1903 ,
typename std::enable_if<
1904 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value &&
1905 ! std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
1910 typedef DynRankView<T,P...> src_type ;
1911 typedef typename src_type::HostMirror dst_type ;
1913 return dst_type( std::string( src.label() ).append(
"_mirror")
1914 , Impl::reconstructLayout(src.layout(), src.rank()) );
1918 template<
class T ,
class ... P >
1920 typename DynRankView<T,P...>::HostMirror
1921 create_mirror(
const DynRankView<T,P...> & src
1922 ,
typename std::enable_if<
1923 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value &&
1924 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
1929 typedef DynRankView<T,P...> src_type ;
1930 typedef typename src_type::HostMirror dst_type ;
1932 return dst_type( std::string( src.label() ).append(
"_mirror")
1933 , Impl::reconstructLayout(src.layout(), src.rank()) );
1938 template<
class Space,
class T,
class ... P>
1939 typename Impl::MirrorDRVType<Space,T,P ...>::view_type
1940 create_mirror(
const Space& ,
const Kokkos::DynRankView<T,P...> & src
1941 ,
typename std::enable_if<
1942 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value
1944 return typename Impl::MirrorDRVType<Space,T,P ...>::view_type(src.label(), Impl::reconstructLayout(src.layout(), src.rank()) );
1947 template<
class T ,
class ... P >
1949 typename DynRankView<T,P...>::HostMirror
1950 create_mirror_view(
const DynRankView<T,P...> & src
1951 ,
typename std::enable_if<(
1952 std::is_same<
typename DynRankView<T,P...>::memory_space
1953 ,
typename DynRankView<T,P...>::HostMirror::memory_space
1956 std::is_same<
typename DynRankView<T,P...>::data_type
1957 ,
typename DynRankView<T,P...>::HostMirror::data_type
1965 template<
class T ,
class ... P >
1967 typename DynRankView<T,P...>::HostMirror
1968 create_mirror_view(
const DynRankView<T,P...> & src
1969 ,
typename std::enable_if< ! (
1970 std::is_same<
typename DynRankView<T,P...>::memory_space
1971 ,
typename DynRankView<T,P...>::HostMirror::memory_space
1974 std::is_same<
typename DynRankView<T,P...>::data_type
1975 ,
typename DynRankView<T,P...>::HostMirror::data_type
1980 return Kokkos::create_mirror( src );
1984 template<
class Space,
class T,
class ... P>
1985 typename Impl::MirrorDRViewType<Space,T,P ...>::view_type
1986 create_mirror_view(
const Space& ,
const Kokkos::DynRankView<T,P...> & src
1987 ,
typename std::enable_if<Impl::MirrorDRViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
1992 template<
class Space,
class T,
class ... P>
1993 typename Impl::MirrorDRViewType<Space,T,P ...>::view_type
1994 create_mirror_view(
const Space& ,
const Kokkos::DynRankView<T,P...> & src
1995 ,
typename std::enable_if<!Impl::MirrorDRViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
1996 return typename Impl::MirrorDRViewType<Space,T,P ...>::view_type(src.label(), Impl::reconstructLayout(src.layout(), src.rank()) );
2000 template<
class Space,
class T,
class ... P>
2001 typename Impl::MirrorDRViewType<Space,T,P ...>::view_type
2002 create_mirror_view_and_copy(
const Space& ,
const Kokkos::DynRankView<T,P...> & src
2003 , std::string
const& name =
""
2004 ,
typename std::enable_if<Impl::MirrorDRViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
2010 template<
class Space,
class T,
class ... P>
2011 typename Impl::MirrorDRViewType<Space,T,P ...>::view_type
2012 create_mirror_view_and_copy(
const Space& ,
const Kokkos::DynRankView<T,P...> & src
2013 , std::string
const& name =
""
2014 ,
typename std::enable_if<!Impl::MirrorDRViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
2015 using Mirror =
typename Impl::MirrorDRViewType<Space,T,P ...>::view_type;
2016 std::string label = name.empty() ? src.label() : name;
2017 auto mirror = Mirror( Kokkos::ViewAllocateWithoutInitializing(label), Impl::reconstructLayout(src.layout(), src.rank()) );
2030 template<
class T ,
class ... P >
2033 const size_t n0 =KOKKOS_INVALID_INDEX ,
2034 const size_t n1 =KOKKOS_INVALID_INDEX ,
2035 const size_t n2 =KOKKOS_INVALID_INDEX ,
2036 const size_t n3 =KOKKOS_INVALID_INDEX ,
2037 const size_t n4 =KOKKOS_INVALID_INDEX ,
2038 const size_t n5 =KOKKOS_INVALID_INDEX ,
2039 const size_t n6 =KOKKOS_INVALID_INDEX ,
2040 const size_t n7 =KOKKOS_INVALID_INDEX )
2042 typedef DynRankView<T,P...> drview_type ;
2046 drview_type v_resized( v.label(), n0, n1, n2, n3, n4, n5, n6 );
2048 Kokkos::Impl::DynRankViewRemap< drview_type , drview_type >( v_resized, v );
2054 template<
class T ,
class ... P >
2057 const size_t n0 =KOKKOS_INVALID_INDEX ,
2058 const size_t n1 =KOKKOS_INVALID_INDEX ,
2059 const size_t n2 =KOKKOS_INVALID_INDEX ,
2060 const size_t n3 =KOKKOS_INVALID_INDEX ,
2061 const size_t n4 =KOKKOS_INVALID_INDEX ,
2062 const size_t n5 =KOKKOS_INVALID_INDEX ,
2063 const size_t n6 =KOKKOS_INVALID_INDEX ,
2064 const size_t n7 =KOKKOS_INVALID_INDEX )
2066 typedef DynRankView<T,P...> drview_type ;
2070 const std::string label = v.label();
2073 v = drview_type( label, n0, n1, n2, n3, n4, n5, n6 );
KOKKOS_INLINE_FUNCTION bool operator==(const complex< RealType1 > &x, const complex< RealType2 > &y)
Equality operator for two complex numbers.
KOKKOS_INLINE_FUNCTION bool operator!=(const complex< RealType1 > &x, const complex< RealType2 > &y)
Inequality operator for two complex numbers.
Memory layout tag indicating left-to-right (Fortran scheme) striding of multi-indices.
Can AccessSpace access MemorySpace ?
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=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n1=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n2=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n3=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n4=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n5=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n6=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n7=KOKKOS_IMPL_CTOR_DEFAULT_ARG)
Resize a view with copying old data to new data at the corresponding indices.
Memory layout tag indicated arbitrarily strided multi-index mapping into contiguous memory...
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.
View to an array of data.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
Assign compatible default mappings.
Implementation of the ParallelFor operator that has a partial specialization for the device...
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=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n1=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n2=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n3=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n4=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n5=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n6=KOKKOS_IMPL_CTOR_DEFAULT_ARG, const size_t n7=KOKKOS_IMPL_CTOR_DEFAULT_ARG)
Resize a view with discarding old data.
Execution policy for work over a range of an integral type.
KOKKOS_INLINE_FUNCTION constexpr unsigned rank(const View< D, P...> &V)
Temporary free function rank() until rank() is implemented in the View.
Traits class for accessing attributes of a View.