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
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
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 , void > DstType ;
372 typedef ViewMapping< SrcTraits , void > 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_offset = dst_offset_type(std::integral_constant<unsigned,0>() , src.layout() );
388 dst.m_map.m_handle = Kokkos::Impl::ViewDataHandle< DstTraits >::assign( src.m_map.m_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 , void > 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(); }
569 KOKKOS_INLINE_FUNCTION
570 const Kokkos::Impl::ViewMapping< traits , void > &
571 implementation_map()
const {
return m_map ; }
578 is_layout_left = std::is_same<
typename traits::array_layout
581 is_layout_right = std::is_same<
typename traits::array_layout
584 is_layout_stride = std::is_same<
typename traits::array_layout
588 std::is_same< typename traits::specialize , void >::value &&
589 ( is_layout_left || is_layout_right || is_layout_stride )
592 template< class Space , bool = Kokkos::Impl::MemorySpaceAccess< Space , typename traits::memory_space >::accessible >
struct verify_space
593 { KOKKOS_FORCEINLINE_FUNCTION
static void check() {} };
595 template<
class Space >
struct verify_space<Space,false>
596 { KOKKOS_FORCEINLINE_FUNCTION
static void check()
597 { Kokkos::abort(
"Kokkos::DynRankView ERROR: attempt to access inaccessible memory space"); };
601 #if defined( KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK ) 604 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( ARG ) \ 605 DynRankView::template verify_space< Kokkos::Impl::ActiveExecutionMemorySpace >::check(); \ 606 Kokkos::Impl::dyn_rank_view_verify_operator_bounds< typename traits::memory_space > ARG ; 610 #define KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( ARG ) \ 611 DynRankView::template verify_space< Kokkos::Impl::ActiveExecutionMemorySpace >::check(); 617 KOKKOS_INLINE_FUNCTION
618 constexpr
unsigned rank()
const {
return m_rank; }
623 KOKKOS_INLINE_FUNCTION
624 reference_type operator()()
const 626 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (0 , this->
rank(), m_track, m_map) )
627 return implementation_map().reference();
633 template<
typename iType >
634 KOKKOS_INLINE_FUNCTION
635 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
636 operator[](
const iType & i0)
const 645 template<
typename iType >
646 KOKKOS_INLINE_FUNCTION
647 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
648 operator[](
const iType & i0)
const 651 const size_t dim_scalar = m_map.dimension_scalar();
652 const size_t bytes = this->span() / dim_scalar;
655 tmp_view_type rankone_view(this->data(), bytes, dim_scalar);
656 return rankone_view(i0);
660 template<
typename iType >
661 KOKKOS_INLINE_FUNCTION
662 typename std::enable_if< (std::is_same<typename traits::specialize , void>::value && std::is_integral<iType>::value), reference_type>::type
663 operator()(
const iType & i0 )
const 665 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (1 , this->
rank(), m_track, m_map, i0) )
666 return m_map.reference(i0);
669 template<
typename iType >
670 KOKKOS_INLINE_FUNCTION
671 typename std::enable_if< !(std::is_same<typename traits::specialize , void>::value && std::is_integral<iType>::value), reference_type>::type
672 operator()(
const iType & i0 )
const 674 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (1 , this->
rank(), m_track, m_map, i0) )
675 return m_map.reference(i0,0,0,0,0,0,0);
679 template<
typename iType0 ,
typename iType1 >
680 KOKKOS_INLINE_FUNCTION
681 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
682 operator()(
const iType0 & i0 ,
const iType1 & i1 )
const 684 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (2 , this->
rank(), m_track, m_map, i0, i1) )
685 return m_map.reference(i0,i1);
688 template<
typename iType0 ,
typename iType1 >
689 KOKKOS_INLINE_FUNCTION
690 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
691 operator()(
const iType0 & i0 ,
const iType1 & i1 )
const 693 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (2 , this->
rank(), m_track, m_map, i0, i1) )
694 return m_map.reference(i0,i1,0,0,0,0,0);
698 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
699 KOKKOS_INLINE_FUNCTION
700 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
701 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const 703 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (3 , this->
rank(), m_track, m_map, i0, i1, i2) )
704 return m_map.reference(i0,i1,i2);
707 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
708 KOKKOS_INLINE_FUNCTION
709 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
710 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const 712 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (3 , this->
rank(), m_track, m_map, i0, i1, i2) )
713 return m_map.reference(i0,i1,i2,0,0,0,0);
717 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
718 KOKKOS_INLINE_FUNCTION
719 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
720 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const 722 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (4 , this->
rank(), m_track, m_map, i0, i1, i2, i3) )
723 return m_map.reference(i0,i1,i2,i3);
726 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
727 KOKKOS_INLINE_FUNCTION
728 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
729 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const 731 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (4 , this->
rank(), m_track, m_map, i0, i1, i2, i3) )
732 return m_map.reference(i0,i1,i2,i3,0,0,0);
736 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 >
737 KOKKOS_INLINE_FUNCTION
738 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
739 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 )
const 741 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (5 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4) )
742 return m_map.reference(i0,i1,i2,i3,i4);
745 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 >
746 KOKKOS_INLINE_FUNCTION
747 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
748 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 )
const 750 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (5 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4) )
751 return m_map.reference(i0,i1,i2,i3,i4,0,0);
755 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 ,
typename iType5 >
756 KOKKOS_INLINE_FUNCTION
757 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
758 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 )
const 760 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (6 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5) )
761 return m_map.reference(i0,i1,i2,i3,i4,i5);
764 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 ,
typename iType5 >
765 KOKKOS_INLINE_FUNCTION
766 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
767 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 )
const 769 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (6 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5) )
770 return m_map.reference(i0,i1,i2,i3,i4,i5,0);
774 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 ,
typename iType5 ,
typename iType6 >
775 KOKKOS_INLINE_FUNCTION
776 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
777 operator()(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 )
const 779 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (7 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5, i6) )
780 return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
784 KOKKOS_INLINE_FUNCTION
785 reference_type access()
const 787 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (0 , this->
rank(), m_track, m_map) )
788 return implementation_map().reference();
794 template<
typename iType >
795 KOKKOS_INLINE_FUNCTION
796 typename std::enable_if< (std::is_same<typename traits::specialize , void>::value && std::is_integral<iType>::value), reference_type>::type
797 access(
const iType & i0 )
const 799 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (1 , this->
rank(), m_track, m_map, i0) )
800 return m_map.reference(i0);
803 template<
typename iType >
804 KOKKOS_INLINE_FUNCTION
805 typename std::enable_if< !(std::is_same<typename traits::specialize , void>::value && std::is_integral<iType>::value), reference_type>::type
806 access(
const iType & i0 )
const 808 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (1 , this->
rank(), m_track, m_map, i0) )
809 return m_map.reference(i0,0,0,0,0,0,0);
813 template<
typename iType0 ,
typename iType1 >
814 KOKKOS_INLINE_FUNCTION
815 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
816 access(
const iType0 & i0 ,
const iType1 & i1 )
const 818 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (2 , this->
rank(), m_track, m_map, i0, i1) )
819 return m_map.reference(i0,i1);
822 template<
typename iType0 ,
typename iType1 >
823 KOKKOS_INLINE_FUNCTION
824 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
825 access(
const iType0 & i0 ,
const iType1 & i1 )
const 827 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (2 , this->
rank(), m_track, m_map, i0, i1) )
828 return m_map.reference(i0,i1,0,0,0,0,0);
832 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
833 KOKKOS_INLINE_FUNCTION
834 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
835 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const 837 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (3 , this->
rank(), m_track, m_map, i0, i1, i2) )
838 return m_map.reference(i0,i1,i2);
841 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
842 KOKKOS_INLINE_FUNCTION
843 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
844 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const 846 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (3 , this->
rank(), m_track, m_map, i0, i1, i2) )
847 return m_map.reference(i0,i1,i2,0,0,0,0);
851 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
852 KOKKOS_INLINE_FUNCTION
853 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
854 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const 856 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (4 , this->
rank(), m_track, m_map, i0, i1, i2, i3) )
857 return m_map.reference(i0,i1,i2,i3);
860 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
861 KOKKOS_INLINE_FUNCTION
862 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
863 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const 865 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (4 , this->
rank(), m_track, m_map, i0, i1, i2, i3) )
866 return m_map.reference(i0,i1,i2,i3,0,0,0);
870 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 >
871 KOKKOS_INLINE_FUNCTION
872 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
873 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 )
const 875 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (5 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4) )
876 return m_map.reference(i0,i1,i2,i3,i4);
879 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 >
880 KOKKOS_INLINE_FUNCTION
881 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
882 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 )
const 884 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (5 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4) )
885 return m_map.reference(i0,i1,i2,i3,i4,0,0);
889 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 ,
typename iType5 >
890 KOKKOS_INLINE_FUNCTION
891 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
892 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 )
const 894 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (6 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5) )
895 return m_map.reference(i0,i1,i2,i3,i4,i5);
898 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 ,
typename iType5 >
899 KOKKOS_INLINE_FUNCTION
900 typename std::enable_if< !(std::is_same<typename drvtraits::specialize , void>::value && std::is_integral<iType0>::value), reference_type>::type
901 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 )
const 903 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (6 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5) )
904 return m_map.reference(i0,i1,i2,i3,i4,i5,0);
908 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3,
typename iType4 ,
typename iType5 ,
typename iType6 >
909 KOKKOS_INLINE_FUNCTION
910 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
911 access(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 )
const 913 KOKKOS_IMPL_VIEW_OPERATOR_VERIFY( (7 , this->
rank(), m_track, m_map, i0, i1, i2, i3, i4, i5, i6) )
914 return m_map.reference(i0,i1,i2,i3,i4,i5,i6);
917 #undef KOKKOS_IMPL_VIEW_OPERATOR_VERIFY 922 KOKKOS_INLINE_FUNCTION
925 KOKKOS_INLINE_FUNCTION
926 DynRankView() : m_track(), m_map(), m_rank() {}
928 KOKKOS_INLINE_FUNCTION
929 DynRankView(
const DynRankView & rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ), m_rank(rhs.m_rank) {}
931 KOKKOS_INLINE_FUNCTION
932 DynRankView( DynRankView && rhs ) : m_track( rhs.m_track ), m_map( rhs.m_map ), m_rank(rhs.m_rank) {}
934 KOKKOS_INLINE_FUNCTION
935 DynRankView & operator = (
const DynRankView & rhs ) { m_track = rhs.m_track; m_map = rhs.m_map; m_rank = rhs.m_rank;
return *
this; }
937 KOKKOS_INLINE_FUNCTION
938 DynRankView & operator = ( DynRankView && rhs ) { m_track = rhs.m_track; m_map = rhs.m_map; m_rank = rhs.m_rank;
return *
this; }
943 template<
class RT ,
class ... RP >
944 KOKKOS_INLINE_FUNCTION
945 DynRankView(
const DynRankView<RT,RP...> & rhs )
946 : m_track( rhs.m_track , traits::is_managed )
950 typedef typename DynRankView<RT,RP...> ::traits SrcTraits ;
951 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
952 static_assert( Mapping::is_assignable ,
"Incompatible DynRankView copy construction" );
953 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
956 template<
class RT ,
class ... RP >
957 KOKKOS_INLINE_FUNCTION
958 DynRankView & operator = (
const DynRankView<RT,RP...> & rhs )
960 typedef typename DynRankView<RT,RP...> ::traits SrcTraits ;
961 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , void > Mapping ;
962 static_assert( Mapping::is_assignable ,
"Incompatible DynRankView copy construction" );
963 Mapping::assign( m_map , rhs.m_map , rhs.m_track );
964 m_track.assign( rhs.m_track , traits::is_managed );
970 template<
class RT ,
class ... RP >
971 KOKKOS_INLINE_FUNCTION
972 DynRankView(
const View<RT,RP...> & rhs )
977 typedef typename View<RT,RP...>::traits SrcTraits ;
978 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , Kokkos::Impl::ViewToDynRankViewTag > Mapping ;
979 static_assert( Mapping::is_assignable ,
"Incompatible DynRankView copy construction" );
980 Mapping::assign( *
this , rhs );
983 template<
class RT ,
class ... RP >
984 KOKKOS_INLINE_FUNCTION
985 DynRankView & operator = (
const View<RT,RP...> & rhs )
987 typedef typename View<RT,RP...>::traits SrcTraits ;
988 typedef Kokkos::Impl::ViewMapping< traits , SrcTraits , Kokkos::Impl::ViewToDynRankViewTag > Mapping ;
989 static_assert( Mapping::is_assignable ,
"Incompatible View to DynRankView copy assignment" );
990 Mapping::assign( *
this , rhs );
997 KOKKOS_INLINE_FUNCTION
998 int use_count()
const 999 {
return m_track.use_count(); }
1002 const std::string label()
const 1003 {
return m_track.template get_label< typename traits::memory_space >(); }
1008 template<
class ... P >
1010 DynRankView(
const Kokkos::Impl::ViewCtorProp< P ... > & arg_prop
1011 ,
typename std::enable_if< ! Kokkos::Impl::ViewCtorProp< P... >::has_pointer
1012 ,
typename traits::array_layout
1013 >::type
const & arg_layout
1017 , m_rank( Impl::DynRankDimTraits<typename traits::specialize>::template computeRank< typename traits::array_layout, P...>(arg_prop, arg_layout) )
1020 typedef Kokkos::Impl::ViewCtorProp< P ... > alloc_prop_input ;
1024 typedef Kokkos::Impl::ViewCtorProp
1026 ,
typename std::conditional
1027 < alloc_prop_input::has_label
1028 , std::integral_constant<unsigned,0>
1029 ,
typename std::string
1031 ,
typename std::conditional
1032 < alloc_prop_input::has_memory_space
1033 , std::integral_constant<unsigned,1>
1034 ,
typename traits::device_type::memory_space
1036 ,
typename std::conditional
1037 < alloc_prop_input::has_execution_space
1038 , std::integral_constant<unsigned,2>
1039 ,
typename traits::device_type::execution_space
1043 static_assert( traits::is_managed
1044 ,
"View allocation constructor requires managed memory" );
1046 if ( alloc_prop::initialize &&
1047 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE
1048 ! alloc_prop::execution_space::is_initialized()
1050 ! alloc_prop::execution_space::impl_is_initialized()
1055 Kokkos::Impl::throw_runtime_exception(
"Constructing DynRankView and initializing data with uninitialized execution space");
1059 alloc_prop prop( arg_prop );
1062 #if defined( KOKKOS_ENABLE_CUDA ) 1068 if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
1069 traits::device_type::memory_space::execution_space::fence();
1074 Kokkos::Impl::SharedAllocationRecord<> *
1075 record = m_map.allocate_shared( prop , Impl::DynRankDimTraits<typename traits::specialize>::template createLayout<traits, P...>(arg_prop, arg_layout) );
1078 #if defined( KOKKOS_ENABLE_CUDA ) 1079 if ( std::is_same< Kokkos::CudaUVMSpace , typename traits::device_type::memory_space >::value ) {
1080 traits::device_type::memory_space::execution_space::fence();
1086 m_track.assign_allocated_record_to_uninitialized( record );
1091 template<
class ... P >
1092 explicit KOKKOS_INLINE_FUNCTION
1093 DynRankView(
const Kokkos::Impl::ViewCtorProp< P ... > & arg_prop
1094 ,
typename std::enable_if< Kokkos::Impl::ViewCtorProp< P... >::has_pointer
1095 ,
typename traits::array_layout
1096 >::type
const & arg_layout
1099 , m_map( arg_prop , Impl::DynRankDimTraits<typename traits::specialize>::template createLayout<traits, P...>(arg_prop, arg_layout) )
1100 , m_rank( Impl::DynRankDimTraits<typename traits::specialize>::template computeRank< typename traits::array_layout, P...>(arg_prop, arg_layout) )
1103 std::is_same< pointer_type
1104 ,
typename Impl::ViewCtorProp< P... >::pointer_type
1106 "Constructing DynRankView to wrap user memory must supply matching pointer type" );
1113 template<
class ... P >
1115 DynRankView(
const Kokkos::Impl::ViewCtorProp< P ... > & arg_prop
1116 ,
typename std::enable_if< ! Kokkos::Impl::ViewCtorProp< P... >::has_pointer
1118 >::type
const arg_N0 =KOKKOS_INVALID_INDEX
1119 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1120 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1121 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1122 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1123 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1124 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1125 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1127 : DynRankView( arg_prop
1128 , typename traits::array_layout
1129 ( arg_N0 , arg_N1 , arg_N2 , arg_N3 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1133 template<
class ... P >
1134 explicit KOKKOS_INLINE_FUNCTION
1135 DynRankView(
const Kokkos::Impl::ViewCtorProp< P ... > & arg_prop
1136 ,
typename std::enable_if< Kokkos::Impl::ViewCtorProp< P... >::has_pointer
1138 >::type
const arg_N0 =KOKKOS_INVALID_INDEX
1139 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1140 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1141 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1142 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1143 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1144 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1145 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1147 : DynRankView( arg_prop
1148 , typename traits::array_layout
1149 ( arg_N0 , arg_N1 , arg_N2 , arg_N3 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1154 template<
typename Label >
1156 DynRankView(
const Label & arg_label
1157 ,
typename std::enable_if<
1158 Kokkos::Impl::is_view_label<Label>::value ,
1159 typename traits::array_layout >::type
const & arg_layout
1161 : DynRankView(
Kokkos::Impl::ViewCtorProp< std::string >( arg_label ) , arg_layout )
1165 template<
typename Label >
1167 DynRankView(
const Label & arg_label
1168 ,
typename std::enable_if<
1169 Kokkos::Impl::is_view_label<Label>::value ,
1170 const size_t >::type arg_N0 =KOKKOS_INVALID_INDEX
1171 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1172 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1173 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1174 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1175 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1176 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1177 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1179 : DynRankView(
Kokkos::Impl::ViewCtorProp< std::string >( arg_label )
1180 , typename traits::array_layout
1181 ( arg_N0 , arg_N1 , arg_N2 , arg_N3 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1188 DynRankView(
const ViewAllocateWithoutInitializing & arg_prop
1189 ,
const typename traits::array_layout & arg_layout
1191 : DynRankView(
Kokkos::Impl::ViewCtorProp< std::string ,
Kokkos::Impl::WithoutInitializing_t >( arg_prop.label ,
Kokkos::WithoutInitializing )
1193 , Impl::DynRankDimTraits<typename traits::specialize>::createLayout(arg_layout)
1198 DynRankView(
const ViewAllocateWithoutInitializing & arg_prop
1199 ,
const size_t arg_N0 =KOKKOS_INVALID_INDEX
1200 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1201 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1202 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1203 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1204 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1205 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1206 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1208 : DynRankView(
Kokkos::Impl::ViewCtorProp< std::string ,
Kokkos::Impl::WithoutInitializing_t >( arg_prop.label ,
Kokkos::WithoutInitializing ), arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7 )
1213 static constexpr
size_t required_allocation_size(
1214 const size_t arg_N0 = 0
1215 ,
const size_t arg_N1 = 0
1216 ,
const size_t arg_N2 = 0
1217 ,
const size_t arg_N3 = 0
1218 ,
const size_t arg_N4 = 0
1219 ,
const size_t arg_N5 = 0
1220 ,
const size_t arg_N6 = 0
1221 ,
const size_t arg_N7 = 0
1224 return map_type::memory_span(
1225 typename traits::array_layout
1226 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1227 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
1230 explicit KOKKOS_INLINE_FUNCTION
1231 DynRankView( pointer_type arg_ptr
1232 ,
const size_t arg_N0 =KOKKOS_INVALID_INDEX
1233 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1234 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1235 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1236 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1237 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1238 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1239 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX
1241 : DynRankView(
Kokkos::Impl::ViewCtorProp<pointer_type>(arg_ptr) , arg_N0, arg_N1, arg_N2, arg_N3, arg_N4, arg_N5, arg_N6, arg_N7 )
1244 explicit KOKKOS_INLINE_FUNCTION
1245 DynRankView( pointer_type arg_ptr
1246 ,
typename traits::array_layout & arg_layout
1248 : DynRankView(
Kokkos::Impl::ViewCtorProp<pointer_type>(arg_ptr) , arg_layout )
1256 size_t shmem_size(
const size_t arg_N0 =KOKKOS_INVALID_INDEX ,
1257 const size_t arg_N1 =KOKKOS_INVALID_INDEX ,
1258 const size_t arg_N2 =KOKKOS_INVALID_INDEX ,
1259 const size_t arg_N3 =KOKKOS_INVALID_INDEX ,
1260 const size_t arg_N4 =KOKKOS_INVALID_INDEX ,
1261 const size_t arg_N5 =KOKKOS_INVALID_INDEX ,
1262 const size_t arg_N6 =KOKKOS_INVALID_INDEX ,
1263 const size_t arg_N7 =KOKKOS_INVALID_INDEX )
1265 const size_t num_passed_args =
1266 ( arg_N0 !=KOKKOS_INVALID_INDEX ) + ( arg_N1 !=KOKKOS_INVALID_INDEX ) + ( arg_N2 !=KOKKOS_INVALID_INDEX ) +
1267 ( arg_N3 !=KOKKOS_INVALID_INDEX ) + ( arg_N4 !=KOKKOS_INVALID_INDEX ) + ( arg_N5 !=KOKKOS_INVALID_INDEX ) +
1268 ( arg_N6 !=KOKKOS_INVALID_INDEX ) + ( arg_N7 !=KOKKOS_INVALID_INDEX );
1270 if ( std::is_same<typename traits::specialize , void>::value && num_passed_args != traits::rank_dynamic ) {
1271 Kokkos::abort(
"Kokkos::View::shmem_size() rank_dynamic != number of arguments.\n" );
1275 return map_type::memory_span(
1276 typename traits::array_layout
1277 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1278 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) );
1281 explicit KOKKOS_INLINE_FUNCTION
1282 DynRankView(
const typename traits::execution_space::scratch_memory_space & arg_space
1283 ,
const typename traits::array_layout & arg_layout )
1284 : DynRankView(
Kokkos::Impl::ViewCtorProp<pointer_type>(
1285 reinterpret_cast<pointer_type>(
1286 arg_space.get_shmem( map_type::memory_span(
1287 Impl::DynRankDimTraits<typename traits::specialize>::createLayout( arg_layout )
1292 explicit KOKKOS_INLINE_FUNCTION
1293 DynRankView(
const typename traits::execution_space::scratch_memory_space & arg_space
1294 ,
const size_t arg_N0 =KOKKOS_INVALID_INDEX
1295 ,
const size_t arg_N1 =KOKKOS_INVALID_INDEX
1296 ,
const size_t arg_N2 =KOKKOS_INVALID_INDEX
1297 ,
const size_t arg_N3 =KOKKOS_INVALID_INDEX
1298 ,
const size_t arg_N4 =KOKKOS_INVALID_INDEX
1299 ,
const size_t arg_N5 =KOKKOS_INVALID_INDEX
1300 ,
const size_t arg_N6 =KOKKOS_INVALID_INDEX
1301 ,
const size_t arg_N7 =KOKKOS_INVALID_INDEX )
1303 : DynRankView(
Kokkos::Impl::ViewCtorProp<pointer_type>(
1304 reinterpret_cast<pointer_type>(
1305 arg_space.get_shmem(
1306 map_type::memory_span(
1307 Impl::DynRankDimTraits<typename traits::specialize>::createLayout(
1308 typename traits::array_layout
1309 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1310 , arg_N4 , arg_N5 , arg_N6 , arg_N7 ) ) ) ) )
1312 , typename traits::array_layout
1313 ( arg_N0 , arg_N1 , arg_N2 , arg_N3
1314 , arg_N4 , arg_N5 , arg_N6 , arg_N7 )
1321 template <
typename D ,
class ... P >
1322 KOKKOS_INLINE_FUNCTION
1323 constexpr
unsigned rank(
const DynRankView<D , P...> & DRV ) {
return DRV.rank(); }
1331 struct DynRankSubviewTag {};
1337 template<
class SrcTraits ,
class ... Args >
1339 < typename std::enable_if<(
1340 std::is_same< typename SrcTraits::specialize , void >::value
1343 std::is_same< typename SrcTraits::array_layout
1344 , Kokkos::LayoutLeft >::value ||
1345 std::is_same< typename SrcTraits::array_layout
1346 , Kokkos::LayoutRight >::value ||
1347 std::is_same< typename SrcTraits::array_layout
1348 , Kokkos::LayoutStride >::value
1350 ), Kokkos::Impl::DynRankSubviewTag >::type
1358 , R0 = bool(is_integral_extent<0,Args...>::value)
1359 , R1 = bool(is_integral_extent<1,Args...>::value)
1360 , R2 = bool(is_integral_extent<2,Args...>::value)
1361 , R3 = bool(is_integral_extent<3,Args...>::value)
1362 , R4 = bool(is_integral_extent<4,Args...>::value)
1363 , R5 = bool(is_integral_extent<5,Args...>::value)
1364 , R6 = bool(is_integral_extent<6,Args...>::value)
1367 enum {
rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
1368 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
1372 typedef typename SrcTraits::value_type value_type ;
1374 typedef value_type******* data_type ;
1381 ,
typename SrcTraits::device_type
1382 ,
typename SrcTraits::memory_traits > traits_type ;
1387 ,
typename SrcTraits::device_type
1388 ,
typename SrcTraits::memory_traits > type ;
1391 template<
class MemoryTraits >
1394 static_assert( Kokkos::Impl::is_memory_traits< MemoryTraits >::value ,
"" );
1399 ,
typename SrcTraits::device_type
1400 , MemoryTraits > traits_type ;
1405 ,
typename SrcTraits::device_type
1406 , MemoryTraits > type ;
1410 typedef typename SrcTraits::dimension dimension ;
1412 template <
class Arg0 =
int,
class Arg1 =
int,
class Arg2 =
int,
class Arg3 =
int,
class Arg4 =
int,
class Arg5 =
int,
class Arg6 =
int >
1413 struct ExtentGenerator {
1414 KOKKOS_INLINE_FUNCTION
1415 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() )
1417 return SubviewExtents< 7 , rank>( dim , arg0 , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 );
1422 typedef Kokkos::DynRankView< value_type , array_layout , typename SrcTraits::device_type , typename SrcTraits::memory_traits > ret_type;
1424 template <
typename T ,
class ... P >
1425 KOKKOS_INLINE_FUNCTION
1426 static ret_type subview(
const unsigned src_rank , Kokkos::DynRankView< T , P...>
const & src
1430 typedef ViewMapping< traits_type, void > DstType ;
1432 typedef typename std::conditional< (rank==0) , ViewDimension<>
1433 ,
typename std::conditional< (rank==1) , ViewDimension<0>
1434 ,
typename std::conditional< (rank==2) , ViewDimension<0,0>
1435 ,
typename std::conditional< (rank==3) , ViewDimension<0,0,0>
1436 ,
typename std::conditional< (rank==4) , ViewDimension<0,0,0,0>
1437 ,
typename std::conditional< (rank==5) , ViewDimension<0,0,0,0,0>
1438 ,
typename std::conditional< (rank==6) , ViewDimension<0,0,0,0,0,0>
1439 , ViewDimension<0,0,0,0,0,0,0>
1440 >::type >::type >::type >::type >::type >::type >::type DstDimType ;
1442 typedef ViewOffset< DstDimType , Kokkos::LayoutStride > dst_offset_type ;
1443 typedef typename DstType::handle_type dst_handle_type ;
1447 const SubviewExtents< 7 , rank > extents =
1448 ExtentGenerator< Args ... >::generator( src.m_map.m_offset.m_dim , args... ) ;
1450 dst_offset_type tempdst( src.m_map.m_offset , extents ) ;
1452 dst.m_track = src.m_track ;
1454 dst.m_map.m_offset.m_dim.N0 = tempdst.m_dim.N0 ;
1455 dst.m_map.m_offset.m_dim.N1 = tempdst.m_dim.N1 ;
1456 dst.m_map.m_offset.m_dim.N2 = tempdst.m_dim.N2 ;
1457 dst.m_map.m_offset.m_dim.N3 = tempdst.m_dim.N3 ;
1458 dst.m_map.m_offset.m_dim.N4 = tempdst.m_dim.N4 ;
1459 dst.m_map.m_offset.m_dim.N5 = tempdst.m_dim.N5 ;
1460 dst.m_map.m_offset.m_dim.N6 = tempdst.m_dim.N6 ;
1462 dst.m_map.m_offset.m_stride.S0 = tempdst.m_stride.S0 ;
1463 dst.m_map.m_offset.m_stride.S1 = tempdst.m_stride.S1 ;
1464 dst.m_map.m_offset.m_stride.S2 = tempdst.m_stride.S2 ;
1465 dst.m_map.m_offset.m_stride.S3 = tempdst.m_stride.S3 ;
1466 dst.m_map.m_offset.m_stride.S4 = tempdst.m_stride.S4 ;
1467 dst.m_map.m_offset.m_stride.S5 = tempdst.m_stride.S5 ;
1468 dst.m_map.m_offset.m_stride.S6 = tempdst.m_stride.S6 ;
1470 dst.m_map.m_handle = dst_handle_type( src.m_map.m_handle +
1471 src.m_map.m_offset( extents.domain_offset(0)
1472 , extents.domain_offset(1)
1473 , extents.domain_offset(2)
1474 , extents.domain_offset(3)
1475 , extents.domain_offset(4)
1476 , extents.domain_offset(5)
1477 , extents.domain_offset(6)
1480 dst.m_rank = ( src_rank > 0 ? unsigned(R0) : 0 )
1481 + ( src_rank > 1 ? unsigned(R1) : 0 )
1482 + ( src_rank > 2 ? unsigned(R2) : 0 )
1483 + ( src_rank > 3 ? unsigned(R3) : 0 )
1484 + ( src_rank > 4 ? unsigned(R4) : 0 )
1485 + ( src_rank > 5 ? unsigned(R5) : 0 )
1486 + ( src_rank > 6 ? unsigned(R6) : 0 ) ;
1495 template<
class V ,
class ... Args >
1496 using Subdynrankview =
typename Kokkos::Impl::ViewMapping< Kokkos::Impl::DynRankSubviewTag , V , Args... >::ret_type ;
1498 template<
class D ,
class ... P ,
class ...Args >
1499 KOKKOS_INLINE_FUNCTION
1500 Subdynrankview< ViewTraits<D******* , P...> , Args... >
1501 subdynrankview(
const Kokkos::DynRankView< D , P... > &src , Args...args)
1503 if ( src.rank() >
sizeof...(Args) )
1504 { Kokkos::abort(
"subdynrankview: num of args must be >= rank of the source DynRankView"); }
1506 typedef Kokkos::Impl::ViewMapping< Kokkos::Impl::DynRankSubviewTag ,
Kokkos::ViewTraits< D*******, P... > , Args... > metafcn ;
1508 return metafcn::subview( src.rank() , src , args... );
1512 template<
class D ,
class ... P ,
class ...Args >
1513 KOKKOS_INLINE_FUNCTION
1514 Subdynrankview< ViewTraits<D******* , P...> , Args... >
1515 subview(
const Kokkos::DynRankView< D , P... > &src , Args...args)
1517 return subdynrankview( src , args... );
1525 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
1526 KOKKOS_INLINE_FUNCTION
1527 bool operator == (
const DynRankView<LT,LP...> & lhs ,
1528 const DynRankView<RT,RP...> & rhs )
1531 typedef ViewTraits<LT,LP...> lhs_traits ;
1532 typedef ViewTraits<RT,RP...> rhs_traits ;
1535 std::is_same<
typename lhs_traits::const_value_type ,
1536 typename rhs_traits::const_value_type >::value &&
1537 std::is_same<
typename lhs_traits::array_layout ,
1538 typename rhs_traits::array_layout >::value &&
1539 std::is_same<
typename lhs_traits::memory_space ,
1540 typename rhs_traits::memory_space >::value &&
1541 lhs.rank() == rhs.rank() &&
1542 lhs.data() == rhs.data() &&
1543 lhs.span() == rhs.span() &&
1544 lhs.extent(0) == rhs.extent(0) &&
1545 lhs.extent(1) == rhs.extent(1) &&
1546 lhs.extent(2) == rhs.extent(2) &&
1547 lhs.extent(3) == rhs.extent(3) &&
1548 lhs.extent(4) == rhs.extent(4) &&
1549 lhs.extent(5) == rhs.extent(5) &&
1550 lhs.extent(6) == rhs.extent(6) &&
1551 lhs.extent(7) == rhs.extent(7);
1554 template<
class LT ,
class ... LP ,
class RT ,
class ... RP >
1555 KOKKOS_INLINE_FUNCTION
1556 bool operator != (
const DynRankView<LT,LP...> & lhs ,
1557 const DynRankView<RT,RP...> & rhs )
1569 template<
class OutputView ,
typename Enable =
void >
1570 struct DynRankViewFill {
1572 typedef typename OutputView::traits::const_value_type const_value_type ;
1574 const OutputView output ;
1575 const_value_type input ;
1577 KOKKOS_INLINE_FUNCTION
1578 void operator()(
const size_t i0 )
const 1580 const size_t n1 = output.extent(1);
1581 const size_t n2 = output.extent(2);
1582 const size_t n3 = output.extent(3);
1583 const size_t n4 = output.extent(4);
1584 const size_t n5 = output.extent(5);
1585 const size_t n6 = output.extent(6);
1587 for (
size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1588 for (
size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1589 for (
size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1590 for (
size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1591 for (
size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1592 for (
size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1593 output.access(i0,i1,i2,i3,i4,i5,i6) = input ;
1597 DynRankViewFill(
const OutputView & arg_out , const_value_type & arg_in )
1598 : output( arg_out ), input( arg_in )
1600 typedef typename OutputView::execution_space execution_space ;
1607 execution_space::fence();
1611 template<
class OutputView >
1612 struct DynRankViewFill< OutputView , typename std::enable_if< OutputView::Rank == 0 >::type > {
1613 DynRankViewFill(
const OutputView & dst ,
const typename OutputView::const_value_type & src )
1615 Kokkos::Impl::DeepCopy< typename OutputView::memory_space , Kokkos::HostSpace >
1616 ( dst.data() , & src ,
sizeof(
typename OutputView::const_value_type) );
1620 template<
class OutputView ,
class InputView ,
class ExecSpace =
typename OutputView::execution_space >
1621 struct DynRankViewRemap {
1623 const OutputView output ;
1624 const InputView input ;
1634 DynRankViewRemap(
const OutputView & arg_out ,
const InputView & arg_in )
1635 : output( arg_out ), input( arg_in )
1636 , n0( std::min( (size_t)arg_out.extent(0) , (size_t)arg_in.extent(0) ) )
1637 , n1( std::min( (size_t)arg_out.extent(1) , (size_t)arg_in.extent(1) ) )
1638 , n2( std::min( (size_t)arg_out.extent(2) , (size_t)arg_in.extent(2) ) )
1639 , n3( std::min( (size_t)arg_out.extent(3) , (size_t)arg_in.extent(3) ) )
1640 , n4( std::min( (size_t)arg_out.extent(4) , (size_t)arg_in.extent(4) ) )
1641 , n5( std::min( (size_t)arg_out.extent(5) , (size_t)arg_in.extent(5) ) )
1642 , n6( std::min( (size_t)arg_out.extent(6) , (size_t)arg_in.extent(6) ) )
1643 , n7( std::min( (size_t)arg_out.extent(7) , (size_t)arg_in.extent(7) ) )
1650 KOKKOS_INLINE_FUNCTION
1651 void operator()(
const size_t i0 )
const 1653 for (
size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
1654 for (
size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
1655 for (
size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
1656 for (
size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
1657 for (
size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
1658 for (
size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
1659 output.access(i0,i1,i2,i3,i4,i5,i6) = input.access(i0,i1,i2,i3,i4,i5,i6);
1671 template<
class DT ,
class ... DP >
1674 (
const DynRankView<DT,DP...> & dst
1675 ,
typename ViewTraits<DT,DP...>::const_value_type & value
1676 ,
typename std::enable_if<
1677 std::is_same<
typename ViewTraits<DT,DP...>::specialize ,
void >::value
1681 std::is_same<
typename ViewTraits<DT,DP...>::non_const_value_type ,
1682 typename ViewTraits<DT,DP...>::value_type >::value
1683 ,
"deep_copy requires non-const type" );
1685 Kokkos::Impl::DynRankViewFill< DynRankView<DT,DP...> >( dst , value );
1689 template<
class ST ,
class ... SP >
1692 (
typename ViewTraits<ST,SP...>::non_const_value_type & dst
1693 ,
const DynRankView<ST,SP...> & src
1694 ,
typename std::enable_if<
1695 std::is_same<
typename ViewTraits<ST,SP...>::specialize ,
void >::value
1698 if ( src.rank() != 0 )
1704 typedef typename src_traits::memory_space src_memory_space ;
1705 Kokkos::Impl::DeepCopy< HostSpace , src_memory_space >( & dst , src.data() ,
sizeof(ST) );
1712 template<
class DstType ,
class SrcType >
1715 (
const DstType & dst
1716 ,
const SrcType & src
1717 ,
typename std::enable_if<(
1718 std::is_same< typename DstType::traits::specialize , void >::value &&
1719 std::is_same< typename SrcType::traits::specialize , void >::value
1721 ( Kokkos::is_dyn_rank_view<DstType>::value || Kokkos::is_dyn_rank_view<SrcType>::value)
1725 std::is_same<
typename DstType::traits::value_type ,
1726 typename DstType::traits::non_const_value_type >::value
1727 ,
"deep_copy requires non-const destination type" );
1729 typedef DstType dst_type ;
1730 typedef SrcType src_type ;
1732 typedef typename dst_type::execution_space dst_execution_space ;
1733 typedef typename src_type::execution_space src_execution_space ;
1734 typedef typename dst_type::memory_space dst_memory_space ;
1735 typedef typename src_type::memory_space src_memory_space ;
1737 enum { DstExecCanAccessSrc =
1740 enum { SrcExecCanAccessDst =
1743 if ( (
void *) dst.data() != (
void*) src.data() ) {
1749 if (
rank(src) == 0 &&
rank(dst) == 0 )
1751 typedef typename dst_type::value_type value_type ;
1752 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() ,
sizeof(value_type) );
1754 else if ( std::is_same<
typename DstType::traits::value_type ,
1755 typename SrcType::traits::non_const_value_type >::value &&
1757 ( std::is_same<
typename DstType::traits::array_layout ,
1758 typename SrcType::traits::array_layout >::value
1760 ( std::is_same<
typename DstType::traits::array_layout ,
1763 std::is_same<
typename DstType::traits::array_layout ,
1774 dst.span_is_contiguous() &&
1775 src.span_is_contiguous() &&
1776 dst.span() == src.span() &&
1777 dst.extent(0) == src.extent(0) &&
1779 dst.extent(1) == src.extent(1) &&
1780 dst.extent(2) == src.extent(2) &&
1781 dst.extent(3) == src.extent(3) &&
1782 dst.extent(4) == src.extent(4) &&
1783 dst.extent(5) == src.extent(5) &&
1784 dst.extent(6) == src.extent(6) &&
1785 dst.extent(7) == src.extent(7) ) {
1787 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1789 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
1791 else if ( std::is_same<
typename DstType::traits::value_type ,
1792 typename SrcType::traits::non_const_value_type >::value &&
1794 ( std::is_same<
typename DstType::traits::array_layout ,
1795 typename SrcType::traits::array_layout >::value
1797 std::is_same<
typename DstType::traits::array_layout ,
1807 dst.span_is_contiguous() &&
1808 src.span_is_contiguous() &&
1809 dst.span() == src.span() &&
1810 dst.extent(0) == src.extent(0) &&
1811 dst.extent(1) == src.extent(1) &&
1812 dst.extent(2) == src.extent(2) &&
1813 dst.extent(3) == src.extent(3) &&
1814 dst.extent(4) == src.extent(4) &&
1815 dst.extent(5) == src.extent(5) &&
1816 dst.extent(6) == src.extent(6) &&
1817 dst.extent(7) == src.extent(7) &&
1818 dst.stride_0() == src.stride_0() &&
1819 dst.stride_1() == src.stride_1() &&
1820 dst.stride_2() == src.stride_2() &&
1821 dst.stride_3() == src.stride_3() &&
1822 dst.stride_4() == src.stride_4() &&
1823 dst.stride_5() == src.stride_5() &&
1824 dst.stride_6() == src.stride_6() &&
1825 dst.stride_7() == src.stride_7()
1828 const size_t nbytes =
sizeof(
typename dst_type::value_type) * dst.span();
1830 Kokkos::Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
1832 else if ( DstExecCanAccessSrc ) {
1834 Kokkos::Impl::DynRankViewRemap< dst_type , src_type >( dst , src );
1836 else if ( SrcExecCanAccessDst ) {
1838 Kokkos::Impl::DynRankViewRemap< dst_type , src_type , src_execution_space >( dst , src );
1841 Kokkos::Impl::throw_runtime_exception(
"deep_copy given views that would require a temporary allocation");
1857 template<
class Space,
class T,
class ... P>
1858 struct MirrorDRViewType {
1860 typedef typename Kokkos::DynRankView<T,P...> src_view_type;
1862 typedef typename Space::memory_space memory_space;
1864 enum { is_same_memspace = std::is_same<memory_space,typename src_view_type::memory_space>::value };
1866 typedef typename src_view_type::array_layout array_layout;
1868 typedef typename src_view_type::non_const_data_type data_type;
1870 typedef Kokkos::DynRankView<data_type,array_layout,Space> dest_view_type;
1873 typedef typename std::conditional<is_same_memspace,src_view_type,dest_view_type>::type view_type;
1876 template<
class Space,
class T,
class ... P>
1877 struct MirrorDRVType {
1879 typedef typename Kokkos::DynRankView<T,P...> src_view_type;
1881 typedef typename Space::memory_space memory_space;
1883 enum { is_same_memspace = std::is_same<memory_space,typename src_view_type::memory_space>::value };
1885 typedef typename src_view_type::array_layout array_layout;
1887 typedef typename src_view_type::non_const_data_type data_type;
1889 typedef Kokkos::DynRankView<data_type,array_layout,Space> view_type;
1894 template<
class T ,
class ... P >
1896 typename DynRankView<T,P...>::HostMirror
1897 create_mirror(
const DynRankView<T,P...> & src
1898 ,
typename std::enable_if<
1899 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value &&
1900 ! std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
1905 typedef DynRankView<T,P...> src_type ;
1906 typedef typename src_type::HostMirror dst_type ;
1908 return dst_type( std::string( src.label() ).append(
"_mirror")
1909 , Impl::reconstructLayout(src.layout(), src.rank()) );
1913 template<
class T ,
class ... P >
1915 typename DynRankView<T,P...>::HostMirror
1916 create_mirror(
const DynRankView<T,P...> & src
1917 ,
typename std::enable_if<
1918 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value &&
1919 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
1924 typedef DynRankView<T,P...> src_type ;
1925 typedef typename src_type::HostMirror dst_type ;
1927 return dst_type( std::string( src.label() ).append(
"_mirror")
1928 , Impl::reconstructLayout(src.layout(), src.rank()) );
1933 template<
class Space,
class T,
class ... P>
1934 typename Impl::MirrorDRVType<Space,T,P ...>::view_type
1935 create_mirror(
const Space& ,
const Kokkos::DynRankView<T,P...> & src
1936 ,
typename std::enable_if<
1937 std::is_same<
typename ViewTraits<T,P...>::specialize ,
void >::value
1939 return typename Impl::MirrorDRVType<Space,T,P ...>::view_type(src.label(), Impl::reconstructLayout(src.layout(), src.rank()) );
1942 template<
class T ,
class ... P >
1944 typename DynRankView<T,P...>::HostMirror
1945 create_mirror_view(
const DynRankView<T,P...> & src
1946 ,
typename std::enable_if<(
1947 std::is_same<
typename DynRankView<T,P...>::memory_space
1948 ,
typename DynRankView<T,P...>::HostMirror::memory_space
1951 std::is_same<
typename DynRankView<T,P...>::data_type
1952 ,
typename DynRankView<T,P...>::HostMirror::data_type
1960 template<
class T ,
class ... P >
1962 typename DynRankView<T,P...>::HostMirror
1963 create_mirror_view(
const DynRankView<T,P...> & src
1964 ,
typename std::enable_if< ! (
1965 std::is_same<
typename DynRankView<T,P...>::memory_space
1966 ,
typename DynRankView<T,P...>::HostMirror::memory_space
1969 std::is_same<
typename DynRankView<T,P...>::data_type
1970 ,
typename DynRankView<T,P...>::HostMirror::data_type
1975 return Kokkos::create_mirror( src );
1979 template<
class Space,
class T,
class ... P>
1980 typename Impl::MirrorDRViewType<Space,T,P ...>::view_type
1981 create_mirror_view(
const Space& ,
const Kokkos::DynRankView<T,P...> & src
1982 ,
typename std::enable_if<Impl::MirrorDRViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
1987 template<
class Space,
class T,
class ... P>
1988 typename Impl::MirrorDRViewType<Space,T,P ...>::view_type
1989 create_mirror_view(
const Space& ,
const Kokkos::DynRankView<T,P...> & src
1990 ,
typename std::enable_if<!Impl::MirrorDRViewType<Space,T,P ...>::is_same_memspace>::type* = 0 ) {
1991 return typename Impl::MirrorDRViewType<Space,T,P ...>::view_type(src.label(), Impl::reconstructLayout(src.layout(), src.rank()) );
2002 template<
class T ,
class ... P >
2005 const size_t n0 =KOKKOS_INVALID_INDEX ,
2006 const size_t n1 =KOKKOS_INVALID_INDEX ,
2007 const size_t n2 =KOKKOS_INVALID_INDEX ,
2008 const size_t n3 =KOKKOS_INVALID_INDEX ,
2009 const size_t n4 =KOKKOS_INVALID_INDEX ,
2010 const size_t n5 =KOKKOS_INVALID_INDEX ,
2011 const size_t n6 =KOKKOS_INVALID_INDEX ,
2012 const size_t n7 =KOKKOS_INVALID_INDEX )
2014 typedef DynRankView<T,P...> drview_type ;
2018 drview_type v_resized( v.label(), n0, n1, n2, n3, n4, n5, n6 );
2020 Kokkos::Impl::DynRankViewRemap< drview_type , drview_type >( v_resized, v );
2026 template<
class T ,
class ... P >
2029 const size_t n0 =KOKKOS_INVALID_INDEX ,
2030 const size_t n1 =KOKKOS_INVALID_INDEX ,
2031 const size_t n2 =KOKKOS_INVALID_INDEX ,
2032 const size_t n3 =KOKKOS_INVALID_INDEX ,
2033 const size_t n4 =KOKKOS_INVALID_INDEX ,
2034 const size_t n5 =KOKKOS_INVALID_INDEX ,
2035 const size_t n6 =KOKKOS_INVALID_INDEX ,
2036 const size_t n7 =KOKKOS_INVALID_INDEX )
2038 typedef DynRankView<T,P...> drview_type ;
2042 const std::string label = v.label();
2045 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 ?
Memory layout tag indicated arbitrarily strided multi-index mapping into contiguous memory...
View to an array of data.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices...
Assign compatible default mappings.
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.
Implementation of the ParallelFor operator that has a partial specialization for the device...
void deep_copy(const View< DT, DP... > &dst, typename ViewTraits< DT, DP... >::const_value_type &value, typename std::enable_if< std::is_same< typename ViewTraits< DT, DP... >::specialize, void >::value >::type *=0)
Deep copy a value from Host memory into a view.
Execution policy for work over a range of an integral type.
KOKKOS_INLINE_FUNCTION bool dyn_rank_view_verify_operator_bounds(const iType0 &, const MapType &)
Debug bounds-checking routines.
Traits class for accessing attributes of a View.
KOKKOS_INLINE_FUNCTION constexpr unsigned rank(const View< D, P... > &V)
Temporary free function rank() until rank() is implemented in the View.
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.