42 #ifndef KOKKOS_VIEW_MP_VECTOR_INTERLACED_HPP
43 #define KOKKOS_VIEW_MP_VECTOR_INTERLACED_HPP
48 #include <Kokkos_Core.hpp>
66 template<
class ValueType ,
class MemorySpace ,
class MemoryTraits >
77 template<
class ValueType ,
class MemorySpace ,
class MemoryTraits >
110 template<
class DataType ,
114 class View< DataType , Arg1Type , Arg2Type , Arg3Type , Impl::ViewMPVectorInterlaced >
115 :
public ViewTraits< DataType
116 , typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::array_layout
117 , typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::device_type
118 , typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::memory_traits
123 typedef ViewTraits< DataType
124 ,
typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::array_layout
125 ,
typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::device_type
126 ,
typename ViewTraits< DataType , Arg1Type, Arg2Type, Arg3Type >::memory_traits
130 typedef View<
typename traits::const_data_type ,
131 typename traits::array_layout ,
132 typename traits::device_type ,
136 typedef View<
typename traits::non_const_data_type ,
137 typename traits::array_layout ,
138 typename traits::device_type ,
143 typename traits::data_type ,
144 typename traits::host_mirror_space::memory_space >::type ,
145 typename traits::array_layout ,
146 typename traits::host_mirror_space ,
150 typedef View<
typename traits::array_type ,
151 typename traits::array_layout ,
152 typename traits::device_type ,
156 typedef View<
typename traits::const_array_type ,
157 typename traits::array_layout ,
158 typename traits::device_type ,
162 typedef View<
typename traits::array_type ,
163 typename traits::array_layout ,
164 typename traits::host_mirror_space ,
168 typedef View<
typename traits::const_array_type ,
169 typename traits::array_layout ,
170 typename traits::host_mirror_space ,
180 template<
class ,
class ,
class ,
class ,
class >
friend class View ;
183 template<
class ,
class ,
class >
friend struct Impl::ViewAssignment ;
185 enum { StokhosStorageStaticDimension = stokhos_storage_type::static_size };
186 typedef integral_nonzero_constant< unsigned , StokhosStorageStaticDimension >
sacado_size_type;
188 typedef Impl::LayoutStride<
typename traits::shape_type ,
206 StokhosStorageStaticDimension ,
208 ( Impl::is_same< typename traits::array_layout , LayoutRight >::value ? 1 : 0 ) ,
217 static const bool is_static = stokhos_storage_type::is_static;
220 static const bool is_contiguous =
221 Impl::is_same< typename traits::array_layout , LayoutRight >::value;
225 enum { Rank = traits::rank };
228 enum { Sacado_Rank = Rank+1 };
230 KOKKOS_FORCEINLINE_FUNCTION
typename traits::shape_type
shape()
const {
return m_shape ; }
231 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_0()
const {
return m_shape.N0 ; }
232 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_1()
const {
return m_shape.N1 ; }
233 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_2()
const {
return m_shape.N2 ; }
234 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_3()
const {
return m_shape.N3 ; }
235 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_4()
const {
return m_shape.N4 ; }
236 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_5()
const {
return m_shape.N5 ; }
237 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_6()
const {
return m_shape.N6 ; }
238 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_7()
const {
return m_shape.N7 ; }
239 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
size()
const
252 template<
typename iType >
253 KOKKOS_FORCEINLINE_FUNCTION
254 typename traits::size_type
dimension(
const iType & i )
const
255 {
return Impl::dimension( m_shape , i ); }
265 if ( dimension(
unsigned(Rank) ) % ( StokhosStorageStaticDimension ? StokhosStorageStaticDimension : 1 ) ) {
266 std::ostringstream msg ;
267 msg <<
"Kokkos::View< Sacado::MP::Vector<StorageType , ... > allocation dimension ("
268 << dimension(
unsigned(Rank) )
269 <<
") must be a multiple of StorageType::static_size ("
270 << StokhosStorageStaticDimension
272 Impl::throw_runtime_exception( msg.str() );
276 #if defined( KOKKOS_EXPRESSION_CHECK )
277 KOKKOS_INLINE_FUNCTION
280 const int length = dimension( Rank );
282 const Impl::integral_nonzero_constant< int , StokhosStorageStaticDimension >
283 per_thread( ! StokhosStorageStaticDimension ? length / dev.team_size() : 0 );
285 if ( per_thread.value * dev.team_size() != length ) {
286 Kokkos::abort(
"Kokkos::View< Sacado::MP::Vector ... > incompatible vector-size : team-size");
290 KOKKOS_INLINE_FUNCTION
299 KOKKOS_INLINE_FUNCTION
302 KOKKOS_INLINE_FUNCTION
303 View() : m_ptr_on_device(0), m_storage_size(0), m_sacado_size(0)
305 traits::shape_type::assign(m_shape,0,0,0,0,0,0,0,0);
306 array_shape_type::assign(m_array_shape,0,0,0,0,0,0,0,0);
307 stride_type::assign(m_stride,0);
310 KOKKOS_INLINE_FUNCTION
311 View(
const View & rhs ) : m_ptr_on_device(0), m_storage_size(0), m_sacado_size(0)
313 (void) Impl::ViewAssignment<
314 typename traits::specialize ,
315 typename traits::specialize >( *
this , rhs );
318 KOKKOS_INLINE_FUNCTION
319 View & operator = (
const View & rhs )
321 (void) Impl::ViewAssignment<
322 typename traits::specialize ,
323 typename traits::specialize >( *
this , rhs );
330 template<
class RT ,
class RL ,
class RD ,
class RM >
331 KOKKOS_INLINE_FUNCTION
332 View(
const View<RT,RL,RD,RM,typename traits::specialize> & rhs )
335 (void) Impl::ViewAssignment<
336 typename traits::specialize ,
337 typename traits::specialize >( *
this , rhs );
340 template<
class RT ,
class RL ,
class RD ,
class RM >
341 KOKKOS_INLINE_FUNCTION
342 View & operator = (
const View<RT,RL,RD,RM,typename traits::specialize> & rhs )
344 (void) Impl::ViewAssignment<
345 typename traits::specialize ,
346 typename traits::specialize >( *
this , rhs );
353 typedef Impl::if_c< traits::is_managed ,
355 Impl::ViewError::allocation_constructor_requires_managed >
358 template<
class AllocationProperties >
360 View(
const AllocationProperties & prop ,
363 const typename Impl::ViewAllocProp< traits , AllocationProperties >::size_type n0 = 0 ,
364 const size_t n1 = 0 ,
365 const size_t n2 = 0 ,
366 const size_t n3 = 0 ,
367 const size_t n4 = 0 ,
368 const size_t n5 = 0 ,
369 const size_t n6 = 0 ,
370 const size_t n7 = 0 )
373 typedef Impl::ViewAllocProp< traits , AllocationProperties > Alloc ;
375 typedef typename traits::memory_space memory_space ;
376 typedef typename traits::shape_type shape_type ;
379 shape_type::assign( m_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
380 array_shape_type::assign( m_array_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
381 stride_type::assign_with_padding( m_stride , m_array_shape );
382 m_storage_size = Impl::dimension( m_array_shape ,
unsigned(Rank) );
383 m_sacado_size = m_storage_size;
385 verify_dimension_storage_static_size();
387 m_tracker = memory_space::allocate_and_track( Alloc::label( prop ) ,
sizeof(scalar_type) * Impl::capacity( m_array_shape , m_stride ) );
389 m_ptr_on_device = (scalar_type *) m_tracker.alloc_ptr();
391 (void) Kokkos::Impl::ViewDefaultConstruct< typename traits::execution_space , scalar_type , Alloc::Initialize >
392 ( m_ptr_on_device , Impl::capacity( m_array_shape , m_stride ) );
399 template<
typename T >
401 const size_t n0 = 0 ,
402 const size_t n1 = 0 ,
403 const size_t n2 = 0 ,
404 const size_t n3 = 0 ,
405 const size_t n4 = 0 ,
406 const size_t n5 = 0 ,
407 const size_t n6 = 0 ,
408 typename Impl::enable_if<(
409 ( Impl::is_same<T,typename traits::value_type>::value ||
410 Impl::is_same<T,typename traits::const_value_type>::value ) &&
411 ! traits::is_managed ),
412 const size_t >::type n7 = 0 )
413 : m_ptr_on_device(ptr)
415 typedef typename traits::shape_type shape_type ;
417 shape_type::assign( m_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
418 array_shape_type::assign( m_array_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
419 stride_type::assign_no_padding( m_stride , m_shape );
420 m_storage_size = Impl::dimension( m_array_shape ,
unsigned(Rank) );
421 m_sacado_size = m_storage_size;
422 m_management.set_unmanaged();
424 verify_dimension_storage_static_size();
430 KOKKOS_FORCEINLINE_FUNCTION
431 bool is_null()
const {
return 0 == m_ptr_on_device ; }
437 typedef Impl::if_c< ( traits::rank == 1 ),
439 Impl::ViewError::scalar_operator_called_from_non_scalar_view >
442 KOKKOS_FORCEINLINE_FUNCTION
443 typename if_scalar_operator::type
446 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
457 template<
typename iType0 >
458 KOKKOS_FORCEINLINE_FUNCTION
459 typename Impl::ViewEnableArrayOper< reference_type , traits, LayoutLeft, 2, iType0 >::type
460 operator() (
const iType0 & i0 )
const
462 KOKKOS_ASSERT_SHAPE_BOUNDS_2( m_shape, i0, 0 );
463 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
467 m_ptr_on_device + i0 ,
472 template<
typename iType0 >
473 KOKKOS_FORCEINLINE_FUNCTION
474 typename Impl::ViewEnableArrayOper< reference_type ,
475 traits, LayoutRight, 2, iType0 >::type
476 operator() (
const iType0 & i0 )
const
478 KOKKOS_ASSERT_SHAPE_BOUNDS_2( m_shape, i0, 0 );
479 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
483 m_ptr_on_device + ( m_stride.value * i0 ) ,
487 template<
typename iType0 >
488 KOKKOS_FORCEINLINE_FUNCTION
489 typename Impl::ViewEnableArrayOper< reference_type , traits, typename traits::array_layout, 2, iType0 >::type
490 operator[] (
const iType0 & i0 )
const
491 {
return operator()( i0 ); }
493 template<
typename iType0 >
494 KOKKOS_FORCEINLINE_FUNCTION
495 typename Impl::ViewEnableArrayOper< reference_type ,
496 traits,
typename traits::array_layout, 2,
498 at(
const iType0 & i0 ,
int ,
int ,
int ,
int ,
int ,
int ,
int )
const
499 {
return operator()(i0); }
505 template<
typename iType0 ,
typename iType1 >
506 KOKKOS_FORCEINLINE_FUNCTION
507 typename Impl::ViewEnableArrayOper< reference_type ,
508 traits, LayoutLeft, 3, iType0, iType1 >::type
509 operator() (
const iType0 & i0 ,
const iType1 & i1 )
const
511 KOKKOS_ASSERT_SHAPE_BOUNDS_3( m_shape, i0, i1, 0 );
512 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
516 m_ptr_on_device + ( i0 + m_stride.value * ( i1 )),
518 m_stride.value * m_shape.N1 ) );
521 template<
typename iType0 ,
typename iType1 >
522 KOKKOS_FORCEINLINE_FUNCTION
523 typename Impl::ViewEnableArrayOper< reference_type ,
524 traits, LayoutRight, 3, iType0, iType1 >::type
525 operator() (
const iType0 & i0 ,
const iType1 & i1 )
const
527 KOKKOS_ASSERT_SHAPE_BOUNDS_3( m_shape, i0, i1, 0);
528 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
532 m_ptr_on_device + ( m_storage_size * ( i1 ) + m_stride.value * i0 ) ,
536 template<
typename iType0 ,
typename iType1 >
537 KOKKOS_FORCEINLINE_FUNCTION
538 typename Impl::ViewEnableArrayOper< reference_type ,
539 traits,
typename traits::array_layout, 3,
540 iType0, iType1 >::type
541 at(
const iType0 & i0 ,
const iType1 & i1 ,
int ,
int ,
int ,
int ,
int ,
int )
const
542 {
return operator()(i0,i1); }
548 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
549 KOKKOS_FORCEINLINE_FUNCTION
550 typename Impl::ViewEnableArrayOper< reference_type ,
551 traits, LayoutLeft, 4, iType0, iType1, iType2 >::type
552 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const
554 KOKKOS_ASSERT_SHAPE_BOUNDS_4( m_shape, i0, i1, i2, 0 );
555 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
559 m_ptr_on_device + ( i0 + m_stride.value * (
563 m_stride.value * m_shape.N1 * m_shape.N2 ) );
566 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
567 KOKKOS_FORCEINLINE_FUNCTION
568 typename Impl::ViewEnableArrayOper< reference_type ,
569 traits, LayoutRight, 4, iType0, iType1, iType2 >::type
570 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const
572 KOKKOS_ASSERT_SHAPE_BOUNDS_4( m_shape, i0, i1, i2, 0 );
573 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
577 m_ptr_on_device + ( m_storage_size * ( i2 +
578 m_shape.N2 * ( i1 )) +
579 m_stride.value * i0 ) ,
583 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
584 KOKKOS_FORCEINLINE_FUNCTION
585 typename Impl::ViewEnableArrayOper< reference_type ,
586 traits,
typename traits::array_layout, 4,
587 iType0, iType1, iType2 >::type
588 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
int ,
int ,
int ,
int ,
int )
const
589 {
return operator()(i0,i1,i2); }
595 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
596 KOKKOS_FORCEINLINE_FUNCTION
597 typename Impl::ViewEnableArrayOper< reference_type ,
598 traits, LayoutLeft, 5, iType0, iType1, iType2, iType3 >::type
599 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const
601 KOKKOS_ASSERT_SHAPE_BOUNDS_5( m_shape, i0, i1, i2, i3, 0 );
602 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
606 m_ptr_on_device + ( i0 + m_stride.value * (
611 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 ) );
614 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
615 KOKKOS_FORCEINLINE_FUNCTION
616 typename Impl::ViewEnableArrayOper< reference_type ,
617 traits, LayoutRight, 5, iType0, iType1, iType2, iType3 >::type
618 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const
620 KOKKOS_ASSERT_SHAPE_BOUNDS_5( m_shape, i0, i1, i2, i3, 0 );
621 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
625 m_ptr_on_device + ( m_storage_size * ( i3 +
627 m_shape.N2 * ( i1 ))) +
628 m_stride.value * i0 ) ,
632 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
633 KOKKOS_FORCEINLINE_FUNCTION
634 typename Impl::ViewEnableArrayOper< reference_type ,
635 traits,
typename traits::array_layout, 5,
636 iType0, iType1, iType2, iType3 >::type
637 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
int ,
int ,
int ,
int )
const
638 {
return operator()(i0,i1,i2,i3); }
644 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
typename iType4 >
645 KOKKOS_FORCEINLINE_FUNCTION
646 typename Impl::ViewEnableArrayOper< reference_type ,
647 traits, LayoutLeft, 6, iType0, iType1, iType2, iType3, iType4 >::type
648 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 )
const
650 KOKKOS_ASSERT_SHAPE_BOUNDS_6( m_shape, i0, i1, i2, i3, i4, 0 );
651 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
655 m_ptr_on_device + ( i0 + m_stride.value * (
661 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 ) );
664 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
665 typename iType3 ,
typename iType4 >
666 KOKKOS_FORCEINLINE_FUNCTION
667 typename Impl::ViewEnableArrayOper< reference_type ,
668 traits, LayoutRight, 6, iType0, iType1, iType2, iType3, iType4 >::type
669 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
670 const iType4 & i4 )
const
672 KOKKOS_ASSERT_SHAPE_BOUNDS_6( m_shape, i0, i1, i2, i3, i4, 0 );
673 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
677 m_ptr_on_device + ( m_storage_size * ( i4 +
680 m_shape.N2 * ( i1 )))) +
681 m_stride.value * i0 ) ,
685 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
686 typename iType3 ,
typename iType4 >
687 KOKKOS_FORCEINLINE_FUNCTION
688 typename Impl::ViewEnableArrayOper< reference_type ,
689 traits,
typename traits::array_layout, 6,
690 iType0, iType1, iType2, iType3, iType4 >::type
691 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
692 const iType4 & i4 ,
int ,
int ,
int )
const
693 {
return operator()(i0,i1,i2,i3,i4); }
699 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
typename iType4 ,
typename iType5 >
700 KOKKOS_FORCEINLINE_FUNCTION
701 typename Impl::ViewEnableArrayOper< reference_type ,
702 traits, LayoutLeft, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type
703 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
704 const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 )
const
706 KOKKOS_ASSERT_SHAPE_BOUNDS_7( m_shape, i0, i1, i2, i3, i4, i5, 0 );
707 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
711 m_ptr_on_device + ( i0 + m_stride.value * (
718 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 * m_shape.N5 ) );
721 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
722 typename iType3 ,
typename iType4 ,
typename iType5 >
723 KOKKOS_FORCEINLINE_FUNCTION
724 typename Impl::ViewEnableArrayOper< reference_type ,
725 traits, LayoutRight, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type
726 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
727 const iType4 & i4 ,
const iType5 & i5 )
const
729 KOKKOS_ASSERT_SHAPE_BOUNDS_7( m_shape, i0, i1, i2, i3, i4, i5, 0 );
730 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
734 m_ptr_on_device + ( m_storage_size * ( i5 +
738 m_shape.N2 * ( i1 ))))) +
739 m_stride.value * i0 ) ,
743 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
744 typename iType3 ,
typename iType4 ,
typename iType5 >
745 KOKKOS_FORCEINLINE_FUNCTION
746 typename Impl::ViewEnableArrayOper< reference_type ,
747 traits,
typename traits::array_layout, 7,
748 iType0, iType1, iType2, iType3, iType4, iType5 >::type
749 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
750 const iType4 & i4 ,
const iType5 & i5 ,
int ,
int )
const
751 {
return operator()(i0,i1,i2,i3,i4,i5); }
757 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
758 typename iType4 ,
typename iType5 ,
typename iType6 >
759 KOKKOS_FORCEINLINE_FUNCTION
760 typename Impl::ViewEnableArrayOper< reference_type ,
761 traits, LayoutLeft, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
762 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
763 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 )
const
765 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
766 KOKKOS_ASSERT_SHAPE_BOUNDS_8( m_shape, i0, i1, i2, i3, i4, i5, i6, 0 );
770 m_ptr_on_device + ( i0 + m_stride.value * (
778 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 * m_shape.N5 * m_shape.N6 ) );
781 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
782 typename iType3 ,
typename iType4 ,
typename iType5,
typename iType6 >
783 KOKKOS_FORCEINLINE_FUNCTION
784 typename Impl::ViewEnableArrayOper< reference_type ,
785 traits, LayoutRight, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
786 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
787 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 )
const
789 KOKKOS_ASSERT_SHAPE_BOUNDS_8( m_shape, i0, i1, i2, i3, i4, i5, i6, 0 );
790 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
794 m_ptr_on_device + ( m_storage_size * ( i6 +
799 m_shape.N2 * ( i1 )))))) +
800 m_stride.value * i0 ) ,
804 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
805 typename iType3 ,
typename iType4 ,
typename iType5,
typename iType6 >
806 KOKKOS_FORCEINLINE_FUNCTION
807 typename Impl::ViewEnableArrayOper< reference_type ,
808 traits,
typename traits::array_layout, 8,
809 iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
810 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
811 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 ,
int )
const
812 {
return operator()(i0,i1,i2,i3,i4,i5,i6); }
818 KOKKOS_FORCEINLINE_FUNCTION
820 data()
const {
return m_ptr_on_device ; }
823 template<
typename iType >
824 KOKKOS_FORCEINLINE_FUNCTION
826 { Impl::stride( s , m_array_shape , m_stride ); }
829 KOKKOS_FORCEINLINE_FUNCTION
831 {
return Impl::capacity( m_array_shape , m_stride ); }
834 KOKKOS_FORCEINLINE_FUNCTION
836 {
return m_sacado_size.value; }
842 template<
class DT ,
class DL ,
class DD ,
class DM ,
843 class ST ,
class SL ,
class SD ,
class SM >
845 void deep_copy(
const View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced> & dst ,
846 const View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced> & src ,
847 typename Impl::enable_if<(
848 Impl::is_same<
typename View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::intinsic_scalar_type ,
849 typename View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::intinsic_scalar_type >::value
851 Impl::is_same<
typename View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::array_layout ,
852 typename View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::array_layout >::value
854 (
unsigned(View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::rank) ==
855 unsigned(View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::rank) )
858 typedef View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced> dst_type ;
859 typedef View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced> src_type ;
861 typedef typename dst_type::memory_space dst_memory_space ;
862 typedef typename src_type::memory_space src_memory_space ;
864 if ( dst.data() != src.data() ) {
866 Impl::assert_shapes_are_equal( dst.shape() , src.shape() );
870 Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
888 template<
class StorageType >
889 struct AnalyzeShape< Sacado::MP::Vector< StorageType > >
890 : Shape< sizeof(Sacado::MP::Vector< StorageType >) , 0 >
894 typedef AnalyzeShape< typename StorageType::value_type >
nested ;
900 typedef Shape< sizeof(Sacado::MP::Vector< StorageType >) , 0 >
shape ;
905 if_c< StorageType::is_static
906 ,
typename nested::array_intrinsic_type [ StorageType::is_static ? StorageType::static_size : 1 ]
907 ,
typename nested::array_intrinsic_type *
911 if_c< StorageType::is_static
912 ,
typename nested::const_array_intrinsic_type [ StorageType::is_static ? StorageType::static_size : 1 ]
913 ,
typename nested::const_array_intrinsic_type *
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 ,
const typename enable_if<(
943 ViewAssignable< ViewTraits<DT,DL,DD,DM> ,
944 ViewTraits<ST,SL,SD,SM> >::value
948 typedef ViewTraits<DT,DL,DD,DM> dst_traits ;
949 typedef View<DT,DL,DD,DM,specialize> dst_type ;
950 typedef typename dst_type::shape_type shape_type ;
951 typedef typename dst_type::array_shape_type array_shape_type ;
952 typedef typename dst_type::stride_type stride_type ;
954 shape_type::assign( dst.m_shape,
955 src.m_shape.N0 , src.m_shape.N1 , src.m_shape.N2 , src.m_shape.N3 ,
956 src.m_shape.N4 , src.m_shape.N5 , src.m_shape.N6 , src.m_shape.N7 );
957 array_shape_type::assign( dst.m_array_shape,
958 src.m_array_shape.N0 , src.m_array_shape.N1 , src.m_array_shape.N2 , src.m_array_shape.N3 ,
959 src.m_array_shape.N4 , src.m_array_shape.N5 , src.m_array_shape.N6 , src.m_array_shape.N7 );
961 stride_type::assign( dst.m_stride , src.m_stride.value );
962 dst.m_ptr_on_device = src.m_ptr_on_device ;
963 dst.m_storage_size = src.m_storage_size ;
964 dst.m_sacado_size = src.m_sacado_size ;
965 dst.m_tracker = src.m_tracker ;
971 template<
class DT ,
class DL ,
class DD ,
class DM ,
972 class ST ,
class SL ,
class SD ,
class SM >
973 KOKKOS_INLINE_FUNCTION
975 ,
const View<ST,SL,SD,SM,specialize> & src
976 ,
typename enable_if<(
978 is_same<
typename View<DT,DL,DD,DM,specialize>::intrinsic_scalar_type ,
979 typename View<ST,SL,SD,SM,specialize>::intrinsic_scalar_type >::value
982 is_same<
typename View<DT,DL,DD,DM,specialize>::memory_space ,
983 typename View<ST,SL,SD,SM,specialize>::memory_space >::value
986 is_same<
typename View<DT,DL,DD,DM,specialize>::array_layout ,
987 typename View<ST,SL,SD,SM,specialize>::array_layout >::value
990 (
unsigned(View<DT,DL,DD,DM,specialize>::Rank) ==
991 unsigned(View<ST,SL,SD,SM,specialize>::Rank) )
994 ! View<DT,DL,DD,DM,specialize>::is_managed
995 ),
const Sacado::MP::VectorPartition & >::type part )
997 typedef ViewTraits<DT,DL,DD,DM> dst_traits ;
998 typedef View<DT,DL,DD,DM,specialize> dst_type ;
999 typedef typename dst_type::shape_type dst_shape_type ;
1000 typedef typename dst_type::array_shape_type dst_array_shape_type ;
1001 typedef typename dst_type::stride_type dst_stride_type ;
1005 enum { DstRank = dst_type::Rank };
1006 enum { DstStaticLength = dst_stokhos_storage_type::static_size };
1008 const int length = part.end - part.begin ;
1010 if ( DstStaticLength && DstStaticLength != length ) {
1011 Kokkos::abort(
"Kokkos::View< Sacado::MP::Vector ... > incompatible partitioning");
1015 dims[0] = src.m_array_shape.N0;
1016 dims[1] = src.m_array_shape.N1;
1017 dims[2] = src.m_array_shape.N2;
1018 dims[3] = src.m_array_shape.N3;
1019 dims[4] = src.m_array_shape.N4;
1020 dims[5] = src.m_array_shape.N5;
1021 dims[6] = src.m_array_shape.N6;
1022 dims[7] = src.m_array_shape.N7;
1023 unsigned rank = dst_type::Rank;
1025 dst_shape_type::assign( dst.m_shape,
1026 dims[0] , dims[1] , dims[2] , dims[3] ,
1027 dims[4] , dims[5] , dims[6] , dims[7] );
1029 dims[rank] = length;
1030 dst_array_shape_type::assign( dst.m_array_shape,
1031 dims[0] , dims[1] , dims[2] , dims[3] ,
1032 dims[4] , dims[5] , dims[6] , dims[7] );
1034 dst_stride_type::assign( dst.m_stride , src.m_stride.value );
1037 dst.m_storage_size = src.m_storage_size ;
1038 dst.m_sacado_size = length;
1040 if ( Impl::is_same< typename dst_traits::array_layout , LayoutLeft >::value ) {
1041 dst.m_ptr_on_device = src.m_ptr_on_device + part.begin *
1042 ( 0 == DstRank ? 1 : dst.m_stride.value * (
1043 ( 1 == DstRank ? 1 : dst.m_shape.N1 * (
1044 ( 2 == DstRank ? 1 : dst.m_shape.N2 * (
1045 ( 3 == DstRank ? 1 : dst.m_shape.N3 * (
1046 ( 4 == DstRank ? 1 : dst.m_shape.N4 * (
1047 ( 5 == DstRank ? 1 : dst.m_shape.N5 * (
1048 ( 6 == DstRank ? 1 : dst.m_shape.N6 )))))))))))));
1051 dst.m_ptr_on_device = src.m_ptr_on_device + part.begin ;
1053 dst.m_tracker = src.m_tracker ;
1063 template<
class ST ,
class SL ,
class SD ,
class SM >
1064 KOKKOS_INLINE_FUNCTION
1066 ,
const View<ST,SL,SD,SM,ViewMPVectorInterlaced> & src )
1068 typedef View<ST,SL,SD,SM,ViewMPVectorInterlaced> src_type ;
1072 typedef typename src_type::array_type dst_type ;
1073 typedef typename dst_type::shape_type dst_shape_type ;
1074 typedef typename dst_type::stride_type dst_stride_type ;
1076 dst_shape_type::assign( dst.m_shape,
1077 src.m_array_shape.N0 , src.m_array_shape.N1 , src.m_array_shape.N2 , src.m_arrat_shape.N3 ,
1078 src.m_array_shape.N4 , src.m_array_shape.N5 , src.m_arrat_shape.N6 , src.m_arrat_shape.N7 );
1080 dst_stride_type::assign( dst.m_stride , src.m_stride.value );
1082 dst.m_ptr_on_device =
reinterpret_cast< typename
dst_type::value_type *
>( src.m_ptr_on_device );
1084 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_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.
if_c< 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::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
const Sacado::MP::Vector< StorageType > const_value_type
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()
Impl::if_c< traits::is_managed, std::string, Impl::ViewError::allocation_constructor_requires_managed > if_allocation_constructor
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
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 > HostMirror
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
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
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
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
if_c< 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
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
Impl::if_c< (traits::rank==1), reference_type, Impl::ViewError::scalar_operator_called_from_non_scalar_view > if_scalar_operator