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 ,
118 typedef View<
typename traits::array_type ,
119 typename traits::array_layout ,
120 typename traits::device_type ,
124 typedef View<
typename traits::const_array_type ,
125 typename traits::array_layout ,
126 typename traits::device_type ,
130 typedef View<
typename traits::array_type ,
131 typename traits::array_layout ,
132 typename traits::host_mirror_space ,
136 typedef View<
typename traits::const_array_type ,
137 typename traits::array_layout ,
138 typename traits::host_mirror_space ,
148 template<
class ,
class ,
class ,
class ,
class >
friend class View ;
151 template<
class ,
class ,
class >
friend struct Impl::ViewAssignment ;
153 enum { StokhosStorageStaticDimension = stokhos_storage_type::static_size };
154 typedef integral_nonzero_constant< unsigned , StokhosStorageStaticDimension >
sacado_size_type;
156 typedef Impl::LayoutStride<
typename traits::shape_type ,
174 StokhosStorageStaticDimension ,
176 ( Impl::is_same< typename traits::array_layout , LayoutRight >::value ? 1 : 0 ) ,
185 static const bool is_static = stokhos_storage_type::is_static;
188 static const bool is_contiguous =
189 Impl::is_same< typename traits::array_layout , LayoutRight >::value;
193 enum { Rank = traits::rank };
196 enum { Sacado_Rank = Rank+1 };
198 KOKKOS_FORCEINLINE_FUNCTION
typename traits::shape_type
shape()
const {
return m_shape ; }
199 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_0()
const {
return m_shape.N0 ; }
200 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_1()
const {
return m_shape.N1 ; }
201 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_2()
const {
return m_shape.N2 ; }
202 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_3()
const {
return m_shape.N3 ; }
203 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_4()
const {
return m_shape.N4 ; }
204 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_5()
const {
return m_shape.N5 ; }
205 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_6()
const {
return m_shape.N6 ; }
206 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
dimension_7()
const {
return m_shape.N7 ; }
207 KOKKOS_FORCEINLINE_FUNCTION
typename traits::size_type
size()
const
220 template<
typename iType >
221 KOKKOS_FORCEINLINE_FUNCTION
222 typename traits::size_type
dimension(
const iType & i )
const
223 {
return Impl::dimension( m_shape , i ); }
233 if ( dimension(
unsigned(Rank) ) % ( StokhosStorageStaticDimension ? StokhosStorageStaticDimension : 1 ) ) {
234 std::ostringstream msg ;
235 msg <<
"Kokkos::View< Sacado::MP::Vector<StorageType , ... > allocation dimension ("
236 << dimension(
unsigned(Rank) )
237 <<
") must be a multiple of StorageType::static_size ("
238 << StokhosStorageStaticDimension
240 Impl::throw_runtime_exception( msg.str() );
244 #if defined( KOKKOS_EXPRESSION_CHECK )
245 KOKKOS_INLINE_FUNCTION
248 const int length = dimension( Rank );
250 const Impl::integral_nonzero_constant< int , StokhosStorageStaticDimension >
251 per_thread( ! StokhosStorageStaticDimension ? length / dev.team_size() : 0 );
253 if ( per_thread.value * dev.team_size() != length ) {
254 Kokkos::abort(
"Kokkos::View< Sacado::MP::Vector ... > incompatible vector-size : team-size");
258 KOKKOS_INLINE_FUNCTION
267 KOKKOS_INLINE_FUNCTION
270 KOKKOS_INLINE_FUNCTION
271 View() : m_ptr_on_device(0), m_storage_size(0), m_sacado_size(0)
273 traits::shape_type::assign(m_shape,0,0,0,0,0,0,0,0);
274 array_shape_type::assign(m_array_shape,0,0,0,0,0,0,0,0);
275 stride_type::assign(m_stride,0);
278 KOKKOS_INLINE_FUNCTION
279 View(
const View & rhs ) : m_ptr_on_device(0), m_storage_size(0), m_sacado_size(0)
281 (void) Impl::ViewAssignment<
282 typename traits::specialize ,
283 typename traits::specialize >( *
this , rhs );
286 KOKKOS_INLINE_FUNCTION
287 View & operator = (
const View & rhs )
289 (void) Impl::ViewAssignment<
290 typename traits::specialize ,
291 typename traits::specialize >( *
this , rhs );
298 template<
class RT ,
class RL ,
class RD ,
class RM >
299 KOKKOS_INLINE_FUNCTION
300 View(
const View<RT,RL,RD,RM,typename traits::specialize> & rhs )
303 (void) Impl::ViewAssignment<
304 typename traits::specialize ,
305 typename traits::specialize >( *
this , rhs );
308 template<
class RT ,
class RL ,
class RD ,
class RM >
309 KOKKOS_INLINE_FUNCTION
310 View & operator = (
const View<RT,RL,RD,RM,typename traits::specialize> & rhs )
312 (void) Impl::ViewAssignment<
313 typename traits::specialize ,
314 typename traits::specialize >( *
this , rhs );
321 template<
class AllocationProperties >
323 View(
const AllocationProperties & prop ,
326 const typename Impl::ViewAllocProp< traits , AllocationProperties >::size_type n0 = 0 ,
327 const size_t n1 = 0 ,
328 const size_t n2 = 0 ,
329 const size_t n3 = 0 ,
330 const size_t n4 = 0 ,
331 const size_t n5 = 0 ,
332 const size_t n6 = 0 ,
333 const size_t n7 = 0 )
336 typedef Impl::ViewAllocProp< traits , AllocationProperties > Alloc ;
338 typedef typename traits::memory_space memory_space ;
339 typedef typename traits::shape_type shape_type ;
342 shape_type::assign( m_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
343 array_shape_type::assign( m_array_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
344 stride_type::assign_with_padding( m_stride , m_array_shape );
345 m_storage_size = Impl::dimension( m_array_shape ,
unsigned(Rank) );
346 m_sacado_size = m_storage_size;
348 verify_dimension_storage_static_size();
350 m_tracker = memory_space::allocate_and_track( Alloc::label( prop ) ,
sizeof(scalar_type) * Impl::capacity( m_array_shape , m_stride ) );
352 m_ptr_on_device = (scalar_type *) m_tracker.alloc_ptr();
354 (void) Kokkos::Impl::ViewDefaultConstruct< typename traits::execution_space , scalar_type , Alloc::Initialize >
355 ( m_ptr_on_device , Impl::capacity( m_array_shape , m_stride ) );
362 template<
typename T >
364 const size_t n0 = 0 ,
365 const size_t n1 = 0 ,
366 const size_t n2 = 0 ,
367 const size_t n3 = 0 ,
368 const size_t n4 = 0 ,
369 const size_t n5 = 0 ,
370 const size_t n6 = 0 ,
371 typename Impl::enable_if<(
372 ( Impl::is_same<T,typename traits::value_type>::value ||
373 Impl::is_same<T,typename traits::const_value_type>::value ) &&
374 ! traits::is_managed ),
375 const size_t >::type n7 = 0 )
376 : m_ptr_on_device(ptr)
378 typedef typename traits::shape_type shape_type ;
380 shape_type::assign( m_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
381 array_shape_type::assign( m_array_shape, n0, n1, n2, n3, n4, n5, n6, n7 );
382 stride_type::assign_no_padding( m_stride , m_shape );
383 m_storage_size = Impl::dimension( m_array_shape ,
unsigned(Rank) );
384 m_sacado_size = m_storage_size;
385 m_management.set_unmanaged();
387 verify_dimension_storage_static_size();
393 KOKKOS_FORCEINLINE_FUNCTION
394 bool is_null()
const {
return 0 == m_ptr_on_device ; }
400 typedef std::conditional< ( traits::rank == 1 ),
402 Impl::ViewError::scalar_operator_called_from_non_scalar_view >
405 KOKKOS_FORCEINLINE_FUNCTION
406 typename if_scalar_operator::type
409 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
420 template<
typename iType0 >
421 KOKKOS_FORCEINLINE_FUNCTION
422 typename Impl::ViewEnableArrayOper< reference_type , traits, LayoutLeft, 2, iType0 >::type
423 operator() (
const iType0 & i0 )
const
425 KOKKOS_ASSERT_SHAPE_BOUNDS_2( m_shape, i0, 0 );
426 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
430 m_ptr_on_device + i0 ,
435 template<
typename iType0 >
436 KOKKOS_FORCEINLINE_FUNCTION
437 typename Impl::ViewEnableArrayOper< reference_type ,
438 traits, LayoutRight, 2, iType0 >::type
439 operator() (
const iType0 & i0 )
const
441 KOKKOS_ASSERT_SHAPE_BOUNDS_2( m_shape, i0, 0 );
442 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
446 m_ptr_on_device + ( m_stride.value * i0 ) ,
450 template<
typename iType0 >
451 KOKKOS_FORCEINLINE_FUNCTION
452 typename Impl::ViewEnableArrayOper< reference_type , traits, typename traits::array_layout, 2, iType0 >::type
453 operator[] (
const iType0 & i0 )
const
454 {
return operator()( i0 ); }
456 template<
typename iType0 >
457 KOKKOS_FORCEINLINE_FUNCTION
458 typename Impl::ViewEnableArrayOper< reference_type ,
459 traits,
typename traits::array_layout, 2,
461 at(
const iType0 & i0 ,
int ,
int ,
int ,
int ,
int ,
int ,
int )
const
462 {
return operator()(i0); }
468 template<
typename iType0 ,
typename iType1 >
469 KOKKOS_FORCEINLINE_FUNCTION
470 typename Impl::ViewEnableArrayOper< reference_type ,
471 traits, LayoutLeft, 3, iType0, iType1 >::type
472 operator() (
const iType0 & i0 ,
const iType1 & i1 )
const
474 KOKKOS_ASSERT_SHAPE_BOUNDS_3( m_shape, i0, i1, 0 );
475 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
479 m_ptr_on_device + ( i0 + m_stride.value * ( i1 )),
481 m_stride.value * m_shape.N1 ) );
484 template<
typename iType0 ,
typename iType1 >
485 KOKKOS_FORCEINLINE_FUNCTION
486 typename Impl::ViewEnableArrayOper< reference_type ,
487 traits, LayoutRight, 3, iType0, iType1 >::type
488 operator() (
const iType0 & i0 ,
const iType1 & i1 )
const
490 KOKKOS_ASSERT_SHAPE_BOUNDS_3( m_shape, i0, i1, 0);
491 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
495 m_ptr_on_device + ( m_storage_size * ( i1 ) + m_stride.value * i0 ) ,
499 template<
typename iType0 ,
typename iType1 >
500 KOKKOS_FORCEINLINE_FUNCTION
501 typename Impl::ViewEnableArrayOper< reference_type ,
502 traits,
typename traits::array_layout, 3,
503 iType0, iType1 >::type
504 at(
const iType0 & i0 ,
const iType1 & i1 ,
int ,
int ,
int ,
int ,
int ,
int )
const
505 {
return operator()(i0,i1); }
511 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
512 KOKKOS_FORCEINLINE_FUNCTION
513 typename Impl::ViewEnableArrayOper< reference_type ,
514 traits, LayoutLeft, 4, iType0, iType1, iType2 >::type
515 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const
517 KOKKOS_ASSERT_SHAPE_BOUNDS_4( m_shape, i0, i1, i2, 0 );
518 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
522 m_ptr_on_device + ( i0 + m_stride.value * (
526 m_stride.value * m_shape.N1 * m_shape.N2 ) );
529 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
530 KOKKOS_FORCEINLINE_FUNCTION
531 typename Impl::ViewEnableArrayOper< reference_type ,
532 traits, LayoutRight, 4, iType0, iType1, iType2 >::type
533 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 )
const
535 KOKKOS_ASSERT_SHAPE_BOUNDS_4( m_shape, i0, i1, i2, 0 );
536 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
540 m_ptr_on_device + ( m_storage_size * ( i2 +
541 m_shape.N2 * ( i1 )) +
542 m_stride.value * i0 ) ,
546 template<
typename iType0 ,
typename iType1 ,
typename iType2 >
547 KOKKOS_FORCEINLINE_FUNCTION
548 typename Impl::ViewEnableArrayOper< reference_type ,
549 traits,
typename traits::array_layout, 4,
550 iType0, iType1, iType2 >::type
551 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
int ,
int ,
int ,
int ,
int )
const
552 {
return operator()(i0,i1,i2); }
558 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
559 KOKKOS_FORCEINLINE_FUNCTION
560 typename Impl::ViewEnableArrayOper< reference_type ,
561 traits, LayoutLeft, 5, iType0, iType1, iType2, iType3 >::type
562 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const
564 KOKKOS_ASSERT_SHAPE_BOUNDS_5( m_shape, i0, i1, i2, i3, 0 );
565 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
569 m_ptr_on_device + ( i0 + m_stride.value * (
574 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 ) );
577 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
578 KOKKOS_FORCEINLINE_FUNCTION
579 typename Impl::ViewEnableArrayOper< reference_type ,
580 traits, LayoutRight, 5, iType0, iType1, iType2, iType3 >::type
581 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 )
const
583 KOKKOS_ASSERT_SHAPE_BOUNDS_5( m_shape, i0, i1, i2, i3, 0 );
584 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
588 m_ptr_on_device + ( m_storage_size * ( i3 +
590 m_shape.N2 * ( i1 ))) +
591 m_stride.value * i0 ) ,
595 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 >
596 KOKKOS_FORCEINLINE_FUNCTION
597 typename Impl::ViewEnableArrayOper< reference_type ,
598 traits,
typename traits::array_layout, 5,
599 iType0, iType1, iType2, iType3 >::type
600 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
int ,
int ,
int ,
int )
const
601 {
return operator()(i0,i1,i2,i3); }
607 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
typename iType4 >
608 KOKKOS_FORCEINLINE_FUNCTION
609 typename Impl::ViewEnableArrayOper< reference_type ,
610 traits, LayoutLeft, 6, iType0, iType1, iType2, iType3, iType4 >::type
611 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
const iType4 & i4 )
const
613 KOKKOS_ASSERT_SHAPE_BOUNDS_6( m_shape, i0, i1, i2, i3, i4, 0 );
614 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
618 m_ptr_on_device + ( i0 + m_stride.value * (
624 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 ) );
627 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
628 typename iType3 ,
typename iType4 >
629 KOKKOS_FORCEINLINE_FUNCTION
630 typename Impl::ViewEnableArrayOper< reference_type ,
631 traits, LayoutRight, 6, iType0, iType1, iType2, iType3, iType4 >::type
632 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
633 const iType4 & i4 )
const
635 KOKKOS_ASSERT_SHAPE_BOUNDS_6( m_shape, i0, i1, i2, i3, i4, 0 );
636 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
640 m_ptr_on_device + ( m_storage_size * ( i4 +
643 m_shape.N2 * ( i1 )))) +
644 m_stride.value * i0 ) ,
648 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
649 typename iType3 ,
typename iType4 >
650 KOKKOS_FORCEINLINE_FUNCTION
651 typename Impl::ViewEnableArrayOper< reference_type ,
652 traits,
typename traits::array_layout, 6,
653 iType0, iType1, iType2, iType3, iType4 >::type
654 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
655 const iType4 & i4 ,
int ,
int ,
int )
const
656 {
return operator()(i0,i1,i2,i3,i4); }
662 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
typename iType4 ,
typename iType5 >
663 KOKKOS_FORCEINLINE_FUNCTION
664 typename Impl::ViewEnableArrayOper< reference_type ,
665 traits, LayoutLeft, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type
666 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
667 const iType3 & i3 ,
const iType4 & i4 ,
const iType5 & i5 )
const
669 KOKKOS_ASSERT_SHAPE_BOUNDS_7( m_shape, i0, i1, i2, i3, i4, i5, 0 );
670 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
674 m_ptr_on_device + ( i0 + m_stride.value * (
681 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 * m_shape.N5 ) );
684 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
685 typename iType3 ,
typename iType4 ,
typename iType5 >
686 KOKKOS_FORCEINLINE_FUNCTION
687 typename Impl::ViewEnableArrayOper< reference_type ,
688 traits, LayoutRight, 7, iType0, iType1, iType2, iType3, iType4, iType5 >::type
689 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
690 const iType4 & i4 ,
const iType5 & i5 )
const
692 KOKKOS_ASSERT_SHAPE_BOUNDS_7( m_shape, i0, i1, i2, i3, i4, i5, 0 );
693 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
697 m_ptr_on_device + ( m_storage_size * ( i5 +
701 m_shape.N2 * ( i1 ))))) +
702 m_stride.value * i0 ) ,
706 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
707 typename iType3 ,
typename iType4 ,
typename iType5 >
708 KOKKOS_FORCEINLINE_FUNCTION
709 typename Impl::ViewEnableArrayOper< reference_type ,
710 traits,
typename traits::array_layout, 7,
711 iType0, iType1, iType2, iType3, iType4, iType5 >::type
712 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
713 const iType4 & i4 ,
const iType5 & i5 ,
int ,
int )
const
714 {
return operator()(i0,i1,i2,i3,i4,i5); }
720 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
typename iType3 ,
721 typename iType4 ,
typename iType5 ,
typename iType6 >
722 KOKKOS_FORCEINLINE_FUNCTION
723 typename Impl::ViewEnableArrayOper< reference_type ,
724 traits, LayoutLeft, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
725 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
726 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 )
const
728 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
729 KOKKOS_ASSERT_SHAPE_BOUNDS_8( m_shape, i0, i1, i2, i3, i4, i5, i6, 0 );
733 m_ptr_on_device + ( i0 + m_stride.value * (
741 m_stride.value * m_shape.N1 * m_shape.N2 * m_shape.N3 * m_shape.N4 * m_shape.N5 * m_shape.N6 ) );
744 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
745 typename iType3 ,
typename iType4 ,
typename iType5,
typename iType6 >
746 KOKKOS_FORCEINLINE_FUNCTION
747 typename Impl::ViewEnableArrayOper< reference_type ,
748 traits, LayoutRight, 8, iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
749 operator() (
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
750 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 )
const
752 KOKKOS_ASSERT_SHAPE_BOUNDS_8( m_shape, i0, i1, i2, i3, i4, i5, i6, 0 );
753 KOKKOS_RESTRICT_EXECUTION_TO_DATA(
typename traits::memory_space , m_ptr_on_device );
757 m_ptr_on_device + ( m_storage_size * ( i6 +
762 m_shape.N2 * ( i1 )))))) +
763 m_stride.value * i0 ) ,
767 template<
typename iType0 ,
typename iType1 ,
typename iType2 ,
768 typename iType3 ,
typename iType4 ,
typename iType5,
typename iType6 >
769 KOKKOS_FORCEINLINE_FUNCTION
770 typename Impl::ViewEnableArrayOper< reference_type ,
771 traits,
typename traits::array_layout, 8,
772 iType0, iType1, iType2, iType3, iType4, iType5, iType6 >::type
773 at(
const iType0 & i0 ,
const iType1 & i1 ,
const iType2 & i2 ,
const iType3 & i3 ,
774 const iType4 & i4 ,
const iType5 & i5 ,
const iType6 & i6 ,
int )
const
775 {
return operator()(i0,i1,i2,i3,i4,i5,i6); }
781 KOKKOS_FORCEINLINE_FUNCTION
783 data()
const {
return m_ptr_on_device ; }
786 template<
typename iType >
787 KOKKOS_FORCEINLINE_FUNCTION
789 { Impl::stride( s , m_array_shape , m_stride ); }
792 KOKKOS_FORCEINLINE_FUNCTION
794 {
return Impl::capacity( m_array_shape , m_stride ); }
797 KOKKOS_FORCEINLINE_FUNCTION
799 {
return m_sacado_size.value; }
805 template<
class DT ,
class DL ,
class DD ,
class DM ,
806 class ST ,
class SL ,
class SD ,
class SM >
808 void deep_copy(
const View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced> & dst ,
809 const View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced> & src ,
810 typename Impl::enable_if<(
811 Impl::is_same<
typename View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::intinsic_scalar_type ,
812 typename View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::intinsic_scalar_type >::value
814 Impl::is_same<
typename View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::array_layout ,
815 typename View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::array_layout >::value
817 (
unsigned(View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced>::rank) ==
818 unsigned(View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced>::rank) )
821 typedef View<DT,DL,DD,DM,Impl::ViewMPVectorInterlaced> dst_type ;
822 typedef View<ST,SL,SD,SM,Impl::ViewMPVectorInterlaced> src_type ;
824 typedef typename dst_type::memory_space dst_memory_space ;
825 typedef typename src_type::memory_space src_memory_space ;
827 if ( dst.data() != src.data() ) {
829 Impl::assert_shapes_are_equal( dst.shape() , src.shape() );
833 Impl::DeepCopy< dst_memory_space , src_memory_space >( dst.data() , src.data() , nbytes );
851 template<
class StorageType >
852 struct AnalyzeShape< Sacado::MP::Vector< StorageType > >
853 : Shape< sizeof(Sacado::MP::Vector< StorageType >) , 0 >
857 typedef AnalyzeShape< typename StorageType::value_type >
nested ;
863 typedef Shape< sizeof(Sacado::MP::Vector< StorageType >) , 0 >
shape ;
868 std::conditional< StorageType::is_static
869 ,
typename nested::array_intrinsic_type [ StorageType::is_static ? StorageType::static_size : 1 ]
870 ,
typename nested::array_intrinsic_type *
874 std::conditional< StorageType::is_static
875 ,
typename nested::const_array_intrinsic_type [ StorageType::is_static ? StorageType::static_size : 1 ]
876 ,
typename nested::const_array_intrinsic_type *
900 template<
class DT ,
class DL ,
class DD ,
class DM ,
901 class ST ,
class SL ,
class SD ,
class SM >
902 KOKKOS_INLINE_FUNCTION
904 ,
const View<ST,SL,SD,SM,specialize> & src
905 ,
const typename enable_if<(
906 ViewAssignable< ViewTraits<DT,DL,DD,DM> ,
907 ViewTraits<ST,SL,SD,SM> >::value
911 typedef ViewTraits<DT,DL,DD,DM> dst_traits ;
912 typedef View<DT,DL,DD,DM,specialize> dst_type ;
913 typedef typename dst_type::shape_type shape_type ;
914 typedef typename dst_type::array_shape_type array_shape_type ;
915 typedef typename dst_type::stride_type stride_type ;
917 shape_type::assign( dst.m_shape,
918 src.m_shape.N0 , src.m_shape.N1 , src.m_shape.N2 , src.m_shape.N3 ,
919 src.m_shape.N4 , src.m_shape.N5 , src.m_shape.N6 , src.m_shape.N7 );
920 array_shape_type::assign( dst.m_array_shape,
921 src.m_array_shape.N0 , src.m_array_shape.N1 , src.m_array_shape.N2 , src.m_array_shape.N3 ,
922 src.m_array_shape.N4 , src.m_array_shape.N5 , src.m_array_shape.N6 , src.m_array_shape.N7 );
924 stride_type::assign( dst.m_stride , src.m_stride.value );
925 dst.m_ptr_on_device = src.m_ptr_on_device ;
926 dst.m_storage_size = src.m_storage_size ;
927 dst.m_sacado_size = src.m_sacado_size ;
928 dst.m_tracker = src.m_tracker ;
934 template<
class DT ,
class DL ,
class DD ,
class DM ,
935 class ST ,
class SL ,
class SD ,
class SM >
936 KOKKOS_INLINE_FUNCTION
938 ,
const View<ST,SL,SD,SM,specialize> & src
939 ,
typename enable_if<(
941 is_same<
typename View<DT,DL,DD,DM,specialize>::intrinsic_scalar_type ,
942 typename View<ST,SL,SD,SM,specialize>::intrinsic_scalar_type >::value
945 is_same<
typename View<DT,DL,DD,DM,specialize>::memory_space ,
946 typename View<ST,SL,SD,SM,specialize>::memory_space >::value
949 is_same<
typename View<DT,DL,DD,DM,specialize>::array_layout ,
950 typename View<ST,SL,SD,SM,specialize>::array_layout >::value
953 (
unsigned(View<DT,DL,DD,DM,specialize>::rank) ==
954 unsigned(View<ST,SL,SD,SM,specialize>::rank) )
957 ! View<DT,DL,DD,DM,specialize>::is_managed
958 ),
const Sacado::MP::VectorPartition & >::type part )
960 typedef ViewTraits<DT,DL,DD,DM> dst_traits ;
961 typedef View<DT,DL,DD,DM,specialize> dst_type ;
962 typedef typename dst_type::shape_type dst_shape_type ;
963 typedef typename dst_type::array_shape_type dst_array_shape_type ;
964 typedef typename dst_type::stride_type dst_stride_type ;
968 enum { DstRank = dst_type::rank };
969 enum { DstStaticLength = dst_stokhos_storage_type::static_size };
971 const int length = part.end - part.begin ;
973 if ( DstStaticLength && DstStaticLength != length ) {
974 Kokkos::abort(
"Kokkos::View< Sacado::MP::Vector ... > incompatible partitioning");
978 dims[0] = src.m_array_shape.N0;
979 dims[1] = src.m_array_shape.N1;
980 dims[2] = src.m_array_shape.N2;
981 dims[3] = src.m_array_shape.N3;
982 dims[4] = src.m_array_shape.N4;
983 dims[5] = src.m_array_shape.N5;
984 dims[6] = src.m_array_shape.N6;
985 dims[7] = src.m_array_shape.N7;
986 unsigned rank = dst_type::rank;
988 dst_shape_type::assign( dst.m_shape,
989 dims[0] , dims[1] , dims[2] , dims[3] ,
990 dims[4] , dims[5] , dims[6] , dims[7] );
993 dst_array_shape_type::assign( dst.m_array_shape,
994 dims[0] , dims[1] , dims[2] , dims[3] ,
995 dims[4] , dims[5] , dims[6] , dims[7] );
997 dst_stride_type::assign( dst.m_stride , src.m_stride.value );
1000 dst.m_storage_size = src.m_storage_size ;
1001 dst.m_sacado_size = length;
1003 if ( Impl::is_same< typename dst_traits::array_layout , LayoutLeft >::value ) {
1004 dst.m_ptr_on_device = src.m_ptr_on_device + part.begin *
1005 ( 0 == DstRank ? 1 : dst.m_stride.value * (
1006 ( 1 == DstRank ? 1 : dst.m_shape.N1 * (
1007 ( 2 == DstRank ? 1 : dst.m_shape.N2 * (
1008 ( 3 == DstRank ? 1 : dst.m_shape.N3 * (
1009 ( 4 == DstRank ? 1 : dst.m_shape.N4 * (
1010 ( 5 == DstRank ? 1 : dst.m_shape.N5 * (
1011 ( 6 == DstRank ? 1 : dst.m_shape.N6 )))))))))))));
1014 dst.m_ptr_on_device = src.m_ptr_on_device + part.begin ;
1016 dst.m_tracker = src.m_tracker ;
1026 template<
class ST ,
class SL ,
class SD ,
class SM >
1027 KOKKOS_INLINE_FUNCTION
1029 ,
const View<ST,SL,SD,SM,ViewMPVectorInterlaced> & src )
1031 typedef View<ST,SL,SD,SM,ViewMPVectorInterlaced> src_type ;
1035 typedef typename src_type::array_type dst_type ;
1036 typedef typename dst_type::shape_type dst_shape_type ;
1037 typedef typename dst_type::stride_type dst_stride_type ;
1039 dst_shape_type::assign( dst.m_shape,
1040 src.m_array_shape.N0 , src.m_array_shape.N1 , src.m_array_shape.N2 , src.m_arrat_shape.N3 ,
1041 src.m_array_shape.N4 , src.m_array_shape.N5 , src.m_arrat_shape.N6 , src.m_arrat_shape.N7 );
1043 dst_stride_type::assign( dst.m_stride , src.m_stride.value );
1045 dst.m_ptr_on_device =
reinterpret_cast< typename
dst_type::value_type *
>( src.m_ptr_on_device );
1047 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
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
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
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
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