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 );
484 execution_space::fence();
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 ( Impl::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_INLINE_FUNCTION ~ViewMapping() = default ;
1252 m_is_contiguous(
true)
1255 KOKKOS_INLINE_FUNCTION ViewMapping(
const ViewMapping & ) = default ;
1256 KOKKOS_INLINE_FUNCTION ViewMapping & operator = (
const ViewMapping & ) = default ;
1258 KOKKOS_INLINE_FUNCTION ViewMapping( ViewMapping && ) = default ;
1259 KOKKOS_INLINE_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();
1291 template<
class ... P >
1292 SharedAllocationRecord<> *
1294 ,
typename Traits::array_layout
const & layout )
1296 typedef ViewCtorProp< P... > ctor_prop ;
1299 typedef typename Traits::memory_space memory_space ;
1300 typedef typename handle_type::template ConstructDestructFunctor<execution_space> functor_type ;
1301 typedef SharedAllocationRecord< memory_space , functor_type > record_type ;
1304 typedef std::integral_constant< unsigned , 0 > padding ;
1308 m_cijk = extract_cijk<cijk_type>(prop);
1309 if (m_cijk.dimension() == 0)
1310 m_cijk = getGlobalCijkTensor<cijk_type>();
1313 if (m_sacado_size == 0 ||
1314 m_sacado_size ==
unsigned(KOKKOS_IMPL_CTOR_DEFAULT_ARG))
1315 m_sacado_size = m_cijk.dimension();
1316 m_is_contiguous =
true;
1318 const size_t alloc_size =
1319 handle_type::memory_span( m_impl_offset.span(), m_sacado_size );
1322 record_type *
const record =
1323 record_type::allocate( ( (ViewCtorProp<void,memory_space>
const &) prop ).value
1324 , ( (ViewCtorProp<void,std::string>
const &) prop ).value
1331 m_impl_handle.set( reinterpret_cast< pointer_type >( record->data() ),
1332 m_impl_offset.span(), m_sacado_size );
1336 record->m_destroy = m_impl_handle.create_functor(
1337 ( (ViewCtorProp<void,execution_space>
const &) prop).value
1338 , ctor_prop::initialize
1339 , m_impl_offset.span()
1344 record->m_destroy.construct_shared_allocation();
1364 template<
class DstTraits ,
class SrcTraits >
1365 class ViewMapping< DstTraits , SrcTraits ,
1366 typename std::enable_if<(
1367 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1368 , typename SrcTraits::memory_space >::assignable
1371 std::is_same< typename DstTraits::specialize
1372 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1375 std::is_same< typename SrcTraits::specialize
1376 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1378 , typename DstTraits::specialize
1383 enum { is_assignable =
true };
1386 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1387 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1389 KOKKOS_INLINE_FUNCTION
static
1396 std::is_same<
typename DstTraits::array_layout
1397 , Kokkos::LayoutLeft >::value ||
1398 std::is_same<
typename DstTraits::array_layout
1399 , Kokkos::LayoutRight >::value ||
1400 std::is_same<
typename DstTraits::array_layout
1401 , Kokkos::LayoutStride >::value
1405 std::is_same<
typename SrcTraits::array_layout
1406 , Kokkos::LayoutLeft >::value ||
1407 std::is_same<
typename SrcTraits::array_layout
1408 , Kokkos::LayoutRight >::value ||
1409 std::is_same<
typename SrcTraits::array_layout
1410 , Kokkos::LayoutStride >::value
1412 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1415 std::is_same<
typename DstTraits::array_layout
1416 ,
typename SrcTraits::array_layout >::value ||
1417 std::is_same<
typename DstTraits::array_layout
1418 , Kokkos::LayoutStride >::value ||
1419 (
unsigned(DstTraits::rank) == 1 &&
unsigned(SrcTraits::rank) == 1 ) ,
1420 "View assignment must have compatible layout" );
1426 ,
typename SrcTraits::const_value_type >::value ,
1427 "View assignment must have same value type or const = non-const" );
1430 ViewDimensionAssignable
1431 <
typename DstType::offset_type::dimension_type
1432 ,
typename SrcType::offset_type::dimension_type >::value ,
1433 "View assignment must have compatible dimensions" );
1435 dst.m_impl_handle = src.m_impl_handle ;
1436 dst.m_impl_offset = src.m_impl_offset ;
1437 dst.m_sacado_size = src.m_sacado_size ;
1438 dst.m_cijk = src.m_cijk ;
1439 dst.m_is_contiguous = src.m_is_contiguous ;
1448 template<
class DstTraits ,
class SrcTraits >
1449 class ViewMapping< DstTraits , SrcTraits ,
1450 typename std::enable_if<(
1451 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1452 , typename SrcTraits::memory_space >::assignable
1455 std::is_same< typename DstTraits::specialize , void >::value
1458 std::is_same< typename SrcTraits::specialize
1459 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1462 unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)+1
1464 , typename DstTraits::specialize
1469 enum { is_assignable =
true };
1472 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1473 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1475 KOKKOS_INLINE_FUNCTION
static
1482 std::is_same<
typename DstTraits::array_layout
1483 , Kokkos::LayoutLeft >::value ||
1484 std::is_same<
typename DstTraits::array_layout
1485 , Kokkos::LayoutRight >::value ||
1486 std::is_same<
typename DstTraits::array_layout
1487 , Kokkos::LayoutStride >::value
1491 std::is_same<
typename SrcTraits::array_layout
1492 , Kokkos::LayoutLeft >::value ||
1493 std::is_same<
typename SrcTraits::array_layout
1494 , Kokkos::LayoutRight >::value ||
1495 std::is_same<
typename SrcTraits::array_layout
1496 , Kokkos::LayoutStride >::value
1498 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1501 std::is_same<
typename DstTraits::array_layout
1502 ,
typename SrcTraits::array_layout >::value ||
1503 std::is_same<
typename DstTraits::array_layout
1504 , Kokkos::LayoutStride >::value ,
1505 "View assignment must have compatible layout" );
1508 std::is_same<
typename DstTraits::scalar_array_type
1509 ,
typename SrcTraits::scalar_array_type >::value ||
1510 std::is_same<
typename DstTraits::scalar_array_type
1511 ,
typename SrcTraits::const_scalar_array_type >::value ,
1512 "View assignment must have same value type or const = non-const" );
1515 ViewDimensionAssignable<
1516 typename DstType::offset_type::dimension_type,
1517 typename SrcType::array_offset_type::dimension_type >::value,
1518 "View assignment must have compatible dimensions" );
1520 if ( !src.m_is_contiguous )
1521 Kokkos::abort(
"\n\n ****** Kokkos::View< Sacado::UQ::PCE ... >: can't assign non-contiguous view ******\n\n");
1524 dims[0] = src.m_impl_offset.dimension_0();
1525 dims[1] = src.m_impl_offset.dimension_1();
1526 dims[2] = src.m_impl_offset.dimension_2();
1527 dims[3] = src.m_impl_offset.dimension_3();
1528 dims[4] = src.m_impl_offset.dimension_4();
1529 dims[5] = src.m_impl_offset.dimension_5();
1530 dims[6] = src.m_impl_offset.dimension_6();
1531 dims[7] = src.m_impl_offset.dimension_7();
1532 unsigned rank = SrcTraits::dimension::rank;
1533 unsigned sacado_size = src.m_sacado_size;
1534 if (std::is_same<typename SrcTraits::array_layout, LayoutLeft>::value) {
1536 for (
unsigned i=rank; i>0; --i)
1537 dims[i] = dims[i-1];
1538 dims[0] = sacado_size;
1541 dims[rank] = sacado_size;
1543 typedef typename DstType::offset_type dst_offset_type;
1544 dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1545 typename DstTraits::array_layout(
1546 dims[0] , dims[1] , dims[2] , dims[3] ,
1547 dims[4] , dims[5] , dims[6] , dims[7] ) );
1548 dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1558 template<
class DstTraits ,
class SrcTraits >
1559 class ViewMapping< DstTraits , SrcTraits ,
1560 typename std::enable_if<(
1561 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1562 , typename SrcTraits::memory_space >::assignable
1565 std::is_same< typename DstTraits::specialize , void >::value
1568 std::is_same< typename SrcTraits::specialize
1569 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1572 unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)
1574 , typename DstTraits::specialize
1579 enum { is_assignable =
true };
1582 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1583 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1585 KOKKOS_INLINE_FUNCTION
static
1592 std::is_same<
typename DstTraits::array_layout
1593 , Kokkos::LayoutLeft >::value ||
1594 std::is_same<
typename DstTraits::array_layout
1595 , Kokkos::LayoutRight >::value ||
1596 std::is_same<
typename DstTraits::array_layout
1597 , Kokkos::LayoutStride >::value
1601 std::is_same<
typename SrcTraits::array_layout
1602 , Kokkos::LayoutLeft >::value ||
1603 std::is_same<
typename SrcTraits::array_layout
1604 , Kokkos::LayoutRight >::value ||
1605 std::is_same<
typename SrcTraits::array_layout
1606 , Kokkos::LayoutStride >::value
1608 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1611 std::is_same<
typename DstTraits::array_layout
1612 ,
typename SrcTraits::array_layout >::value ||
1613 std::is_same<
typename DstTraits::array_layout
1614 , Kokkos::LayoutStride >::value ,
1615 "View assignment must have compatible layout" );
1622 "View assignment must have same value type or const = non-const" );
1625 ViewDimensionAssignable<
1626 typename DstType::offset_type::dimension_type,
1627 typename SrcType::offset_type::dimension_type >::value,
1628 "View assignment must have compatible dimensions" );
1630 if ( !src.m_is_contiguous )
1631 Kokkos::abort(
"\n\n ****** Kokkos::View< Sacado::UQ::PCE ... >: can't assign non-contiguous view ******\n\n");
1634 dims[0] = src.m_impl_offset.dimension_0();
1635 dims[1] = src.m_impl_offset.dimension_1();
1636 dims[2] = src.m_impl_offset.dimension_2();
1637 dims[3] = src.m_impl_offset.dimension_3();
1638 dims[4] = src.m_impl_offset.dimension_4();
1639 dims[5] = src.m_impl_offset.dimension_5();
1640 dims[6] = src.m_impl_offset.dimension_6();
1641 dims[7] = src.m_impl_offset.dimension_7();
1642 unsigned rank = SrcTraits::dimension::rank;
1643 unsigned sacado_size = src.m_sacado_size;
1644 if (std::is_same<typename DstTraits::array_layout, LayoutLeft>::value) {
1645 dims[0] = dims[0]*sacado_size;
1649 dims[rank-1] = dims[rank-1]*sacado_size;
1652 typedef typename DstType::offset_type dst_offset_type;
1653 dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1654 typename DstTraits::array_layout(
1655 dims[0] , dims[1] , dims[2] , dims[3] ,
1656 dims[4] , dims[5] , dims[6] , dims[7] ) );
1657 dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1671 template<
class DataType,
class ... P ,
class Arg0,
class ... Args >
1673 < typename std::enable_if<(
1675 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::specialize
1676 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1679 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1680 , Kokkos::LayoutLeft >::value ||
1681 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1682 , Kokkos::LayoutRight >::value ||
1683 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1684 , Kokkos::LayoutStride >::value
1687 , Kokkos::ViewTraits<DataType,P...>
1698 , R0 = bool(is_integral_extent<0,Arg0,Args...>::value)
1699 , R1 = bool(is_integral_extent<1,Arg0,Args...>::value)
1700 , R2 = bool(is_integral_extent<2,Arg0,Args...>::value)
1701 , R3 = bool(is_integral_extent<3,Arg0,Args...>::value)
1702 , R4 = bool(is_integral_extent<4,Arg0,Args...>::value)
1703 , R5 = bool(is_integral_extent<5,Arg0,Args...>::value)
1704 , R6 = bool(is_integral_extent<6,Arg0,Args...>::value)
1708 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
1709 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
1712 enum { R0_rev = ( 0 == SrcTraits::rank ? RZ : (
1713 1 == SrcTraits::rank ? R0 : (
1714 2 == SrcTraits::rank ? R1 : (
1715 3 == SrcTraits::rank ? R2 : (
1716 4 == SrcTraits::rank ? R3 : (
1717 5 == SrcTraits::rank ? R4 : (
1718 6 == SrcTraits::rank ? R5 : R6 ))))))) };
1721 typedef typename std::conditional<
1727 ( rank <= 2 && R0 && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutLeft >::value )
1731 ( rank <= 2 && R0_rev && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutRight >::value )
1732 ),
typename SrcTraits::array_layout , Kokkos::LayoutStride
1737 typedef typename std::conditional< rank == 0 , sacado_uq_pce_type ,
1738 typename std::conditional< rank == 1 , sacado_uq_pce_type * ,
1739 typename std::conditional< rank == 2 , sacado_uq_pce_type ** ,
1740 typename std::conditional< rank == 3 , sacado_uq_pce_type *** ,
1741 typename std::conditional< rank == 4 , sacado_uq_pce_type **** ,
1742 typename std::conditional< rank == 5 , sacado_uq_pce_type ***** ,
1743 typename std::conditional< rank == 6 , sacado_uq_pce_type ****** ,
1744 sacado_uq_pce_type *******
1750 typedef Kokkos::ViewTraits
1753 ,
typename SrcTraits::device_type
1756 typedef Kokkos::View
1759 ,
typename SrcTraits::device_type
1760 ,
typename SrcTraits::memory_traits >
type ;
1765 template<
class DstTraits >
1766 KOKKOS_INLINE_FUNCTION
1767 static void assign( ViewMapping< DstTraits , typename DstTraits::specialize > & dst
1768 , ViewMapping< SrcTraits , typename SrcTraits::specialize >
const & src
1769 , Arg0 arg0, Args ... args )
1772 ViewMapping< DstTraits , traits_type , typename DstTraits::specialize >::is_assignable ,
1773 "Subview destination type must be compatible with subview derived type" );
1775 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1776 typedef typename DstType::offset_type dst_offset_type ;
1778 const SubviewExtents< SrcTraits::rank , rank >
1779 extents( src.m_impl_offset.m_dim , arg0 , args... );
1781 const size_t offset = src.m_impl_offset( extents.domain_offset(0)
1782 , extents.domain_offset(1)
1783 , extents.domain_offset(2)
1784 , extents.domain_offset(3)
1785 , extents.domain_offset(4)
1786 , extents.domain_offset(5)
1787 , extents.domain_offset(6)
1788 , extents.domain_offset(7) );
1790 dst.m_impl_offset = dst_offset_type( src.m_impl_offset , extents );
1791 dst.m_impl_handle.value_ptr = src.m_impl_handle.value_ptr + offset;
1792 dst.m_impl_handle.scalar_ptr =
1793 src.m_impl_handle.scalar_ptr + offset * src.m_sacado_size;
1794 dst.m_sacado_size = src.m_sacado_size;
1795 dst.m_cijk = src.m_cijk;
1796 dst.m_is_contiguous = src.m_is_contiguous;
1812 #if defined( KOKKOS_ENABLE_CUDA )
1813 template<
class OutputView >
1814 struct StokhosViewFill< OutputView ,
1815 typename std::enable_if< std::is_same< typename OutputView::specialize,
1816 Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&
1817 std::is_same< typename OutputView::execution_space,
1818 Cuda >::value >::type >
1820 typedef typename OutputView::const_value_type const_value_type ;
1821 typedef typename Sacado::ScalarType<const_value_type>::type
scalar_type ;
1823 typedef typename OutputView::size_type size_type ;
1825 template <
unsigned VectorLength>
1828 const OutputView output;
1829 const_value_type input;
1831 PCEKernel(
const OutputView & arg_out , const_value_type & arg_in ) :
1832 output(arg_out), input(arg_in) {}
1834 typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1836 KOKKOS_INLINE_FUNCTION
1837 void operator()(
const team_member & dev )
const
1839 const size_type tidx = dev.team_rank() % VectorLength;
1840 const size_type tidy = dev.team_rank() / VectorLength;
1841 const size_type nrow = dev.team_size() / VectorLength;
1844 const size_type i0 = dev.league_rank() * nrow + tidy;
1845 if ( i0 >= output.extent(0) )
return;
1847 for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1848 for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1849 for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1850 for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1851 for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1852 for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1853 for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1854 for ( size_type is = tidx ; is < nvec ; is+=VectorLength ) {
1855 output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1856 input.fastAccessCoeff(is) ;
1861 template <
unsigned VectorLength>
1862 struct ScalarKernel {
1864 const OutputView output;
1867 ScalarKernel(
const OutputView & arg_out ,
const scalar_type & arg_in ) :
1868 output(arg_out), input(arg_in) {}
1870 typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1871 KOKKOS_INLINE_FUNCTION
1872 void operator()(
const team_member & dev )
const
1874 const size_type tidx = dev.team_rank() % VectorLength;
1875 const size_type tidy = dev.team_rank() / VectorLength;
1876 const size_type nrow = dev.team_size() / VectorLength;
1879 const size_type i0 = dev.league_rank() * nrow + tidy;
1880 if ( i0 >= output.extent(0) )
return;
1882 for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1883 for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1884 for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1885 for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1886 for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1887 for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1888 for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1889 for ( size_type is = tidx ; is < npce ; is+=VectorLength ) {
1890 output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1896 StokhosViewFill(
const OutputView & output , const_value_type & input )
1900 const unsigned vector_length =
1904 const size_type block_size = 256;
1906 const size_type rows_per_block = block_size / vector_length;
1907 const size_type
n = output.extent(0);
1908 const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
1909 const size_type team_size = rows_per_block * vector_length;
1910 Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
1914 Kokkos::abort(
"StokhosViewFill: Invalid input value size");
1916 if (input.size() == 1)
1918 config, ScalarKernel<vector_length>(output, input.fastAccessCoeff(0)) );
1920 parallel_for( config, PCEKernel<vector_length>(output, input) );
1921 execution_space::fence();
1924 StokhosViewFill(
const OutputView & output ,
const scalar_type & input )
1928 const unsigned vector_length =
1932 const size_type block_size = 256;
1934 const size_type rows_per_block = block_size / vector_length;
1935 const size_type n = output.extent(0);
1936 const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
1937 const size_type team_size = rows_per_block * vector_length;
1938 Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
1940 parallel_for( config, ScalarKernel<vector_length>(output, input) );
1941 execution_space::fence();
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::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)