42 #ifndef KOKKOS_EXPERIMENTAL_VIEW_UQ_PCE_CONTIGUOUS_HPP
43 #define KOKKOS_EXPERIMENTAL_VIEW_UQ_PCE_CONTIGUOUS_HPP
47 #include "Kokkos_Core_fwd.hpp"
48 #include "Kokkos_View.hpp"
49 #include "Kokkos_Layout.hpp"
60 template <
typename Storage >
68 template<
class Space,
class T,
class ... P>
75 namespace Experimental {
80 template<
class ... Args >
83 template<
class D ,
class ... P ,
class ... Args >
86 std::is_same<
typename Kokkos::ViewTraits<
D,P...>::specialize
89 ( (
sizeof...(Args) == 0 ) ||
102 template<
class T ,
class ... P >
104 typename Kokkos::View<T,P...>::HostMirror
106 const Kokkos::View<T,P...> & src,
107 typename std::enable_if<
108 std::is_same<
typename ViewTraits<T,P...>::specialize ,
110 !std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
111 Kokkos::LayoutStride >::value >::type * = 0);
113 template<
class T ,
class ... P >
115 typename Kokkos::View<T,P...>::HostMirror
117 const Kokkos::View<T,P...> & src,
118 typename std::enable_if<
119 std::is_same<
typename ViewTraits<T,P...>::specialize ,
121 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
122 Kokkos::LayoutStride >::value >::type * = 0);
124 template<
class Space,
class T,
class ... P>
125 typename Impl::MirrorType<Space,T,P ...>::view_type
128 const Kokkos::View<T,P...> & src,
129 typename std::enable_if<
130 std::is_same<
typename ViewTraits<T,P...>::specialize ,
134 template<
class DT,
class ... DP >
136 const View<DT,DP...> & view ,
138 ,
typename std::enable_if<(
139 std::is_same<
typename ViewTraits<DT,DP...>::specialize
144 template<
class DT,
class ... DP >
146 const View<DT,DP...> & view ,
148 ,
typename std::enable_if<(
149 std::is_same<
typename ViewTraits<DT,DP...>::specialize
154 template<
class ExecSpace ,
class DT,
class ... DP >
157 const View<DT,DP...> & view ,
159 ,
typename std::enable_if<(
160 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
161 std::is_same<
typename ViewTraits<DT,DP...>::specialize
166 template<
class ExecSpace ,
class DT,
class ... DP >
169 const View<DT,DP...> & view ,
171 ,
typename std::enable_if<(
172 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
173 std::is_same<
typename ViewTraits<DT,DP...>::specialize
178 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
180 void deep_copy(
const View<DT,DP...> & dst ,
181 const View<ST,SP...> & src
182 ,
typename std::enable_if<(
183 std::is_same<
typename ViewTraits<DT,DP...>::specialize
186 std::is_same<
typename ViewTraits<ST,SP...>::specialize
190 template <
typename T,
typename ... P>
193 static const bool value =
194 std::is_same<
typename view_type::specialize,
198 template <
typename ViewType>
200 typename std::enable_if< is_view_uq_pce< ViewType >::value >
::type > {
201 typedef typename ViewType::non_const_value_type::cijk_type
type;
204 template <
typename T,
typename ... P>
205 KOKKOS_INLINE_FUNCTION
209 return view.impl_map().dimension_scalar();
212 template <
typename view_type>
213 KOKKOS_INLINE_FUNCTION
215 std::enable_if< is_view_uq_pce<view_type>::value,
216 typename CijkType<view_type>::type >::type
218 return view.impl_map().cijk();
221 template <
typename view_type>
222 KOKKOS_INLINE_FUNCTION
224 std::enable_if< is_view_uq_pce<view_type>::value,
bool >::type
226 return view.impl_map().is_allocation_contiguous();
229 template <
typename ViewType>
233 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
234 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
236 return ViewType(view_alloc(label,cijk),
237 N0, N1, N2, N3, N4, N5, N6, N7);
240 template <
typename ViewType>
243 const Impl::WithoutInitializing_t& init,
245 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
246 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
248 return ViewType(view_alloc(label,init,cijk),
249 N0, N1, N2, N3, N4, N5, N6, N7);
252 template <
typename ViewType>
256 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
257 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
259 return ViewType(view_alloc(init.label,
262 N0, N1, N2, N3, N4, N5, N6, N7);
265 template <
typename ViewType>
266 typename std::enable_if< is_view_uq_pce<ViewType>::value, ViewType>::type
269 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
270 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
272 size_t N[8] = { N0, N1, N2, N3, N4, N5, N6, N7 };
273 N[ViewType::rank] = cijk.dimension();
274 ViewType v(view_wrap(ptr, cijk),
275 N[0], N[1], N[2], N[3], N[4], N[5], N[6], N[7]);
281 #include "Sacado_Traits.hpp"
284 #include "Kokkos_Core.hpp"
288 template <
typename D,
typename ... P>
290 typename std::enable_if< is_view_uq_pce< View<D,P...> >::value >
::type > {
292 typedef typename view_type::traits::dimension
dimension;
294 typedef typename Kokkos::Impl::ViewDataType< flat_value_type , dimension >::type
flat_data_type;
298 template<
class T ,
class ... P >
300 typename Kokkos::View<T,P...>::HostMirror
302 ,
typename std::enable_if<
303 std::is_same<
typename ViewTraits<T,P...>::specialize ,
306 ! std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
307 , Kokkos::LayoutStride >::value
311 typedef View<T,P...> src_type ;
312 typedef typename src_type::HostMirror dst_type ;
314 typename src_type::array_layout layout = src.layout();
317 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"),
318 src.impl_map().cijk()), layout);
321 template<
class T ,
class ... P >
323 typename Kokkos::View<T,P...>::HostMirror
325 ,
typename std::enable_if<
326 std::is_same<
typename ViewTraits<T,P...>::specialize ,
329 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout
330 , Kokkos::LayoutStride >::value
334 typedef View<T,P...> src_type ;
335 typedef typename src_type::HostMirror dst_type ;
337 Kokkos::LayoutStride layout ;
339 layout.dimension[0] = src.extent(0);
340 layout.dimension[1] = src.extent(1);
341 layout.dimension[2] = src.extent(2);
342 layout.dimension[3] = src.extent(3);
343 layout.dimension[4] = src.extent(4);
344 layout.dimension[5] = src.extent(5);
345 layout.dimension[6] = src.extent(6);
346 layout.dimension[7] = src.extent(7);
348 layout.stride[0] = src.stride_0();
349 layout.stride[1] = src.stride_1();
350 layout.stride[2] = src.stride_2();
351 layout.stride[3] = src.stride_3();
352 layout.stride[4] = src.stride_4();
353 layout.stride[5] = src.stride_5();
354 layout.stride[6] = src.stride_6();
355 layout.stride[7] = src.stride_7();
359 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"),
360 src.impl_map().cijk()), layout);
363 template<
class Space,
class T,
class ... P>
364 typename Impl::MirrorType<Space,T,P ...>::view_type
366 ,
typename std::enable_if<
367 std::is_same<
typename ViewTraits<T,P...>::specialize ,
370 typedef View<T,P...> src_type ;
371 typename src_type::array_layout layout = src.layout();
374 view_alloc(src.label(), src.impl_map().cijk()),layout);
378 template<
class DT,
class ... DP >
380 const View<DT,DP...> & view ,
382 ,
typename std::enable_if<(
383 std::is_same<
typename ViewTraits<DT,DP...>::specialize
389 typename ViewTraits<DT,DP...>::non_const_value_type >::value
390 ,
"Can only deep copy into non-const type" );
392 typedef View<DT,DP...> view_type;
402 template<
class DT,
class ... DP >
404 const View<DT,DP...> & view ,
406 ,
typename std::enable_if<(
407 std::is_same<
typename ViewTraits<DT,DP...>::specialize
413 typename ViewTraits<DT,DP...>::non_const_value_type >::value
414 ,
"Can only deep copy into non-const type" );
420 template<
class ExecSpace ,
class DT,
class ... DP >
423 const View<DT,DP...> & view ,
425 ,
typename std::enable_if<(
426 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
427 std::is_same<
typename ViewTraits<DT,DP...>::specialize
433 typename ViewTraits<DT,DP...>::non_const_value_type >::value
434 ,
"Can only deep copy into non-const type" );
436 typedef View<DT,DP...> view_type;
446 template<
class ExecSpace ,
class DT,
class ... DP >
449 const View<DT,DP...> & view ,
451 ,
typename std::enable_if<(
452 Kokkos::Impl::is_execution_space< ExecSpace >::value &&
453 std::is_same<
typename ViewTraits<DT,DP...>::specialize
459 typename ViewTraits<DT,DP...>::non_const_value_type >::value
460 ,
"Can only deep copy into non-const type" );
465 namespace Experimental {
470 template<
class OutputView ,
class InputView >
480 const InputView & arg_in ) :
481 output( arg_out ), input( arg_in )
483 parallel_for( output.extent(0) , *this );
487 KOKKOS_INLINE_FUNCTION
490 for (
size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
491 for (
size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
492 for (
size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
493 for (
size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
494 for (
size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
495 for (
size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
496 for (
size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
497 output.access(i0,i1,i2,i3,i4,i5,i6,i7) = input.access(i0,i1,i2,i3,i4,i5,i6,i7) ;
506 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
509 const View<ST,SP...> & src
510 ,
typename std::enable_if<(
511 std::is_same<
typename ViewTraits<DT,DP...>::specialize
514 std::is_same<
typename ViewTraits<ST,SP...>::specialize
520 typename ViewTraits<DT,DP...>::non_const_value_type >::value
521 ,
"Deep copy destination must be non-const" );
524 (
unsigned(ViewTraits<DT,DP...>::rank) ==
525 unsigned(ViewTraits<ST,SP...>::rank) )
526 ,
"Deep copy destination and source must have same rank" );
528 typedef View<DT,DP...> dst_type ;
529 typedef View<ST,SP...> src_type ;
530 typedef typename dst_type::array_type dst_array_type ;
531 typedef typename src_type::array_type src_array_type ;
534 dst_array_type dst_array = dst ;
535 src_array_type src_array = src ;
543 if ( std::is_same<
typename dst_type::memory_space ,
544 typename src_type::memory_space >::value ) {
550 typedef View<
typename src_type::non_const_data_type ,
551 typename src_type::array_layout ,
553 typedef typename tmp_src_type::array_type tmp_src_array_type;
554 typedef View<
typename dst_type::non_const_data_type ,
555 typename dst_type::array_layout ,
557 typedef typename tmp_dst_type::array_type tmp_dst_array_type;
565 src_dims[0] = src.extent(0);
566 src_dims[1] = src.extent(1);
567 src_dims[2] = src.extent(2);
568 src_dims[3] = src.extent(3);
569 src_dims[4] = src.extent(4);
570 src_dims[5] = src.extent(5);
571 src_dims[6] = src.extent(6);
572 src_dims[7] = src.extent(7);
574 tmp_src_type src_tmp(
575 view_alloc(
"src_tmp" , WithoutInitializing,
cijk(src) ) ,
576 src_dims[0], src_dims[1], src_dims[2], src_dims[3],
577 src_dims[4], src_dims[5], src_dims[6], src_dims[7] );
579 dst_array_type dst_array = dst ;
580 tmp_src_array_type src_array = src_tmp ;
590 dst_dims[0] = dst.extent(0);
591 dst_dims[1] = dst.extent(1);
592 dst_dims[2] = dst.extent(2);
593 dst_dims[3] = dst.extent(3);
594 dst_dims[4] = dst.extent(4);
595 dst_dims[5] = dst.extent(5);
596 dst_dims[6] = dst.extent(6);
597 dst_dims[7] = dst.extent(7);
599 tmp_dst_type dst_tmp(
600 view_alloc(
"dst_tmp" , WithoutInitializing,
cijk(dst) ) ,
601 dst_dims[0], dst_dims[1], dst_dims[2], dst_dims[3],
602 dst_dims[4], dst_dims[5], dst_dims[6], dst_dims[7] );
603 tmp_dst_array_type dst_array = dst_tmp ;
604 src_array_type src_array = src ;
614 src_dims[0] = src.extent(0);
615 src_dims[1] = src.extent(1);
616 src_dims[2] = src.extent(2);
617 src_dims[3] = src.extent(3);
618 src_dims[4] = src.extent(4);
619 src_dims[5] = src.extent(5);
620 src_dims[6] = src.extent(6);
621 src_dims[7] = src.extent(7);
623 tmp_src_type src_tmp(
624 view_alloc(
"src_tmp" , WithoutInitializing,
cijk(src) ) ,
625 src_dims[0], src_dims[1], src_dims[2], src_dims[3],
626 src_dims[4], src_dims[5], src_dims[6], src_dims[7] );
630 dst_dims[0] = dst.extent(0);
631 dst_dims[1] = dst.extent(1);
632 dst_dims[2] = dst.extent(2);
633 dst_dims[3] = dst.extent(3);
634 dst_dims[4] = dst.extent(4);
635 dst_dims[5] = dst.extent(5);
636 dst_dims[6] = dst.extent(6);
637 dst_dims[7] = dst.extent(7);
639 tmp_dst_type dst_tmp(
640 view_alloc(
"dst_tmp" , WithoutInitializing,
cijk(dst) ) ,
641 dst_dims[0], dst_dims[1], dst_dims[2], dst_dims[3],
642 dst_dims[4], dst_dims[5], dst_dims[6], dst_dims[7] );
643 tmp_dst_array_type dst_array = dst_tmp ;
644 tmp_src_array_type src_array = src_tmp ;
663 template<
typename Value,
typename Execution,
typename Memory >
664 struct ViewCtorProp< void , Stokhos::CrsProductTensor<Value, Execution, Memory> >
666 ViewCtorProp() = default ;
667 ViewCtorProp(
const ViewCtorProp & ) = default ;
668 ViewCtorProp & operator = (
const ViewCtorProp & ) = default ;
678 template <
typename AllocProp>
681 static const bool value =
false;
684 template<
typename T >
687 static const bool value =
false;
690 template<
typename Value,
typename Execution,
typename Memory >
692 ViewCtorProp< Stokhos::CrsProductTensor<Value, Execution, Memory> >
695 static const bool value =
true;
698 template<
typename T,
typename ... P >
701 static const bool value =
709 template <
typename CijkType,
typename AllocProp>
710 KOKKOS_INLINE_FUNCTION
711 typename std::enable_if< !Impl::ctor_prop_has_cijk<AllocProp>::value,
718 template <
typename CijkType,
typename AllocProp>
719 KOKKOS_INLINE_FUNCTION
720 typename std::enable_if< Impl::ctor_prop_has_cijk<AllocProp>::value,
724 return ( (
const Impl::ViewCtorProp<void,CijkType>&) prop ).value;
736 template<
class DataType ,
class ArrayLayout ,
typename StorageType >
737 struct ViewDataAnalysis< DataType
739 , Sacado::UQ::PCE< StorageType > >
758 ViewDataType< value_type , dimension >::type
type ;
760 ViewDataType< const_value_type , dimension >::type
const_type ;
767 enum { is_const = std::is_same< value_type , const_value_type >::value };
771 std::conditional< is_const , const ScalarType , ScalarType >::type
778 typedef typename array_analysis::dimension::
779 template prepend<0>::type
781 typedef typename array_analysis::dimension::
782 template append<0>::type
784 typedef typename std::conditional<
785 std::is_same< ArrayLayout, Kokkos::LayoutLeft>::value,
796 ViewDataType< const_scalar_type , scalar_dimension >::type
800 ViewDataType< non_const_scalar_type , scalar_dimension >::type
810 namespace Experimental {
818 template <
class ValueType>
827 KOKKOS_INLINE_FUNCTION
828 static constexpr
size_t
833 KOKKOS_INLINE_FUNCTION
836 template <
typename T>
837 KOKKOS_INLINE_FUNCTION
847 KOKKOS_INLINE_FUNCTION
850 scalar_ptr =
reinterpret_cast<scalar_type*
>(ptr+span);
853 template <
class ExecSpace>
871 const unsigned pce_size,
873 m_space(space), m_p(p), m_sp(sp), m_span(span), m_pce_size(pce_size),
877 if ( ! m_space.in_parallel() ) {
878 typedef Kokkos::RangePolicy< ExecSpace > PolicyType ;
879 const Kokkos::Impl::ParallelFor< PCEConstruct , PolicyType >
880 closure( *
this , PolicyType( 0 , m_span ) );
885 for (
size_t i = 0 ; i < m_span ; ++i )
operator()(i);
889 KOKKOS_INLINE_FUNCTION
890 void operator() (
const size_t i)
const {
891 new (m_p+i)
value_type(m_cijk, m_pce_size, m_sp+i*m_pce_size,
false);
895 template <
class ExecSpace>
908 const bool initialize,
910 const unsigned pce_size,
914 m_scalar_functor( space , scalar_ptr , span*pce_size ),
915 m_pce_functor( space , value_ptr , scalar_ptr , span , pce_size , cijk ),
916 m_initialize(initialize) {}
921 m_scalar_functor.construct_shared_allocation();
933 m_pce_functor.execute();
940 m_scalar_functor.destroy_shared_allocation();
945 template <
class ExecSpace>
946 inline ConstructDestructFunctor<ExecSpace>
948 const bool initialize,
950 const unsigned pce_size,
952 return ConstructDestructFunctor<ExecSpace>(space, initialize, span,
953 pce_size,
cijk, scalar_ptr,
959 template <
typename T>
961 value_ptr =
reinterpret_cast<value_type*
>(ptr);
963 scalar_ptr = value_ptr->coeff();
974 template<
class Traits >
975 class ViewMapping< Traits ,
976 typename std::enable_if<
977 ( std::is_same< typename Traits::specialize
978 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
980 ( std::is_same< typename Traits::array_layout
981 , Kokkos::LayoutLeft >::value
983 std::is_same< typename Traits::array_layout
984 , Kokkos::LayoutRight >::value
986 std::is_same< typename Traits::array_layout
987 , Kokkos::LayoutStride >::value
990 , typename Traits::specialize
995 template< class ,
class ... >
friend class ViewMapping ;
996 template< class ,
class ... >
friend class Kokkos::View ;
1009 typedef ViewOffset<
typename Traits::dimension
1010 ,
typename Traits::array_layout
1017 typedef ViewOffset<
typename array_dimension::
1018 template append<0>::type,
1019 typename Traits::array_layout,
1022 typedef ViewOffset<
typename array_dimension::
1023 template prepend<0>::type,
1024 typename Traits::array_layout,
1027 typedef typename std::conditional<
1028 std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft>::value,
1041 KOKKOS_INLINE_FUNCTION
1043 const size_t sz = this->span();
1047 m_impl_handle.value_ptr[sz-1].coeff();
1049 m_impl_handle.scalar_ptr + (sz-1)*m_sacado_size;
1050 return last_coeff == last_coeff_expected;
1058 enum { Rank = Traits::dimension::rank };
1061 enum { Sacado_Rank = std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft >::value ? 0 : Rank+1 };
1064 template<
typename iType >
1065 KOKKOS_INLINE_FUNCTION constexpr
size_t extent(
const iType & r )
const
1066 {
return m_impl_offset.m_dim.extent(r); }
1068 KOKKOS_INLINE_FUNCTION constexpr
1070 {
return m_impl_offset.layout(); }
1073 {
return m_impl_offset.dimension_0(); }
1075 {
return m_impl_offset.dimension_1(); }
1077 {
return m_impl_offset.dimension_2(); }
1079 {
return m_impl_offset.dimension_3(); }
1081 {
return m_impl_offset.dimension_4(); }
1083 {
return m_impl_offset.dimension_5(); }
1085 {
return m_impl_offset.dimension_6(); }
1087 {
return m_impl_offset.dimension_7(); }
1094 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_0()
const
1095 {
return m_impl_offset.stride_0(); }
1096 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_1()
const
1097 {
return m_impl_offset.stride_1(); }
1098 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_2()
const
1099 {
return m_impl_offset.stride_2(); }
1100 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_3()
const
1101 {
return m_impl_offset.stride_3(); }
1102 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_4()
const
1103 {
return m_impl_offset.stride_4(); }
1104 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_5()
const
1105 {
return m_impl_offset.stride_5(); }
1106 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_6()
const
1107 {
return m_impl_offset.stride_6(); }
1108 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_7()
const
1109 {
return m_impl_offset.stride_7(); }
1111 template<
typename iType >
1112 KOKKOS_INLINE_FUNCTION
void stride( iType *
const s )
const
1113 { m_impl_offset.stride(s); }
1117 {
return m_sacado_size; }
1120 KOKKOS_FORCEINLINE_FUNCTION
1125 KOKKOS_FORCEINLINE_FUNCTION
1130 KOKKOS_INLINE_FUNCTION
1132 {
return m_is_contiguous; }
1135 static const bool is_static = false ;
1138 static const bool is_contiguous =
true;
1150 KOKKOS_INLINE_FUNCTION constexpr
size_t span()
const
1151 {
return m_impl_offset.span(); }
1155 {
return m_impl_offset.span_is_contiguous() ; }
1159 {
return m_impl_handle.value_ptr ; }
1163 KOKKOS_FORCEINLINE_FUNCTION
1165 {
return *m_impl_handle.value_ptr; }
1168 template<
typename I0 >
1169 KOKKOS_FORCEINLINE_FUNCTION
1171 std::enable_if< std::is_integral<I0>::value &&
1172 ! std::is_same< typename Traits::array_layout , Kokkos::LayoutStride >::value
1173 , reference_type >::type
1175 {
return m_impl_handle.value_ptr[i0]; }
1178 template<
typename I0 >
1179 KOKKOS_FORCEINLINE_FUNCTION
1181 std::enable_if< std::is_integral<I0>::value &&
1182 std::is_same< typename Traits::array_layout , Kokkos::LayoutStride >::value
1183 , reference_type >::type
1185 {
return m_impl_handle.value_ptr[ m_impl_offset(i0) ]; }
1187 template<
typename I0 ,
typename I1 >
1188 KOKKOS_FORCEINLINE_FUNCTION
1190 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1) ]; }
1192 template<
typename I0 ,
typename I1 ,
typename I2 >
1193 KOKKOS_FORCEINLINE_FUNCTION
1195 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2) ]; }
1197 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3 >
1198 KOKKOS_FORCEINLINE_FUNCTION
1200 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3) ]; }
1202 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1204 KOKKOS_FORCEINLINE_FUNCTION
1206 ,
const I4 & i4 )
const
1207 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3,i4) ]; }
1209 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1210 ,
typename I4 ,
typename I5 >
1211 KOKKOS_FORCEINLINE_FUNCTION
1213 ,
const I4 & i4 ,
const I5 & i5 )
const
1214 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5) ]; }
1216 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1217 ,
typename I4 ,
typename I5 ,
typename I6 >
1218 KOKKOS_FORCEINLINE_FUNCTION
1220 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 )
const
1221 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5,i6) ]; }
1223 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1224 ,
typename I4 ,
typename I5 ,
typename I6 ,
typename I7 >
1225 KOKKOS_FORCEINLINE_FUNCTION
1227 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 ,
const I7 & i7 )
const
1228 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5,i6,i7) ]; }
1233 KOKKOS_INLINE_FUNCTION
1234 static size_t memory_span(
typename Traits::array_layout
const & layout )
1237 typedef std::integral_constant< unsigned , 0 > padding ;
1239 unsigned sacado_size =
1241 return handle_type::memory_span( offset.span(), sacado_size );
1246 KOKKOS_DEFAULTED_FUNCTION ~ViewMapping() = default ;
1252 m_is_contiguous(
true)
1255 KOKKOS_DEFAULTED_FUNCTION ViewMapping(
const ViewMapping & ) = default ;
1256 KOKKOS_DEFAULTED_FUNCTION ViewMapping & operator = (
const ViewMapping & ) = default ;
1258 KOKKOS_DEFAULTED_FUNCTION ViewMapping( ViewMapping && ) = default ;
1259 KOKKOS_DEFAULTED_FUNCTION ViewMapping & operator = ( ViewMapping && ) = default ;
1261 template<
class ... P >
1262 KOKKOS_INLINE_FUNCTION
1264 ( ViewCtorProp< P ... >
const & prop
1265 ,
typename Traits::array_layout
const & layout
1268 , m_impl_offset( std::integral_constant< unsigned , 0 >() , layout )
1271 m_impl_handle.set( ( (ViewCtorProp<void,pointer_type>
const &) prop ).value
1272 , m_impl_offset.span(), m_sacado_size );
1273 m_cijk = extract_cijk<cijk_type>(prop);
1274 #ifndef __CUDA_ARCH__
1275 if (m_cijk.dimension() == 0)
1276 m_cijk = getGlobalCijkTensor<cijk_type>();
1279 if (m_sacado_size == 0 ||
1280 m_sacado_size ==
unsigned(KOKKOS_IMPL_CTOR_DEFAULT_ARG))
1281 m_sacado_size = m_cijk.dimension();
1283 m_is_contiguous = this->is_data_contiguous();
1287 KOKKOS_INLINE_FUNCTION
1289 { m_impl_handle.set( arg_ptr, m_impl_offset.span(), m_sacado_size ); }
1296 template<
class ... P >
1297 SharedAllocationRecord<> *
1299 ,
typename Traits::array_layout
const & layout )
1301 typedef ViewCtorProp< P... > ctor_prop ;
1304 typedef typename Traits::memory_space memory_space ;
1305 typedef typename handle_type::template ConstructDestructFunctor<execution_space> functor_type ;
1306 typedef SharedAllocationRecord< memory_space , functor_type > record_type ;
1309 typedef std::integral_constant< unsigned , 0 > padding ;
1313 m_cijk = extract_cijk<cijk_type>(prop);
1314 if (m_cijk.dimension() == 0)
1315 m_cijk = getGlobalCijkTensor<cijk_type>();
1318 if (m_sacado_size == 0 ||
1319 m_sacado_size ==
unsigned(KOKKOS_IMPL_CTOR_DEFAULT_ARG))
1320 m_sacado_size = m_cijk.dimension();
1321 m_is_contiguous =
true;
1323 const size_t alloc_size =
1324 handle_type::memory_span( m_impl_offset.span(), m_sacado_size );
1327 record_type *
const record =
1328 record_type::allocate( ( (ViewCtorProp<void,memory_space>
const &) prop ).value
1329 , ( (ViewCtorProp<void,std::string>
const &) prop ).value
1336 m_impl_handle.set( reinterpret_cast< pointer_type >( record->data() ),
1337 m_impl_offset.span(), m_sacado_size );
1341 record->m_destroy = m_impl_handle.create_functor(
1342 ( (ViewCtorProp<void,execution_space>
const &) prop).value
1343 , ctor_prop::initialize
1344 , m_impl_offset.span()
1349 record->m_destroy.construct_shared_allocation();
1369 template<
class DstTraits ,
class SrcTraits >
1370 class ViewMapping< DstTraits , SrcTraits ,
1371 typename std::enable_if<(
1372 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1373 , typename SrcTraits::memory_space >::assignable
1376 std::is_same< typename DstTraits::specialize
1377 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1380 std::is_same< typename SrcTraits::specialize
1381 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1383 , typename DstTraits::specialize
1388 enum { is_assignable =
true };
1389 enum { is_assignable_data_type =
true };
1392 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1393 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1395 KOKKOS_INLINE_FUNCTION
static
1402 std::is_same<
typename DstTraits::array_layout
1403 , Kokkos::LayoutLeft >::value ||
1404 std::is_same<
typename DstTraits::array_layout
1405 , Kokkos::LayoutRight >::value ||
1406 std::is_same<
typename DstTraits::array_layout
1407 , Kokkos::LayoutStride >::value
1411 std::is_same<
typename SrcTraits::array_layout
1412 , Kokkos::LayoutLeft >::value ||
1413 std::is_same<
typename SrcTraits::array_layout
1414 , Kokkos::LayoutRight >::value ||
1415 std::is_same<
typename SrcTraits::array_layout
1416 , Kokkos::LayoutStride >::value
1418 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1421 std::is_same<
typename DstTraits::array_layout
1422 ,
typename SrcTraits::array_layout >::value ||
1423 std::is_same<
typename DstTraits::array_layout
1424 , Kokkos::LayoutStride >::value ||
1425 (
unsigned(DstTraits::rank) == 1 &&
unsigned(SrcTraits::rank) == 1 ) ,
1426 "View assignment must have compatible layout" );
1432 ,
typename SrcTraits::const_value_type >::value ,
1433 "View assignment must have same value type or const = non-const" );
1436 ViewDimensionAssignable
1437 <
typename DstType::offset_type::dimension_type
1438 ,
typename SrcType::offset_type::dimension_type >::value ,
1439 "View assignment must have compatible dimensions" );
1441 dst.m_impl_handle = src.m_impl_handle ;
1442 dst.m_impl_offset = src.m_impl_offset ;
1443 dst.m_sacado_size = src.m_sacado_size ;
1444 dst.m_cijk = src.m_cijk ;
1445 dst.m_is_contiguous = src.m_is_contiguous ;
1454 template<
class DstTraits ,
class SrcTraits >
1455 class ViewMapping< DstTraits , SrcTraits ,
1456 typename std::enable_if<(
1457 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1458 , typename SrcTraits::memory_space >::assignable
1461 std::is_same< typename DstTraits::specialize , void >::value
1464 std::is_same< typename SrcTraits::specialize
1465 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1468 unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)+1
1470 , typename DstTraits::specialize
1475 enum { is_assignable =
true };
1476 enum { is_assignable_data_type =
true };
1479 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1480 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1482 KOKKOS_INLINE_FUNCTION
static
1489 std::is_same<
typename DstTraits::array_layout
1490 , Kokkos::LayoutLeft >::value ||
1491 std::is_same<
typename DstTraits::array_layout
1492 , Kokkos::LayoutRight >::value ||
1493 std::is_same<
typename DstTraits::array_layout
1494 , Kokkos::LayoutStride >::value
1498 std::is_same<
typename SrcTraits::array_layout
1499 , Kokkos::LayoutLeft >::value ||
1500 std::is_same<
typename SrcTraits::array_layout
1501 , Kokkos::LayoutRight >::value ||
1502 std::is_same<
typename SrcTraits::array_layout
1503 , Kokkos::LayoutStride >::value
1505 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1508 std::is_same<
typename DstTraits::array_layout
1509 ,
typename SrcTraits::array_layout >::value ||
1510 std::is_same<
typename DstTraits::array_layout
1511 , Kokkos::LayoutStride >::value ,
1512 "View assignment must have compatible layout" );
1515 std::is_same<
typename DstTraits::scalar_array_type
1516 ,
typename SrcTraits::scalar_array_type >::value ||
1517 std::is_same<
typename DstTraits::scalar_array_type
1518 ,
typename SrcTraits::const_scalar_array_type >::value ,
1519 "View assignment must have same value type or const = non-const" );
1522 ViewDimensionAssignable<
1523 typename DstType::offset_type::dimension_type,
1524 typename SrcType::array_offset_type::dimension_type >::value,
1525 "View assignment must have compatible dimensions" );
1527 if ( !src.m_is_contiguous )
1528 Kokkos::abort(
"\n\n ****** Kokkos::View< Sacado::UQ::PCE ... >: can't assign non-contiguous view ******\n\n");
1531 dims[0] = src.m_impl_offset.dimension_0();
1532 dims[1] = src.m_impl_offset.dimension_1();
1533 dims[2] = src.m_impl_offset.dimension_2();
1534 dims[3] = src.m_impl_offset.dimension_3();
1535 dims[4] = src.m_impl_offset.dimension_4();
1536 dims[5] = src.m_impl_offset.dimension_5();
1537 dims[6] = src.m_impl_offset.dimension_6();
1538 dims[7] = src.m_impl_offset.dimension_7();
1539 unsigned rank = SrcTraits::dimension::rank;
1540 unsigned sacado_size = src.m_sacado_size;
1541 if (std::is_same<typename SrcTraits::array_layout, LayoutLeft>::value) {
1543 for (
unsigned i=rank; i>0; --i)
1544 dims[i] = dims[i-1];
1545 dims[0] = sacado_size;
1548 dims[rank] = sacado_size;
1550 typedef typename DstType::offset_type dst_offset_type;
1551 dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1552 typename DstTraits::array_layout(
1553 dims[0] , dims[1] , dims[2] , dims[3] ,
1554 dims[4] , dims[5] , dims[6] , dims[7] ) );
1555 dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1565 template<
class DstTraits ,
class SrcTraits >
1566 class ViewMapping< DstTraits , SrcTraits ,
1567 typename std::enable_if<(
1568 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1569 , typename SrcTraits::memory_space >::assignable
1572 std::is_same< typename DstTraits::specialize , void >::value
1575 std::is_same< typename SrcTraits::specialize
1576 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1579 unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)
1581 , typename DstTraits::specialize
1586 enum { is_assignable =
true };
1587 enum { is_assignable_data_type =
true };
1590 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1591 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1593 KOKKOS_INLINE_FUNCTION
static
1600 std::is_same<
typename DstTraits::array_layout
1601 , Kokkos::LayoutLeft >::value ||
1602 std::is_same<
typename DstTraits::array_layout
1603 , Kokkos::LayoutRight >::value ||
1604 std::is_same<
typename DstTraits::array_layout
1605 , Kokkos::LayoutStride >::value
1609 std::is_same<
typename SrcTraits::array_layout
1610 , Kokkos::LayoutLeft >::value ||
1611 std::is_same<
typename SrcTraits::array_layout
1612 , Kokkos::LayoutRight >::value ||
1613 std::is_same<
typename SrcTraits::array_layout
1614 , Kokkos::LayoutStride >::value
1616 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1619 std::is_same<
typename DstTraits::array_layout
1620 ,
typename SrcTraits::array_layout >::value ||
1621 std::is_same<
typename DstTraits::array_layout
1622 , Kokkos::LayoutStride >::value ,
1623 "View assignment must have compatible layout" );
1630 "View assignment must have same value type or const = non-const" );
1633 ViewDimensionAssignable<
1634 typename DstType::offset_type::dimension_type,
1635 typename SrcType::offset_type::dimension_type >::value,
1636 "View assignment must have compatible dimensions" );
1638 if ( !src.m_is_contiguous )
1639 Kokkos::abort(
"\n\n ****** Kokkos::View< Sacado::UQ::PCE ... >: can't assign non-contiguous view ******\n\n");
1642 dims[0] = src.m_impl_offset.dimension_0();
1643 dims[1] = src.m_impl_offset.dimension_1();
1644 dims[2] = src.m_impl_offset.dimension_2();
1645 dims[3] = src.m_impl_offset.dimension_3();
1646 dims[4] = src.m_impl_offset.dimension_4();
1647 dims[5] = src.m_impl_offset.dimension_5();
1648 dims[6] = src.m_impl_offset.dimension_6();
1649 dims[7] = src.m_impl_offset.dimension_7();
1650 unsigned rank = SrcTraits::dimension::rank;
1651 unsigned sacado_size = src.m_sacado_size;
1652 if (std::is_same<typename DstTraits::array_layout, LayoutLeft>::value) {
1653 dims[0] = dims[0]*sacado_size;
1657 dims[rank-1] = dims[rank-1]*sacado_size;
1660 typedef typename DstType::offset_type dst_offset_type;
1661 dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1662 typename DstTraits::array_layout(
1663 dims[0] , dims[1] , dims[2] , dims[3] ,
1664 dims[4] , dims[5] , dims[6] , dims[7] ) );
1665 dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1679 template<
class DataType,
class ... P ,
class Arg0,
class ... Args >
1681 < typename std::enable_if<(
1683 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::specialize
1684 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1687 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1688 , Kokkos::LayoutLeft >::value ||
1689 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1690 , Kokkos::LayoutRight >::value ||
1691 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1692 , Kokkos::LayoutStride >::value
1695 , Kokkos::ViewTraits<DataType,P...>
1706 , R0 = bool(is_integral_extent<0,Arg0,Args...>::value)
1707 , R1 = bool(is_integral_extent<1,Arg0,Args...>::value)
1708 , R2 = bool(is_integral_extent<2,Arg0,Args...>::value)
1709 , R3 = bool(is_integral_extent<3,Arg0,Args...>::value)
1710 , R4 = bool(is_integral_extent<4,Arg0,Args...>::value)
1711 , R5 = bool(is_integral_extent<5,Arg0,Args...>::value)
1712 , R6 = bool(is_integral_extent<6,Arg0,Args...>::value)
1716 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
1717 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
1720 enum { R0_rev = ( 0 == SrcTraits::rank ? RZ : (
1721 1 == SrcTraits::rank ? R0 : (
1722 2 == SrcTraits::rank ? R1 : (
1723 3 == SrcTraits::rank ? R2 : (
1724 4 == SrcTraits::rank ? R3 : (
1725 5 == SrcTraits::rank ? R4 : (
1726 6 == SrcTraits::rank ? R5 : R6 ))))))) };
1729 typedef typename std::conditional<
1735 ( rank <= 2 && R0 && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutLeft >::value )
1739 ( rank <= 2 && R0_rev && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutRight >::value )
1740 ),
typename SrcTraits::array_layout , Kokkos::LayoutStride
1745 typedef typename std::conditional< rank == 0 , sacado_uq_pce_type ,
1746 typename std::conditional< rank == 1 , sacado_uq_pce_type * ,
1747 typename std::conditional< rank == 2 , sacado_uq_pce_type ** ,
1748 typename std::conditional< rank == 3 , sacado_uq_pce_type *** ,
1749 typename std::conditional< rank == 4 , sacado_uq_pce_type **** ,
1750 typename std::conditional< rank == 5 , sacado_uq_pce_type ***** ,
1751 typename std::conditional< rank == 6 , sacado_uq_pce_type ****** ,
1752 sacado_uq_pce_type *******
1758 typedef Kokkos::ViewTraits
1761 ,
typename SrcTraits::device_type
1764 typedef Kokkos::View
1767 ,
typename SrcTraits::device_type
1768 ,
typename SrcTraits::memory_traits >
type ;
1773 template<
class DstTraits >
1774 KOKKOS_INLINE_FUNCTION
1775 static void assign( ViewMapping< DstTraits , typename DstTraits::specialize > & dst
1776 , ViewMapping< SrcTraits , typename SrcTraits::specialize >
const & src
1777 , Arg0 arg0, Args ... args )
1780 ViewMapping< DstTraits , traits_type , typename DstTraits::specialize >::is_assignable ,
1781 "Subview destination type must be compatible with subview derived type" );
1783 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1784 typedef typename DstType::offset_type dst_offset_type ;
1786 const SubviewExtents< SrcTraits::rank , rank >
1787 extents( src.m_impl_offset.m_dim , arg0 , args... );
1789 const size_t offset = src.m_impl_offset( extents.domain_offset(0)
1790 , extents.domain_offset(1)
1791 , extents.domain_offset(2)
1792 , extents.domain_offset(3)
1793 , extents.domain_offset(4)
1794 , extents.domain_offset(5)
1795 , extents.domain_offset(6)
1796 , extents.domain_offset(7) );
1798 dst.m_impl_offset = dst_offset_type( src.m_impl_offset , extents );
1799 dst.m_impl_handle.value_ptr = src.m_impl_handle.value_ptr + offset;
1800 dst.m_impl_handle.scalar_ptr =
1801 src.m_impl_handle.scalar_ptr + offset * src.m_sacado_size;
1802 dst.m_sacado_size = src.m_sacado_size;
1803 dst.m_cijk = src.m_cijk;
1804 dst.m_is_contiguous = src.m_is_contiguous;
1820 #if defined( KOKKOS_ENABLE_CUDA )
1821 template<
class OutputView >
1822 struct StokhosViewFill< OutputView ,
1823 typename std::enable_if< std::is_same< typename OutputView::specialize,
1824 Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&
1825 std::is_same< typename OutputView::execution_space,
1826 Cuda >::value >::type >
1828 typedef typename OutputView::const_value_type const_value_type ;
1829 typedef typename Sacado::ScalarType<const_value_type>::type
scalar_type ;
1831 typedef typename OutputView::size_type size_type ;
1833 template <
unsigned VectorLength>
1836 const OutputView output;
1837 const_value_type input;
1839 PCEKernel(
const OutputView & arg_out , const_value_type & arg_in ) :
1840 output(arg_out), input(arg_in) {}
1842 typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1844 KOKKOS_INLINE_FUNCTION
1845 void operator()(
const team_member & dev )
const
1847 const size_type tidx = dev.team_rank() % VectorLength;
1848 const size_type tidy = dev.team_rank() / VectorLength;
1849 const size_type nrow = dev.team_size() / VectorLength;
1852 const size_type i0 = dev.league_rank() * nrow + tidy;
1853 if ( i0 >= output.extent(0) )
return;
1855 for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1856 for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1857 for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1858 for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1859 for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1860 for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1861 for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1862 for ( size_type is = tidx ; is < nvec ; is+=VectorLength ) {
1863 output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1864 input.fastAccessCoeff(is) ;
1869 template <
unsigned VectorLength>
1870 struct ScalarKernel {
1872 const OutputView output;
1875 ScalarKernel(
const OutputView & arg_out ,
const scalar_type & arg_in ) :
1876 output(arg_out), input(arg_in) {}
1878 typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1879 KOKKOS_INLINE_FUNCTION
1880 void operator()(
const team_member & dev )
const
1882 const size_type tidx = dev.team_rank() % VectorLength;
1883 const size_type tidy = dev.team_rank() / VectorLength;
1884 const size_type nrow = dev.team_size() / VectorLength;
1887 const size_type i0 = dev.league_rank() * nrow + tidy;
1888 if ( i0 >= output.extent(0) )
return;
1890 for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1891 for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1892 for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1893 for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1894 for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1895 for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1896 for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1897 for ( size_type is = tidx ; is < npce ; is+=VectorLength ) {
1898 output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1904 StokhosViewFill(
const OutputView & output , const_value_type & input )
1908 const unsigned vector_length =
1912 const size_type block_size = 256;
1914 const size_type rows_per_block = block_size / vector_length;
1915 const size_type
n = output.extent(0);
1916 const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
1917 const size_type team_size = rows_per_block * vector_length;
1918 Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
1922 Kokkos::abort(
"StokhosViewFill: Invalid input value size");
1924 if (input.size() == 1)
1926 config, ScalarKernel<vector_length>(output, input.fastAccessCoeff(0)) );
1928 parallel_for( config, PCEKernel<vector_length>(output, input) );
1932 StokhosViewFill(
const OutputView & output ,
const scalar_type & input )
1936 const unsigned vector_length =
1940 const size_type block_size = 256;
1942 const size_type rows_per_block = block_size / vector_length;
1943 const size_type n = output.extent(0);
1944 const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
1945 const size_type team_size = rows_per_block * vector_length;
1946 Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
1948 parallel_for( config, ScalarKernel<vector_length>(output, input) );
ViewMapping< DstTraits, typename DstTraits::specialize > DstType
execution_space::size_type size_type
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_2() const
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1, const I2 &i2, const I3 &i3) const
ViewMapping< DstTraits, typename DstTraits::specialize > DstType
static KOKKOS_INLINE_FUNCTION constexpr size_t memory_span(const size_t span, const unsigned pce_size)
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_3() const
ViewArrayAnalysis< DataType > array_analysis
array_analysis::value_type value_type
Stokhos::StandardStorage< int, double > storage_type
PCEConstruct< ExecSpace > PCEFunctorType
Kokkos::Impl::ViewMapping< typename std::enable_if<(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutRight >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutStride >::value))>::type, Kokkos::ViewTraits< DataType, P...>, Arg0, Args... >::sacado_uq_pce_type SrcTraits::value_type sacado_uq_pce_type
KOKKOS_INLINE_FUNCTION PCEAllocation()
view_type::array_type::value_type flat_value_type
Kokkos::Impl::SharedAllocationTracker TrackType
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_7() const
KOKKOS_INLINE_FUNCTION PCEAllocation & operator=(const PCEAllocation< T > &a)
KOKKOS_INLINE_FUNCTION constexpr size_t stride_5() const
Kokkos::Impl::SharedAllocationTracker TrackType
KOKKOS_FORCEINLINE_FUNCTION constexpr unsigned dimension_scalar() const
KOKKOS_FORCEINLINE_FUNCTION reference_type reference() const
Kokkos::DefaultExecutionSpace execution_space
ViewDataType< scalar_type, scalar_dimension >::type scalar_array_type
Kokkos::Experimental::Impl::PCEAllocation< sacado_uq_pce_type > handle_type
value_type::cijk_type cijk_type
KOKKOS_INLINE_FUNCTION constexpr size_t stride_0() const
std::add_const< intrinsic_scalar_type >::type const_intrinsic_scalar_type
KOKKOS_FORCEINLINE_FUNCTION std::enable_if< std::is_integral< I0 >::value &&std::is_same< typename Traits::array_layout, Kokkos::LayoutStride >::value, reference_type >::type reference(const I0 &i0) const
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1, const I2 &i2) const
Kokkos::Impl::SharedAllocationTracker TrackType
OutputView::execution_space execution_space
ViewMapping< SrcTraits, typename SrcTraits::specialize > SrcType
static KOKKOS_INLINE_FUNCTION size_t memory_span(typename Traits::array_layout const &layout)
Span, in bytes, of the required memory.
array_analysis::dimension array_dimension
std::conditional< std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft >::value, prepend_offset_type, append_offset_type >::type array_offset_type
const ScalarType const_scalar_type
ViewArrayAnalysis< typename Traits::data_type > array_analysis
static KOKKOS_INLINE_FUNCTION void assign(DstType &dst, const SrcType &src, const TrackType &)
ViewDataType< non_const_value_type, dimension >::type non_const_type
KOKKOS_INLINE_FUNCTION constexpr size_t stride_3() const
KOKKOS_INLINE_FUNCTION bool is_data_contiguous() const
ScalarType non_const_scalar_type
Traits::value_type sacado_uq_pce_type
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
Stokhos::CrsProductTensor< Value, Execution, Memory > type
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1, const I2 &i2, const I3 &i3, const I4 &i4, const I5 &i5) const
KOKKOS_INLINE_FUNCTION ViewMapping()
KOKKOS_INLINE_FUNCTION void operator()(const size_type i0) const
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1, const I2 &i2, const I3 &i3, const I4 &i4, const I5 &i5, const I6 &i6, const I7 &i7) const
KOKKOS_INLINE_FUNCTION constexpr pointer_type data() const
Raw data access.
ViewDataType< const_value_type, dimension >::type const_type
ConstructDestructFunctor< ExecSpace > create_functor(const ExecSpace &space, const bool initialize, const size_t span, const unsigned pce_size, const cijk_type &cijk) const
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1, const I2 &i2, const I3 &i3, const I4 &i4, const I5 &i5, const I6 &i6) const
KOKKOS_INLINE_FUNCTION constexpr size_t stride_6() const
StorageType::value_type ScalarType
ViewMapping< DstTraits, typename DstTraits::specialize > DstType
ViewType make_view(const std::string &label, size_t N0=0, size_t N1=0, size_t N2=0, size_t N3=0, size_t N4=0, size_t N5=0, size_t N6=0, size_t N7=0)
ViewDataType< non_const_scalar_type, scalar_dimension >::type non_const_scalar_array_type
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_0() const
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, bool >::type is_allocation_contiguous(const view_type &view)
array_analysis::non_const_value_type non_const_value_type
sacado_uq_pce_type::storage_type stokhos_storage_type
ViewMapping< SrcTraits, typename SrcTraits::specialize > SrcType
ViewCtorProp(const type &arg)
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1, const I2 &i2, const I3 &i3, const I4 &i4) const
KOKKOS_INLINE_FUNCTION constexpr bool span_is_contiguous() const
Is the mapped range span contiguous.
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_6() const
ViewOffset< typename Traits::dimension, typename Traits::array_layout, void > offset_type
KOKKOS_FORCEINLINE_FUNCTION void set_cijk(const cijk_type &cijk)
KOKKOS_INLINE_FUNCTION void stride(iType *const s) const
array_analysis::dimension dimension
ViewType::non_const_value_type::cijk_type type
array_analysis::dimension::template prepend< 0 >::type prepend_scalar_dimension
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_4() const
std::conditional< is_const, const ScalarType, ScalarType >::type scalar_type
array_analysis::dimension::template append< 0 >::type append_scalar_dimension
ViewMapping< SrcTraits, typename SrcTraits::specialize > SrcType
ViewDataType< const_scalar_type, scalar_dimension >::type const_scalar_array_type
offset_type m_impl_offset
sacado_uq_pce_type & reference_type
static KOKKOS_INLINE_FUNCTION void assign(DstType &dst, const SrcType &src, const TrackType &)
PCEFunctorType m_pce_functor
DeepCopyNonContiguous(const OutputView &arg_out, const InputView &arg_in)
Kokkos::Impl::ViewMapping< typename std::enable_if<(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutRight >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutStride >::value))>::type, Kokkos::ViewTraits< DataType, P...>, Arg0, Args... >::array_layout std::conditional< ((rank==0)||(rank<=2 &&R0 &&std::is_same< typename SrcTraits::array_layout, Kokkos::LayoutLeft >::value)||(rank<=2 &&R0_rev &&std::is_same< typename SrcTraits::array_layout, Kokkos::LayoutRight >::value)), typename SrcTraits::array_layout, Kokkos::LayoutStride >::type array_layout
KOKKOS_INLINE_FUNCTION constexpr size_t span() const
Span of the mapped range : [ data() .. data() + span() )
KOKKOS_INLINE_FUNCTION constexpr size_t stride_2() const
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_5() const
static KOKKOS_INLINE_FUNCTION void assign(DstType &dst, const SrcType &src, const TrackType &)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_1() const
Kokkos::Impl::ViewMapping< typename std::enable_if<(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutRight >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutStride >::value))>::type, Kokkos::ViewTraits< DataType, P...>, Arg0, Args... >::assign static KOKKOS_INLINE_FUNCTION void assign(ViewMapping< DstTraits, typename DstTraits::specialize > &dst, ViewMapping< SrcTraits, typename SrcTraits::specialize > const &src, Arg0 arg0, Args...args)
Kokkos::Impl::ViewMapping< typename std::enable_if<(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutRight >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutStride >::value))>::type, Kokkos::ViewTraits< DataType, P...>, Arg0, Args... >::type Kokkos::View< data_type, array_layout, typename SrcTraits::device_type, typename SrcTraits::memory_traits > type
KOKKOS_INLINE_FUNCTION constexpr size_t stride_4() const
handle_type m_impl_handle
void destroy_shared_allocation()
Kokkos::Impl::ViewValueFunctor< ExecSpace, scalar_type > ScalarFunctorType
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, typename CijkType< view_type >::type >::type cijk(const view_type &view)
Kokkos::Impl::ViewMapping< typename std::enable_if<(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutRight >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutStride >::value))>::type, Kokkos::ViewTraits< DataType, P...>, Arg0, Args... >::data_type std::conditional< rank==0, sacado_uq_pce_type, typename std::conditional< rank==1, sacado_uq_pce_type *, typename std::conditional< rank==2, sacado_uq_pce_type **, typename std::conditional< rank==3, sacado_uq_pce_type ***, typename std::conditional< rank==4, sacado_uq_pce_type ****, typename std::conditional< rank==5, sacado_uq_pce_type *****, typename std::conditional< rank==6, sacado_uq_pce_type ******, sacado_uq_pce_type ******* >::type >::type >::type >::type >::type >::type >::type data_type
KOKKOS_FORCEINLINE_FUNCTION std::enable_if< std::is_integral< I0 >::value &&!std::is_same< typename Traits::array_layout, Kokkos::LayoutStride >::value, reference_type >::type reference(const I0 &i0) const
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1) const
KOKKOS_INLINE_FUNCTION constexpr size_t stride_7() const
Sacado::ValueType< value_type >::type scalar_type
view_type::traits::dimension dimension
KOKKOS_INLINE_FUNCTION void assign_data(pointer_type arg_ptr)
Assign data.
Kokkos::Impl::ViewDataType< flat_value_type, dimension >::type flat_data_type
KOKKOS_INLINE_FUNCTION bool is_allocation_contiguous() const
ScalarFunctorType m_scalar_functor
Kokkos::Experimental::Impl::ViewPCEContiguous specialize
ConstructDestructFunctor(const ExecSpace &space, const bool initialize, const size_t span, const unsigned pce_size, const cijk_type &cijk, scalar_type *scalar_ptr, value_type *value_ptr)
View< flat_data_type, P...> type
ViewDataType< value_type, dimension >::type type
KOKKOS_INLINE_FUNCTION constexpr size_t stride_1() const
KOKKOS_INLINE_FUNCTION constexpr Traits::array_layout layout() const
PCEConstruct(const ExecSpace &space, value_type *p, scalar_type *sp, const size_t span, const unsigned pce_size, const cijk_type &cijk)
std::false_type is_regular
ViewOffset< typename array_dimension::template prepend< 0 >::type, typename Traits::array_layout, void > prepend_offset_type
KOKKOS_INLINE_FUNCTION constexpr size_t extent(const iType &r) const
Kokkos::Impl::ViewMapping< typename std::enable_if<(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutRight >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutStride >::value))>::type, Kokkos::ViewTraits< DataType, P...>, Arg0, Args... >::traits_type Kokkos::ViewTraits< data_type, array_layout, typename SrcTraits::device_type, typename SrcTraits::memory_traits > traits_type
sacado_uq_pce_type * pointer_type
Pointer to underlying memory type.
sacado_uq_pce_type::cijk_type cijk_type
KOKKOS_INLINE_FUNCTION std::enable_if< !Impl::ctor_prop_has_cijk< AllocProp >::value, CijkType >::type extract_cijk(const AllocProp &prop)
ViewOffset< typename array_dimension::template append< 0 >::type, typename Traits::array_layout, void > append_offset_type
KOKKOS_INLINE_FUNCTION void set(value_type *ptr, const size_t span, const unsigned pce_size)
std::conditional< std::is_same< ArrayLayout, Kokkos::LayoutLeft >::value, prepend_scalar_dimension, append_scalar_dimension >::type scalar_dimension
Kokkos::Impl::ViewMapping< typename std::enable_if<(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&(std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutLeft >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutRight >::value||std::is_same< typename Kokkos::ViewTraits< DataType, P...>::array_layout, Kokkos::LayoutStride >::value))>::type, Kokkos::ViewTraits< DataType, P...>, Arg0, Args... >::SrcTraits Kokkos::ViewTraits< DataType, P...> SrcTraits
stokhos_storage_type::value_type intrinsic_scalar_type
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)
array_analysis::const_value_type const_value_type
KOKKOS_FORCEINLINE_FUNCTION cijk_type cijk() const
void construct_shared_allocation()
SharedAllocationRecord * allocate_shared(ViewCtorProp< P... > const &prop, typename Traits::array_layout const &layout)