10 #ifndef KOKKOS_VIEW_MP_VECTOR_INTERLACED_HPP
11 #define KOKKOS_VIEW_MP_VECTOR_INTERLACED_HPP
16 #include <Kokkos_Core.hpp>
34 template<
class ValueType ,
class MemorySpace ,
class MemoryTraits >
45 template<
class ValueType ,
class MemorySpace ,
class MemoryTraits >
78 template<
class DataType ,
82 class View< DataType , Arg1Type , Arg2Type , Arg3Type , Impl::ViewMPVectorInterlaced >
83 :
public ViewTraits< DataType
84 , typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::array_layout
85 , typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::device_type
86 , typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::memory_traits
91 typedef ViewTraits< DataType
92 ,
typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::array_layout
93 ,
typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::device_type
94 ,
typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::memory_traits
98 typedef View<
typename traits::const_data_type ,
99 typename traits::array_layout ,
100 typename traits::device_type ,
104 typedef View<
typename traits::non_const_data_type ,
105 typename traits::array_layout ,
106 typename traits::device_type ,
111 typename traits::data_type ,
112 typename traits::host_mirror_space::memory_space >::type ,
113 typename traits::array_layout ,
114 typename traits::host_mirror_space ,
121 typedef View<
typename traits::array_type ,
122 typename traits::array_layout ,
123 typename traits::device_type ,
127 typedef View<
typename traits::const_array_type ,
128 typename traits::array_layout ,
129 typename traits::device_type ,
133 typedef View<
typename traits::array_type ,
134 typename traits::array_layout ,
135 typename traits::host_mirror_space ,
139 typedef View<
typename traits::const_array_type ,
140 typename traits::array_layout ,
141 typename traits::host_mirror_space ,
151 template<
class ,
class ,
class ,
class ,
class >
friend class View ;
154 template<
class ,
class ,
class >
friend struct Impl::ViewAssignment ;
156 enum { StokhosStorageStaticDimension = stokhos_storage_type::static_size };
157 typedef integral_nonzero_constant< unsigned , StokhosStorageStaticDimension >
sacado_size_type;
159 typedef Impl::LayoutStride<
typename traits::shape_type ,
177 StokhosStorageStaticDimension ,
179 ( Impl::is_same< typename traits::array_layout , LayoutRight >::value ? 1 : 0 ) ,
188 static const bool is_static = stokhos_storage_type::is_static;
191 static const bool is_contiguous =
192 Impl::is_same< typename traits::array_layout , LayoutRight >::value;
196 enum { Rank = traits::rank };
199 enum { Sacado_Rank = Rank+1 };
201 KOKKOS_FORCEINLINE_FUNCTION
typename traits::shape_type
shape()
const {
return m_shape ; }
202 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_0()
const {
return m_shape.N0 ; }
203 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_1()
const {
return m_shape.N1 ; }
204 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_2()
const {
return m_shape.N2 ; }
205 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_3()
const {
return m_shape.N3 ; }
206 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_4()
const {
return m_shape.N4 ; }
207 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_5()
const {
return m_shape.N5 ; }
208 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_6()
const {
return m_shape.N6 ; }
209 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_7()
const {
return m_shape.N7 ; }
210 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
size()
const
223 template<
typename iType >
224 KOKKOS_FORCEINLINE_FUNCTION
225 typename traits::size_type
dimension(
const iType & i )
const
226 {
return Impl::dimension( m_shape , i ); }
236 if ( dimension(
unsigned(Rank) ) % ( StokhosStorageStaticDimension ? StokhosStorageStaticDimension : 1 ) ) {
237 std::ostringstream msg ;
238 msg <<
"Kokkos::View< Sacado::MP::Vector<StorageType , ... > allocation dimension ("
239 << dimension(
unsigned(Rank) )
240 <<
") must be a multiple of StorageType::static_size ("
241 << StokhosStorageStaticDimension
243 Impl::throw_runtime_exception( msg.str() );
247 #if defined( KOKKOS_EXPRESSION_CHECK )
248 KOKKOS_INLINE_FUNCTION
251 const int length = dimension( Rank );
253 const Impl::integral_nonzero_constant< int , StokhosStorageStaticDimension >
254 per_thread( ! StokhosStorageStaticDimension ? length / dev.team_size() : 0 );
256 if ( per_thread.value * dev.team_size() != length ) {
257 Kokkos::abort(
"Kokkos::View< Sacado::MP::Vector ... > incompatible vector-size : team-size");
261 KOKKOS_INLINE_FUNCTION
270 KOKKOS_INLINE_FUNCTION
273 KOKKOS_INLINE_FUNCTION
274 View() : m_ptr_on_device(0), m_storage_size(0), m_sacado_size(0)
276 traits::shape_type::assign(m_shape,0,0,0,0,0,0,0,0);
277 array_shape_type::assign(m_array_shape,0,0,0,0,0,0,0,0);
278 stride_type::assign(m_stride,0);
281 KOKKOS_INLINE_FUNCTION
282 View(
const View & rhs ) : m_ptr_on_device(0), m_storage_size(0), m_sacado_size(0)
284 (void) Impl::ViewAssignment<
285 typename traits::specialize ,
286 typename traits::specialize >( *
this , rhs );
289 KOKKOS_INLINE_FUNCTION
290 View & operator = (
const View & rhs )
292 (void) Impl::ViewAssignment<
293 typename traits::specialize ,
294 typename traits::specialize >( *
this , rhs );
301 template<
class RT ,
class RL ,
class RD ,
class RM >
302 KOKKOS_INLINE_FUNCTION
303 View(
const View<RT,RL,RD,RM,typename traits::specialize> & rhs )
306 (void) Impl::ViewAssignment<
307 typename traits::specialize ,
308 typename traits::specialize >( *
this , rhs );
311 template<
class RT ,
class RL ,
class RD ,
class RM >
312 KOKKOS_INLINE_FUNCTION
313 View & operator = (
const View<RT,RL,RD,RM,typename traits::specialize> & rhs )
315 (void) Impl::ViewAssignment<
316 typename traits::specialize ,
317 typename traits::specialize >( *
this , rhs );
324 template<
class AllocationProperties >
326 View(
const AllocationProperties & prop ,
329 const typename Impl::ViewAllocProp< traits , AllocationProperties >::size_type n0 = 0 ,
330 const size_t n1 = 0 ,
331 const size_t n2 = 0 ,
332 const size_t n3 = 0 ,
333 const size_t n4 = 0 ,
334 const size_t n5 = 0 ,
335 const size_t n6 = 0 ,
336 const size_t n7 = 0 )
339 typedef Impl::ViewAllocProp< traits , AllocationProperties > Alloc ;
341 typedef typename traits::memory_space memory_space ;
342 typedef typename traits::shape_type shape_type ;
345 shape_type::assign( m_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
346 array_shape_type::assign( m_array_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
347 stride_type::assign_with_padding( m_stride , m_array_shape );
348 m_storage_size = Impl::dimension( m_array_shape ,
unsigned(Rank) );
349 m_sacado_size = m_storage_size;
351 verify_dimension_storage_static_size();
353 m_tracker = memory_space::allocate_and_track( Alloc::label( prop ) ,
sizeof(scalar_type) * Impl::capacity( m_array_shape , m_stride ) );
355 m_ptr_on_device = (scalar_type *) m_tracker.alloc_ptr();
357 (void) Kokkos::Impl::ViewDefaultConstruct< typename traits::execution_space , scalar_type , Alloc::Initialize >
358 ( m_ptr_on_device , Impl::capacity( m_array_shape , m_stride ) );
365 template<
typename T >
367 const size_t n0 = 0 ,
368 const size_t n1 = 0 ,
369 const size_t n2 = 0 ,
370 const size_t n3 = 0 ,
371 const size_t n4 = 0 ,
372 const size_t n5 = 0 ,
373 const size_t n6 = 0 ,
374 typename Impl::enable_if<(
375 ( Impl::is_same<T,typename traits::value_type>::value ||
376 Impl::is_same<T,typename traits::const_value_type>::value ) &&
377 ! traits::is_managed ),
378 const size_t >::type n7 = 0 )
379 : m_ptr_on_device(ptr)
381 typedef typename traits::shape_type shape_type ;
383 shape_type::assign( m_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
384 array_shape_type::assign( m_array_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
385 stride_type::assign_no_padding( m_stride , m_shape );
386 m_storage_size = Impl::dimension( m_array_shape ,
unsigned(Rank) );
387 m_sacado_size = m_storage_size;
388 m_management.set_unmanaged();
390 verify_dimension_storage_static_size();
396 KOKKOS_FORCEINLINE_FUNCTION
397 bool is_null()
const {
return 0 == m_ptr_on_device ; }
403 typedef std::conditional< ( traits::rank == 1 ),
405 Impl::ViewError::scalar_operator_called_from_non_scalar_view >
408 KOKKOS_FORCEINLINE_FUNCTION
409 typename if_scalar_operator::type
412 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
423 template<
typename iType0 >
424 KOKKOS_FORCEINLINE_FUNCTION
425 typename Impl::ViewEnableArrayOper< reference_type , traits, LayoutLeft, 2, iType0 >::type
426 operator() (
const iType0 & i0 )
const
428 KOKKOS_ASSERT_SHAPE_BOUNDS_2( m_shape, i0, 0 );
429 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
433 m_ptr_on_device + i0 ,
438 template<
typename iType0 >
439 KOKKOS_FORCEINLINE_FUNCTION
440 typename Impl::ViewEnableArrayOper< reference_type ,
441 traits, LayoutRight, 2, iType0 >::type
442 operator() (
const iType0 & i0 )
const
444 KOKKOS_ASSERT_SHAPE_BOUNDS_2( m_shape, i0, 0 );
445 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
449 m_ptr_on_device + ( m_stride.value * i0 ) ,
453 template<
typename iType0 >
454 KOKKOS_FORCEINLINE_FUNCTION
455 typename Impl::ViewEnableArrayOper< reference_type , traits, typename traits::array_layout, 2, iType0 >::type
456 operator[] (
const iType0 & i0 )
const
457 {
return operator()( i0 ); }
459 template<
typename iType0 >
460 KOKKOS_FORCEINLINE_FUNCTION
461 typename Impl::ViewEnableArrayOper< reference_type ,
462 traits,
typename traits::array_layout, 2,
464 at(
const iType0 & i0 ,
int ,
int ,
int ,
int ,
int ,
int ,
int )
const
465 {
return operator()(i0); }
471 template<
typename iType0 ,
typename iType1 >
472 KOKKOS_FORCEINLINE_FUNCTION
473 typename Impl::ViewEnableArrayOper< reference_type ,
474 traits, LayoutLeft, 3, iType0, iType1 >::type
475 operator() (
const iType0 & i0 ,
const iType1 & i1 )
const
477 KOKKOS_ASSERT_SHAPE_BOUNDS_3( m_shape, i0, i1, 0 );
478 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
482 m_ptr_on_device + ( i0 + m_stride.value * ( i1 )),
484 m_stride.value * m_shape.N1 ) );
487 template<
typename iType0 ,
typename iType1 >
488 KOKKOS_FORCEINLINE_FUNCTION
489 typename Impl::ViewEnableArrayOper< reference_type ,
490 traits, LayoutRight, 3, iType0, iType1 >::type
491 operator() (
const iType0 & i0 ,
const iType1 & i1 )
const
493 KOKKOS_ASSERT_SHAPE_BOUNDS_3( m_shape, i0, i1, 0);
494 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
498 m_ptr_on_device + ( m_storage_size * ( i1 ) + m_stride.value * i0 ) ,
502 template<
typename iType0 ,
typename iType1 >
503 KOKKOS_FORCEINLINE_FUNCTION
504 typename Impl::ViewEnableArrayOper< reference_type ,
505 traits,
typename traits::array_layout, 3,
506 iType0, iType1 >::type
507 at(
const iType0 & i0 ,
const iType1 & i1 ,
int ,
int ,
int ,
int ,
int ,
int )
const
508 {
return operator()(i0,i1); }
514 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
515 KOKKOS_FORCEINLINE_FUNCTION
516 typename Impl::ViewEnableArrayOper< reference_type ,
517 traits, LayoutLeft, 4, iType0, iType1, iType2 >::type
518 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const
520 KOKKOS_ASSERT_SHAPE_BOUNDS_4( m_shape, i0, i1, i2, 0 );
521 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
525 m_ptr_on_device + ( i0 + m_stride.value * (
529 m_stride.value * m_shape.N1 * m_shape.N2 ) );
532 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
533 KOKKOS_FORCEINLINE_FUNCTION
534 typename Impl::ViewEnableArrayOper< reference_type ,
535 traits, LayoutRight, 4, iType0, iType1, iType2 >::type
536 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const
538 KOKKOS_ASSERT_SHAPE_BOUNDS_4( m_shape, i0, i1, i2, 0 );
539 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
543 m_ptr_on_device + ( m_storage_size * ( i2 +
544 m_shape.N2 * ( i1 )) +
545 m_stride.value * i0 ) ,
549 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
550 KOKKOS_FORCEINLINE_FUNCTION
551 typename Impl::ViewEnableArrayOper< reference_type ,
552 traits,
typename traits::array_layout, 4,
553 iType0, iType1, iType2 >::type
554 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
int ,
int ,
int ,
int ,
int )
const
555 {
return operator()(i0,i1,i2); }
561 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
562 KOKKOS_FORCEINLINE_FUNCTION
563 typename Impl::ViewEnableArrayOper< reference_type ,
564 traits, LayoutLeft, 5, iType0, iType1, iType2, iType3 >::type
565 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const
567 KOKKOS_ASSERT_SHAPE_BOUNDS_5( m_shape, i0, i1, i2, i3, 0 );
568 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
572 m_ptr_on_device + ( i0 + m_stride.value * (
577 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 ) );
580 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
581 KOKKOS_FORCEINLINE_FUNCTION
582 typename Impl::ViewEnableArrayOper< reference_type ,
583 traits, LayoutRight, 5, iType0, iType1, iType2, iType3 >::type
584 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const
586 KOKKOS_ASSERT_SHAPE_BOUNDS_5( m_shape, i0, i1, i2, i3, 0 );
587 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
591 m_ptr_on_device + ( m_storage_size * ( i3 +
593 m_shape.N2 * ( i1 ))) +
594 m_stride.value * i0 ) ,
598 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
599 KOKKOS_FORCEINLINE_FUNCTION
600 typename Impl::ViewEnableArrayOper< reference_type ,
601 traits,
typename traits::array_layout, 5,
602 iType0, iType1, iType2, iType3 >::type
603 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
int ,
int ,
int ,
int )
const
604 {
return operator()(i0,i1,i2,i3); }
610 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
typename iType4 >
611 KOKKOS_FORCEINLINE_FUNCTION
612 typename Impl::ViewEnableArrayOper< reference_type ,
613 traits, LayoutLeft, 6, iType0, iType1, iType2, iType3, iType4 >::type
614 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 )
const
616 KOKKOS_ASSERT_SHAPE_BOUNDS_6( m_shape, i0, i1, i2, i3, i4, 0 );
617 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
621 m_ptr_on_device + ( i0 + m_stride.value * (
627 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 ) );
630 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
631 typename iType3 ,
typename iType4 >
632 KOKKOS_FORCEINLINE_FUNCTION
633 typename Impl::ViewEnableArrayOper< reference_type ,
634 traits, LayoutRight, 6, iType0, iType1, iType2, iType3, iType4 >::type
635 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
636 const iType4 & i4 )
const
638 KOKKOS_ASSERT_SHAPE_BOUNDS_6( m_shape, i0, i1, i2, i3, i4, 0 );
639 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
643 m_ptr_on_device + ( m_storage_size * ( i4 +
646 m_shape.N2 * ( i1 )))) +
647 m_stride.value * i0 ) ,
651 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
652 typename iType3 ,
typename iType4 >
653 KOKKOS_FORCEINLINE_FUNCTION
654 typename Impl::ViewEnableArrayOper< reference_type ,
655 traits,
typename traits::array_layout, 6,
656 iType0, iType1, iType2, iType3, iType4 >::type
657 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
658 const iType4 & i4 ,
int ,
int ,
int )
const
659 {
return operator()(i0,i1,i2,i3,i4); }
665 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
typename iType4 ,
typename iType5 >
666 KOKKOS_FORCEINLINE_FUNCTION
667 typename Impl::ViewEnableArrayOper< reference_type ,
668 traits, LayoutLeft, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type
669 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
670 const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 )
const
672 KOKKOS_ASSERT_SHAPE_BOUNDS_7( m_shape, i0, i1, i2, i3, i4, i5, 0 );
673 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
677 m_ptr_on_device + ( i0 + m_stride.value * (
684 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 * m_shape.N5 ) );
687 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
688 typename iType3 ,
typename iType4 ,
typename iType5 >
689 KOKKOS_FORCEINLINE_FUNCTION
690 typename Impl::ViewEnableArrayOper< reference_type ,
691 traits, LayoutRight, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type
692 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
693 const iType4 & i4 ,
const iType5 & i5 )
const
695 KOKKOS_ASSERT_SHAPE_BOUNDS_7( m_shape, i0, i1, i2, i3, i4, i5, 0 );
696 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
700 m_ptr_on_device + ( m_storage_size * ( i5 +
704 m_shape.N2 * ( i1 ))))) +
705 m_stride.value * i0 ) ,
709 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
710 typename iType3 ,
typename iType4 ,
typename iType5 >
711 KOKKOS_FORCEINLINE_FUNCTION
712 typename Impl::ViewEnableArrayOper< reference_type ,
713 traits,
typename traits::array_layout, 7,
714 iType0, iType1, iType2, iType3, iType4, iType5 >::type
715 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
716 const iType4 & i4 ,
const iType5 & i5 ,
int ,
int )
const
717 {
return operator()(i0,i1,i2,i3,i4,i5); }
723 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
724 typename iType4 ,
typename iType5 ,
typename iType6 >
725 KOKKOS_FORCEINLINE_FUNCTION
726 typename Impl::ViewEnableArrayOper< reference_type ,
727 traits, LayoutLeft, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
728 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
729 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 )
const
731 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
732 KOKKOS_ASSERT_SHAPE_BOUNDS_8( m_shape, i0, i1, i2, i3, i4, i5, i6, 0 );
736 m_ptr_on_device + ( i0 + m_stride.value * (
744 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 * m_shape.N5 * m_shape.N6 ) );
747 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
748 typename iType3 ,
typename iType4 ,
typename iType5,
typename iType6 >
749 KOKKOS_FORCEINLINE_FUNCTION
750 typename Impl::ViewEnableArrayOper< reference_type ,
751 traits, LayoutRight, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
752 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
753 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 )
const
755 KOKKOS_ASSERT_SHAPE_BOUNDS_8( m_shape, i0, i1, i2, i3, i4, i5, i6, 0 );
756 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
760 m_ptr_on_device + ( m_storage_size * ( i6 +
765 m_shape.N2 * ( i1 )))))) +
766 m_stride.value * i0 ) ,
770 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
771 typename iType3 ,
typename iType4 ,
typename iType5,
typename iType6 >
772 KOKKOS_FORCEINLINE_FUNCTION
773 typename Impl::ViewEnableArrayOper< reference_type ,
774 traits,
typename traits::array_layout, 8,
775 iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
776 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
777 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 ,
int )
const
778 {
return operator()(i0,i1,i2,i3,i4,i5,i6); }
784 KOKKOS_FORCEINLINE_FUNCTION
786 data()
const {
return m_ptr_on_device ; }
789 template<
typename iType >
790 KOKKOS_FORCEINLINE_FUNCTION
792 { Impl::stride( s , m_array_shape , m_stride ); }
795 KOKKOS_FORCEINLINE_FUNCTION
797 {
return Impl::capacity( m_array_shape , m_stride ); }
800 KOKKOS_FORCEINLINE_FUNCTION
802 {
return m_sacado_size.value; }
808 template<
class DT ,
class DL ,
class DD ,
class DM ,
809 class ST ,
class SL ,
class SD ,
class SM >
811 void deep_copy(
const View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced> & dst ,
812 const View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced> & src ,
813 typename Impl::enable_if<(
814 Impl::is_same<
typename View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::intinsic_scalar_type ,
815 typename View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::intinsic_scalar_type >::value
817 Impl::is_same<
typename View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::array_layout ,
818 typename View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::array_layout >::value
820 (
unsigned(View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::rank) ==
821 unsigned(View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::rank) )
824 typedef View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced> dst_type ;
825 typedef View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced> src_type ;
827 typedef typename dst_type::memory_space dst_memory_space ;
828 typedef typename src_type::memory_space src_memory_space ;
830 if ( dst.data() != src.data() ) {
832 Impl::assert_shapes_are_equal( dst.shape() , src.shape() );
836 Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
854 template<
class StorageType >
855 struct AnalyzeShape< Sacado::MP::Vector< StorageType > >
856 : Shape< sizeof(Sacado::MP::Vector< StorageType >) , 0 >
860 typedef AnalyzeShape< typename StorageType::value_type >
nested ;
866 typedef Shape< sizeof(Sacado::MP::Vector< StorageType >) , 0 >
shape ;
871 std::conditional< StorageType::is_static
872 ,
typename nested::array_intrinsic_type [ StorageType::is_static ? StorageType::static_size : 1 ]
873 ,
typename nested::array_intrinsic_type *
877 std::conditional< StorageType::is_static
878 ,
typename nested::const_array_intrinsic_type [ StorageType::is_static ? StorageType::static_size : 1 ]
879 ,
typename nested::const_array_intrinsic_type *
903 template<
class DT ,
class DL ,
class DD ,
class DM ,
904 class ST ,
class SL ,
class SD ,
class SM >
905 KOKKOS_INLINE_FUNCTION
907 ,
const View<ST,SL,SD,SM,specialize> & src
908 ,
const typename enable_if<(
909 ViewAssignable< ViewTraits<DT,DL,DD,DM> ,
910 ViewTraits<ST,SL,SD,SM> >::value
914 typedef ViewTraits<DT,DL,DD,DM> dst_traits ;
915 typedef View<DT,DL,DD,DM,specialize> dst_type ;
916 typedef typename dst_type::shape_type shape_type ;
917 typedef typename dst_type::array_shape_type array_shape_type ;
918 typedef typename dst_type::stride_type stride_type ;
920 shape_type::assign( dst.m_shape,
921 src.m_shape.N0 , src.m_shape.N1 , src.m_shape.N2 , src.m_shape.N3 ,
922 src.m_shape.N4 , src.m_shape.N5 , src.m_shape.N6 , src.m_shape.N7 );
923 array_shape_type::assign( dst.m_array_shape,
924 src.m_array_shape.N0 , src.m_array_shape.N1 , src.m_array_shape.N2 , src.m_array_shape.N3 ,
925 src.m_array_shape.N4 , src.m_array_shape.N5 , src.m_array_shape.N6 , src.m_array_shape.N7 );
927 stride_type::assign( dst.m_stride , src.m_stride.value );
928 dst.m_ptr_on_device = src.m_ptr_on_device ;
929 dst.m_storage_size = src.m_storage_size ;
930 dst.m_sacado_size = src.m_sacado_size ;
931 dst.m_tracker = src.m_tracker ;
937 template<
class DT ,
class DL ,
class DD ,
class DM ,
938 class ST ,
class SL ,
class SD ,
class SM >
939 KOKKOS_INLINE_FUNCTION
941 ,
const View<ST,SL,SD,SM,specialize> & src
942 ,
typename enable_if<(
944 is_same<
typename View<DT,DL,DD,DM,specialize>::intrinsic_scalar_type ,
945 typename View<ST,SL,SD,SM,specialize>::intrinsic_scalar_type >::value
948 is_same<
typename View<DT,DL,DD,DM,specialize>::memory_space ,
949 typename View<ST,SL,SD,SM,specialize>::memory_space >::value
952 is_same<
typename View<DT,DL,DD,DM,specialize>::array_layout ,
953 typename View<ST,SL,SD,SM,specialize>::array_layout >::value
956 (
unsigned(View<DT,DL,DD,DM,specialize>::rank) ==
957 unsigned(View<ST,SL,SD,SM,specialize>::rank) )
960 ! View<DT,DL,DD,DM,specialize>::is_managed
961 ),
const Sacado::MP::VectorPartition & >::type part )
963 typedef ViewTraits<DT,DL,DD,DM> dst_traits ;
964 typedef View<DT,DL,DD,DM,specialize> dst_type ;
965 typedef typename dst_type::shape_type dst_shape_type ;
966 typedef typename dst_type::array_shape_type dst_array_shape_type ;
967 typedef typename dst_type::stride_type dst_stride_type ;
971 enum { DstRank = dst_type::rank };
972 enum { DstStaticLength = dst_stokhos_storage_type::static_size };
974 const int length = part.end - part.begin ;
976 if ( DstStaticLength && DstStaticLength != length ) {
977 Kokkos::abort(
"Kokkos::View< Sacado::MP::Vector ... > incompatible partitioning");
981 dims[0] = src.m_array_shape.N0;
982 dims[1] = src.m_array_shape.N1;
983 dims[2] = src.m_array_shape.N2;
984 dims[3] = src.m_array_shape.N3;
985 dims[4] = src.m_array_shape.N4;
986 dims[5] = src.m_array_shape.N5;
987 dims[6] = src.m_array_shape.N6;
988 dims[7] = src.m_array_shape.N7;
989 unsigned rank = dst_type::rank;
991 dst_shape_type::assign( dst.m_shape,
992 dims[0] , dims[1] , dims[2] , dims[3] ,
993 dims[4] , dims[5] , dims[6] , dims[7] );
996 dst_array_shape_type::assign( dst.m_array_shape,
997 dims[0] , dims[1] , dims[2] , dims[3] ,
998 dims[4] , dims[5] , dims[6] , dims[7] );
1000 dst_stride_type::assign( dst.m_stride , src.m_stride.value );
1003 dst.m_storage_size = src.m_storage_size ;
1004 dst.m_sacado_size = length;
1006 if ( Impl::is_same< typename dst_traits::array_layout , LayoutLeft >::value ) {
1007 dst.m_ptr_on_device = src.m_ptr_on_device + part.begin *
1008 ( 0 == DstRank ? 1 : dst.m_stride.value * (
1009 ( 1 == DstRank ? 1 : dst.m_shape.N1 * (
1010 ( 2 == DstRank ? 1 : dst.m_shape.N2 * (
1011 ( 3 == DstRank ? 1 : dst.m_shape.N3 * (
1012 ( 4 == DstRank ? 1 : dst.m_shape.N4 * (
1013 ( 5 == DstRank ? 1 : dst.m_shape.N5 * (
1014 ( 6 == DstRank ? 1 : dst.m_shape.N6 )))))))))))));
1017 dst.m_ptr_on_device = src.m_ptr_on_device + part.begin ;
1019 dst.m_tracker = src.m_tracker ;
1029 template<
class ST ,
class SL ,
class SD ,
class SM >
1030 KOKKOS_INLINE_FUNCTION
1032 ,
const View<ST,SL,SD,SM,ViewMPVectorInterlaced> & src )
1034 typedef View<ST,SL,SD,SM,ViewMPVectorInterlaced> src_type ;
1038 typedef typename src_type::array_type dst_type ;
1039 typedef typename dst_type::shape_type dst_shape_type ;
1040 typedef typename dst_type::stride_type dst_stride_type ;
1042 dst_shape_type::assign( dst.m_shape,
1043 src.m_array_shape.N0 , src.m_array_shape.N1 , src.m_array_shape.N2 , src.m_arrat_shape.N3 ,
1044 src.m_array_shape.N4 , src.m_array_shape.N5 , src.m_arrat_shape.N6 , src.m_arrat_shape.N7 );
1046 dst_stride_type::assign( dst.m_stride , src.m_stride.value );
1048 dst.m_ptr_on_device =
reinterpret_cast< typename
dst_type::value_type *
>( src.m_ptr_on_device );
1050 dst.m_tracker = src.m_tracker ;
KOKKOS_FORCEINLINE_FUNCTION Impl::ViewEnableArrayOper< reference_type, traits, typename traits::array_layout, 3, iType0, iType1 >::type at(const iType0 &i0, const iType1 &i1, int, int, int, int, int, int) const
View< typename traits::const_data_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > const_type
ViewMPVectorInterlaced specialize
array_type::traits::shape_type array_shape_type
Impl::ViewDataManagement< traits > m_management
array_intrinsic_type non_const_array_intrinsic_type
Stokhos::StandardStorage< int, double > storage_type
Impl::LayoutStride< typename traits::shape_type, typename traits::array_layout > stride_type
Dynamic storage with view semantics and contiguous access.
KOKKOS_INLINE_FUNCTION View(const View< RT, RL, RD, RM, typename traits::specialize > &rhs)
KOKKOS_FORCEINLINE_FUNCTION if_scalar_operator::type operator()() const
KOKKOS_INLINE_FUNCTION ViewAssignment(typename View< ST, SL, SD, SM, ViewMPVectorInterlaced >::array_type &dst, const View< ST, SL, SD, SM, ViewMPVectorInterlaced > &src)
Compatible value and shape.
KOKKOS_FORCEINLINE_FUNCTION void stride(iType *const s) const
Shape< sizeof(Sacado::MP::Vector< StorageType >), 0 > shape
ViewMPVectorInterlaced type
View< typename traits::array_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > array_type
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension_1() const
const Sacado::MP::Vector< StorageType > const_type
Kokkos::DefaultExecutionSpace execution_space
array_shape_type m_array_shape
ViewTraits< DataType, typename ViewTraits< DataType, Arg1Type, Arg2Type, Arg3Type >::array_layout, typename ViewTraits< DataType, Arg1Type, Arg2Type, Arg3Type >::device_type, typename ViewTraits< DataType, Arg1Type, Arg2Type, Arg3Type >::memory_traits > traits
View< typename traits::const_array_type, typename traits::array_layout, typename traits::host_mirror_space, typename traits::memory_traits > host_const_array_type
ViewMPVectorContiguous specialize
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension_4() const
Impl::AllocationTracker m_tracker
Sacado::MP::Vector< StorageType > non_const_value_type
KOKKOS_INLINE_FUNCTION ~View()
KOKKOS_FORCEINLINE_FUNCTION traits::size_type size() const
KOKKOS_FORCEINLINE_FUNCTION traits::size_type sacado_size() const
KOKKOS_INLINE_FUNCTION ViewAssignment(View< DT, DL, DD, DM, specialize > &dst, const View< ST, SL, SD, SM, specialize > &src, typename enable_if<(is_same< typename View< DT, DL, DD, DM, specialize >::intrinsic_scalar_type, typename View< ST, SL, SD, SM, specialize >::intrinsic_scalar_type >::value &&is_same< typename View< DT, DL, DD, DM, specialize >::memory_space, typename View< ST, SL, SD, SM, specialize >::memory_space >::value &&is_same< typename View< DT, DL, DD, DM, specialize >::array_layout, typename View< ST, SL, SD, SM, specialize >::array_layout >::value &&(unsigned(View< DT, DL, DD, DM, specialize >::rank)==unsigned(View< ST, SL, SD, SM, specialize >::rank))&&!View< DT, DL, DD, DM, specialize >::is_managed), const Sacado::MP::VectorPartition & >::type part)
Partition of compatible value and shape.
const Sacado::MP::Vector< StorageType > const_value_type
std::conditional< (traits::rank==1), reference_type, Impl::ViewError::scalar_operator_called_from_non_scalar_view > if_scalar_operator
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension_3() const
Sacado::MP::Vector< StorageType > value_type
View< typename traits::array_type, typename traits::array_layout, typename traits::host_mirror_space, typename traits::memory_traits > host_array_type
View< typename traits::non_const_data_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > non_const_type
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension_5() const
KOKKOS_FORCEINLINE_FUNCTION Impl::ViewEnableArrayOper< reference_type, traits, typename traits::array_layout, 2, iType0 >::type at(const iType0 &i0, int, int, int, int, int, int, int) const
Sacado::MP::Vector< stokhos_view_storage_type > reference_type
KOKKOS_INLINE_FUNCTION View()
Sacado::MP::Vector< StorageType > type
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension_0() const
traits::shape_type m_shape
stokhos_storage_type::value_type intrinsic_scalar_type
KOKKOS_FORCEINLINE_FUNCTION traits::value_type::storage_type::value_type * data() const
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
KOKKOS_FORCEINLINE_FUNCTION Impl::ViewEnableArrayOper< reference_type, traits, typename traits::array_layout, 6, iType0, iType1, iType2, iType3, iType4 >::type at(const iType0 &i0, const iType1 &i1, const iType2 &i2, const iType3 &i3, const iType4 &i4, int, int, int) const
KOKKOS_INLINE_FUNCTION void verify_dimension_storage_size(const typename traits::execution_space &) const
integral_nonzero_constant< unsigned, StokhosStorageStaticDimension > sacado_size_type
View(const AllocationProperties &prop, const typename Impl::ViewAllocProp< traits, AllocationProperties >::size_type n0=0, const size_t n1=0, const size_t n2=0, const size_t n3=0, const size_t n4=0, const size_t n5=0, const size_t n6=0, const size_t n7=0)
KOKKOS_FORCEINLINE_FUNCTION Impl::ViewEnableArrayOper< reference_type, traits, typename traits::array_layout, 4, iType0, iType1, iType2 >::type at(const iType0 &i0, const iType1 &i1, const iType2 &i2, int, int, int, int, int) const
sacado_mp_vector_type::storage_type stokhos_storage_type
Sacado::MP::Vector< StorageType > non_const_type
std::conditional< StorageType::is_static, typename nested::array_intrinsic_type[StorageType::is_static?StorageType::static_size:1], typename nested::array_intrinsic_type * >::type array_intrinsic_type
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension_7() const
void verify_dimension_storage_static_size() const
KOKKOS_INLINE_FUNCTION ViewAssignment(View< DT, DL, DD, DM, specialize > &dst, const View< ST, SL, SD, SM, specialize > &src, const typename enable_if<(ViewAssignable< ViewTraits< DT, DL, DD, DM >, ViewTraits< ST, SL, SD, SM > >::value)>::type *=0)
Compatible value and shape.
ViewMPVectorInterlaced type
traits::execution_space::size_type m_storage_size
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension_6() const
traits::value_type sacado_mp_vector_type
HostMirror host_mirror_type
KOKKOS_FORCEINLINE_FUNCTION Impl::ViewEnableArrayOper< reference_type, traits, typename traits::array_layout, 5, iType0, iType1, iType2, iType3 >::type at(const iType0 &i0, const iType1 &i1, const iType2 &i2, const iType3 &i3, int, int, int, int) const
View< typename Impl::RebindStokhosStorageDevice< typename traits::data_type, typename traits::host_mirror_space::memory_space >::type, typename traits::array_layout, typename traits::host_mirror_space, void > host_mirror_type
KOKKOS_INLINE_FUNCTION View(const View &rhs)
View< typename traits::const_array_type, typename traits::array_layout, typename traits::device_type, typename traits::memory_traits > const_array_type
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension_2() const
std::conditional< StorageType::is_static, typename nested::const_array_intrinsic_type[StorageType::is_static?StorageType::static_size:1], typename nested::const_array_intrinsic_type * >::type const_array_intrinsic_type
sacado_size_type m_sacado_size
KOKKOS_FORCEINLINE_FUNCTION Impl::ViewEnableArrayOper< reference_type, traits, typename traits::array_layout, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type at(const iType0 &i0, const iType1 &i1, const iType2 &i2, const iType3 &i3, const iType4 &i4, const iType5 &i5, int, int) const
KOKKOS_FORCEINLINE_FUNCTION traits::size_type dimension(const iType &i) const
AnalyzeShape< typename StorageType::value_type > nested
KOKKOS_FORCEINLINE_FUNCTION traits::shape_type shape() const
View(T *ptr, const size_t n0=0, const size_t n1=0, const size_t n2=0, const size_t n3=0, const size_t n4=0, const size_t n5=0, const size_t n6=0, typename Impl::enable_if<((Impl::is_same< T, typename traits::value_type >::value||Impl::is_same< T, typename traits::const_value_type >::value)&&!traits::is_managed), const size_t >::type n7=0)
KOKKOS_FORCEINLINE_FUNCTION bool is_null() const
stokhos_storage_type::value_type * m_ptr_on_device
KOKKOS_FORCEINLINE_FUNCTION Impl::ViewEnableArrayOper< reference_type, traits, typename traits::array_layout, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type at(const iType0 &i0, const iType1 &i1, const iType2 &i2, const iType3 &i3, const iType4 &i4, const iType5 &i5, const iType6 &i6, int) const
KOKKOS_FORCEINLINE_FUNCTION traits::size_type capacity() const