10 #ifndef KOKKOS_EXPERIMENTAL_VIEW_UQ_PCE_CONTIGUOUS_HPP
11 #define KOKKOS_EXPERIMENTAL_VIEW_UQ_PCE_CONTIGUOUS_HPP
19 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
20 #define KOKKOS_IMPL_PUBLIC_INCLUDE
21 #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
23 #include "Kokkos_Layout.hpp"
24 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
25 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
26 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
37 namespace Experimental {
42 template<
class ... Args >
45 template<
class D ,
class ... P ,
class ... Args >
48 std::is_same<
typename Kokkos::ViewTraits<
D,P...>::specialize
51 ( (
sizeof...(Args) == 0 ) ||
61 template <
typename T,
typename ... P>
64 static const bool value =
65 std::is_same<
typename view_type::specialize,
69 template <
typename ViewType>
71 typename std::enable_if< is_view_uq_pce< ViewType >::value >
::type > {
72 typedef typename ViewType::non_const_value_type::cijk_type
type;
75 template <
typename T,
typename ... P>
76 KOKKOS_INLINE_FUNCTION
80 return view.impl_map().dimension_scalar();
83 template <
typename view_type>
84 KOKKOS_INLINE_FUNCTION
86 std::enable_if< is_view_uq_pce<view_type>::value,
87 typename CijkType<view_type>::type >::type
88 cijk(
const view_type& view) {
89 return view.impl_map().cijk();
92 template <
typename view_type>
93 KOKKOS_INLINE_FUNCTION
95 std::enable_if< is_view_uq_pce<view_type>::value,
bool >::type
97 return view.impl_map().is_allocation_contiguous();
100 template <
typename ViewType>
104 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
105 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
107 return ViewType(view_alloc(label,cijk),
108 N0, N1, N2, N3, N4, N5, N6, N7);
111 template <
typename ViewType>
114 const Impl::WithoutInitializing_t& init,
116 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
117 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
119 return ViewType(view_alloc(label,init,cijk),
120 N0, N1, N2, N3, N4, N5, N6, N7);
123 template <
typename ViewType>
127 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
128 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
130 return ViewType(view_alloc(((Kokkos::Impl::ViewCtorProp<void, std::string>)init).value,
133 N0, N1, N2, N3, N4, N5, N6, N7);
136 template <
typename ViewType>
137 typename std::enable_if< is_view_uq_pce<ViewType>::value, ViewType>::type
140 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
141 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
143 size_t N[8] = { N0, N1, N2, N3, N4, N5, N6, N7 };
144 N[ViewType::rank] = cijk.dimension();
145 ViewType v(view_wrap(ptr, cijk),
146 N[0], N[1], N[2], N[3], N[4], N[5], N[6], N[7]);
152 #include "Sacado_Traits.hpp"
155 #include "Kokkos_Core.hpp"
159 template <
typename D,
typename ... P>
161 typename std::enable_if< is_view_uq_pce< View<D,P...> >::value >
::type > {
163 typedef typename view_type::traits::dimension
dimension;
165 typedef typename Kokkos::Impl::ViewDataType< flat_value_type , dimension >::type
flat_data_type;
169 template<
class T ,
class ... P >
171 typename std::enable_if<
172 std::is_same<
typename ViewTraits<T,P...>::specialize ,
174 !std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
175 Kokkos::LayoutStride >::value,
176 typename Kokkos::View<T,P...>::HostMirror>::type
179 typedef View<T,P...> src_type ;
180 typedef typename src_type::HostMirror dst_type ;
182 typename src_type::array_layout layout = src.layout();
185 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"),
186 src.impl_map().cijk()), layout);
189 template<
class T ,
class ... P >
191 typename std::enable_if<
192 std::is_same<
typename ViewTraits<T,P...>::specialize ,
194 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
195 Kokkos::LayoutStride >::value,
196 typename Kokkos::View<T,P...>::HostMirror>::type
199 typedef View<T,P...> src_type ;
200 typedef typename src_type::HostMirror dst_type ;
202 Kokkos::LayoutStride layout ;
204 layout.dimension[0] = src.extent(0);
205 layout.dimension[1] = src.extent(1);
206 layout.dimension[2] = src.extent(2);
207 layout.dimension[3] = src.extent(3);
208 layout.dimension[4] = src.extent(4);
209 layout.dimension[5] = src.extent(5);
210 layout.dimension[6] = src.extent(6);
211 layout.dimension[7] = src.extent(7);
213 layout.stride[0] = src.stride_0();
214 layout.stride[1] = src.stride_1();
215 layout.stride[2] = src.stride_2();
216 layout.stride[3] = src.stride_3();
217 layout.stride[4] = src.stride_4();
218 layout.stride[5] = src.stride_5();
219 layout.stride[6] = src.stride_6();
220 layout.stride[7] = src.stride_7();
224 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"),
225 src.impl_map().cijk()), layout);
228 template<
class Space,
class T,
class ... P,
typename Enabled>
229 typename std::enable_if<
230 std::is_same<
typename ViewTraits<T,P...>::specialize ,
232 typename Impl::MirrorViewType<Space,T,P ...>::dest_view_type>::type
235 typedef View<T,P...> src_type ;
236 typename src_type::array_layout layout = src.layout();
239 view_alloc(src.label(), src.impl_map().cijk()),layout);
242 template<
class T ,
class ... P >
244 typename std::enable_if<
245 std::is_same<
typename ViewTraits<T,P...>::specialize ,
247 !std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
248 Kokkos::LayoutStride >::value,
249 typename Kokkos::View<T,P...>::HostMirror>::type
251 const Kokkos::View<T,P...> & src)
253 typedef View<T,P...> src_type ;
254 typedef typename src_type::HostMirror dst_type ;
256 typename src_type::array_layout layout = src.layout();
259 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"), wi,
260 src.impl_map().cijk()), layout);
263 template<
class T ,
class ... P >
265 typename std::enable_if<
266 std::is_same<
typename ViewTraits<T,P...>::specialize ,
268 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
269 Kokkos::LayoutStride >::value,
270 typename Kokkos::View<T,P...>::HostMirror>::type
272 const Kokkos::View<T,P...> & src)
274 typedef View<T,P...> src_type ;
275 typedef typename src_type::HostMirror dst_type ;
277 Kokkos::LayoutStride layout ;
279 layout.dimension[0] = src.extent(0);
280 layout.dimension[1] = src.extent(1);
281 layout.dimension[2] = src.extent(2);
282 layout.dimension[3] = src.extent(3);
283 layout.dimension[4] = src.extent(4);
284 layout.dimension[5] = src.extent(5);
285 layout.dimension[6] = src.extent(6);
286 layout.dimension[7] = src.extent(7);
288 layout.stride[0] = src.stride_0();
289 layout.stride[1] = src.stride_1();
290 layout.stride[2] = src.stride_2();
291 layout.stride[3] = src.stride_3();
292 layout.stride[4] = src.stride_4();
293 layout.stride[5] = src.stride_5();
294 layout.stride[6] = src.stride_6();
295 layout.stride[7] = src.stride_7();
299 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"), wi,
300 src.impl_map().cijk()), layout);
303 template<
class Space,
class T,
class ... P,
typename Enable>
304 typename std::enable_if<
305 std::is_same<
typename ViewTraits<T,P...>::specialize ,
307 typename Impl::MirrorViewType<Space,T,P ...>::dest_view_type>::type
309 const Space& ,
const Kokkos::View<T,P...> & src)
311 typedef View<T,P...> src_type ;
312 typename src_type::array_layout layout = src.layout();
315 view_alloc(src.label(), wi, src.impl_map().cijk()), layout);
318 template <
class Space,
class T,
class... P>
319 typename Impl::MirrorViewType<Space, T, P...>::view_type
321 const Space&,
const Kokkos::View<T, P...>& src,
322 std::string
const& name,
323 typename std::enable_if<
324 std::is_same<
typename ViewTraits<T, P...>::specialize,
330 "Kokkos::create_mirror_view_and_copy: fence before returning src view");
334 template <
class Space,
class T,
class... P>
335 typename Impl::MirrorViewType<Space, T, P...>::view_type
337 const Space&,
const Kokkos::View<T, P...>& src,
338 std::string
const& name,
339 typename std::enable_if<
340 std::is_same<
typename ViewTraits<T, P...>::specialize,
344 using src_type =
View<T,P...>;
346 std::string label = name.empty() ? src.label() : name;
347 typename src_type::array_layout layout = src.layout();
349 auto mirror =
typename Mirror::non_const_type{
350 view_alloc(WithoutInitializing, label, src.impl_map().cijk()), layout};
356 template<
class DT,
class ... DP >
358 const View<DT,DP...> & view ,
360 ,
typename std::enable_if<(
361 std::is_same<
typename ViewTraits<DT,DP...>::specialize
367 typename ViewTraits<DT,DP...>::non_const_value_type >::value
368 ,
"Can only deep copy into non-const type" );
370 typedef View<DT,DP...> view_type;
380 template<
class DT,
class ... DP >
382 const View<DT,DP...> & view ,
384 ,
typename std::enable_if<(
385 std::is_same<
typename ViewTraits<DT,DP...>::specialize
391 typename ViewTraits<DT,DP...>::non_const_value_type >::value
392 ,
"Can only deep copy into non-const type" );
398 template<
class ExecSpace ,
class DT,
class ... DP >
401 const View<DT,DP...> & view ,
403 ,
typename std::enable_if<(
404 Kokkos::is_execution_space< ExecSpace >::value &&
405 std::is_same<
typename ViewTraits<DT,DP...>::specialize
411 typename ViewTraits<DT,DP...>::non_const_value_type >::value
412 ,
"Can only deep copy into non-const type" );
414 typedef View<DT,DP...> view_type;
424 template<
class ExecSpace ,
class DT,
class ... DP >
427 const View<DT,DP...> & view ,
429 ,
typename std::enable_if<(
430 Kokkos::is_execution_space< ExecSpace >::value &&
431 std::is_same<
typename ViewTraits<DT,DP...>::specialize
437 typename ViewTraits<DT,DP...>::non_const_value_type >::value
438 ,
"Can only deep copy into non-const type" );
443 namespace Experimental {
448 template<
class OutputView ,
class InputView >
458 const InputView & arg_in ) :
459 output( arg_out ), input( arg_in )
461 parallel_for( output.extent(0) , *this );
465 KOKKOS_INLINE_FUNCTION
468 for (
size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
469 for (
size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
470 for (
size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
471 for (
size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
472 for (
size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
473 for (
size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
474 for (
size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
475 output.access(i0,i1,i2,i3,i4,i5,i6,i7) = input.access(i0,i1,i2,i3,i4,i5,i6,i7) ;
484 template<
class ExecSpace,
class DT ,
class ... DP ,
class ST ,
class ... SP >
487 const View<DT,DP...> & dst ,
488 const View<ST,SP...> & src
489 ,
typename std::enable_if<(
490 std::is_same<
typename ViewTraits<DT,DP...>::specialize
493 std::is_same<
typename ViewTraits<ST,SP...>::specialize
499 typename ViewTraits<DT,DP...>::non_const_value_type >::value
500 ,
"Deep copy destination must be non-const" );
503 (
unsigned(ViewTraits<DT,DP...>::rank) ==
504 unsigned(ViewTraits<ST,SP...>::rank) )
505 ,
"Deep copy destination and source must have same rank" );
507 typedef View<DT,DP...> dst_type ;
508 typedef View<ST,SP...> src_type ;
509 typedef typename dst_type::array_type dst_array_type ;
510 typedef typename src_type::array_type src_array_type ;
513 dst_array_type dst_array = dst ;
514 src_array_type src_array = src ;
515 deep_copy( ExecSpace(), dst_array , src_array );
522 if ( std::is_same<
typename dst_type::memory_space ,
523 typename src_type::memory_space >::value ) {
529 typedef View<
typename src_type::non_const_data_type ,
530 std::conditional_t<std::is_same<
typename src_type::array_layout,
531 Kokkos::LayoutStride>::value,
533 typename src_type::array_layout>,
535 typedef typename tmp_src_type::array_type tmp_src_array_type;
536 typedef View<
typename dst_type::non_const_data_type ,
537 std::conditional_t<std::is_same<
typename dst_type::array_layout,
538 Kokkos::LayoutStride>::value,
540 typename dst_type::array_layout>,
542 typedef typename tmp_dst_type::array_type tmp_dst_array_type;
550 src_dims[0] = src.extent(0);
551 src_dims[1] = src.extent(1);
552 src_dims[2] = src.extent(2);
553 src_dims[3] = src.extent(3);
554 src_dims[4] = src.extent(4);
555 src_dims[5] = src.extent(5);
556 src_dims[6] = src.extent(6);
557 src_dims[7] = src.extent(7);
559 tmp_src_type src_tmp(
560 view_alloc(
"src_tmp" , WithoutInitializing,
cijk(src) ) ,
561 src_dims[0], src_dims[1], src_dims[2], src_dims[3],
562 src_dims[4], src_dims[5], src_dims[6], src_dims[7] );
564 dst_array_type dst_array = dst ;
565 tmp_src_array_type src_array = src_tmp ;
566 deep_copy( ExecSpace(), dst_array , src_array );
575 dst_dims[0] = dst.extent(0);
576 dst_dims[1] = dst.extent(1);
577 dst_dims[2] = dst.extent(2);
578 dst_dims[3] = dst.extent(3);
579 dst_dims[4] = dst.extent(4);
580 dst_dims[5] = dst.extent(5);
581 dst_dims[6] = dst.extent(6);
582 dst_dims[7] = dst.extent(7);
584 tmp_dst_type dst_tmp(
585 view_alloc(
"dst_tmp" , WithoutInitializing,
cijk(dst) ) ,
586 dst_dims[0], dst_dims[1], dst_dims[2], dst_dims[3],
587 dst_dims[4], dst_dims[5], dst_dims[6], dst_dims[7] );
588 tmp_dst_array_type dst_array = dst_tmp ;
589 src_array_type src_array = src ;
590 deep_copy( ExecSpace(), dst_array , src_array );
599 src_dims[0] = src.extent(0);
600 src_dims[1] = src.extent(1);
601 src_dims[2] = src.extent(2);
602 src_dims[3] = src.extent(3);
603 src_dims[4] = src.extent(4);
604 src_dims[5] = src.extent(5);
605 src_dims[6] = src.extent(6);
606 src_dims[7] = src.extent(7);
608 tmp_src_type src_tmp(
609 view_alloc(
"src_tmp" , WithoutInitializing,
cijk(src) ) ,
610 src_dims[0], src_dims[1], src_dims[2], src_dims[3],
611 src_dims[4], src_dims[5], src_dims[6], src_dims[7] );
615 dst_dims[0] = dst.extent(0);
616 dst_dims[1] = dst.extent(1);
617 dst_dims[2] = dst.extent(2);
618 dst_dims[3] = dst.extent(3);
619 dst_dims[4] = dst.extent(4);
620 dst_dims[5] = dst.extent(5);
621 dst_dims[6] = dst.extent(6);
622 dst_dims[7] = dst.extent(7);
624 tmp_dst_type dst_tmp(
625 view_alloc(
"dst_tmp" , WithoutInitializing,
cijk(dst) ) ,
626 dst_dims[0], dst_dims[1], dst_dims[2], dst_dims[3],
627 dst_dims[4], dst_dims[5], dst_dims[6], dst_dims[7] );
628 tmp_dst_array_type dst_array = dst_tmp ;
629 tmp_src_array_type src_array = src_tmp ;
630 deep_copy( ExecSpace(), dst_array , src_array );
638 template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
641 const View<ST,SP...> & src
642 ,
typename std::enable_if<(
643 std::is_same<
typename ViewTraits<DT,DP...>::specialize
646 std::is_same<
typename ViewTraits<ST,SP...>::specialize
658 template <
unsigned N,
typename... Args>
659 KOKKOS_FUNCTION std::enable_if_t<
660 N ==
View<Args...>::rank &&
661 std::is_same<
typename ViewTraits<Args...>::specialize,
670 template <
unsigned N,
typename T,
typename... Args>
672 N !=
View<T, Args...>::rank &&
673 std::is_same<
typename ViewTraits<T, Args...>::specialize,
678 Kokkos::Impl::throw_runtime_exception(
679 "Trying to get at a View of the wrong rank");
696 template<
typename Value,
typename Execution,
typename Memory >
697 struct ViewCtorProp< void , Stokhos::CrsProductTensor<Value, Execution, Memory> >
699 ViewCtorProp() = default ;
700 ViewCtorProp(
const ViewCtorProp & ) = default ;
701 ViewCtorProp & operator = (
const ViewCtorProp & ) = default ;
711 template <
typename AllocProp>
714 static const bool value =
false;
717 template<
typename T >
720 static const bool value =
false;
723 template<
typename Value,
typename Execution,
typename Memory >
725 ViewCtorProp< Stokhos::CrsProductTensor<Value, Execution, Memory> >
728 static const bool value =
true;
731 template<
typename T,
typename ... P >
734 static const bool value =
742 template <
typename CijkType,
typename AllocProp>
743 KOKKOS_INLINE_FUNCTION
744 typename std::enable_if< !Impl::ctor_prop_has_cijk<AllocProp>::value,
751 template <
typename CijkType,
typename AllocProp>
752 KOKKOS_INLINE_FUNCTION
753 typename std::enable_if< Impl::ctor_prop_has_cijk<AllocProp>::value,
757 return ( (
const Impl::ViewCtorProp<void,CijkType>&) prop ).value;
769 template<
class DataType ,
class ArrayLayout ,
typename StorageType >
770 struct ViewDataAnalysis< DataType
772 , Sacado::UQ::PCE< StorageType > >
791 ViewDataType< value_type , dimension >::type
type ;
793 ViewDataType< const_value_type , dimension >::type
const_type ;
800 enum { is_const = std::is_same< value_type , const_value_type >::value };
804 std::conditional< is_const , const ScalarType , ScalarType >::type
811 typedef typename array_analysis::dimension::
812 template prepend<0>::type
814 typedef typename array_analysis::dimension::
815 template append<0>::type
817 typedef typename std::conditional<
818 std::is_same< ArrayLayout, Kokkos::LayoutLeft>::value,
829 ViewDataType< const_scalar_type , scalar_dimension >::type
833 ViewDataType< non_const_scalar_type , scalar_dimension >::type
843 namespace Experimental {
851 template <
class ValueType>
860 KOKKOS_INLINE_FUNCTION
861 static constexpr
size_t
866 KOKKOS_INLINE_FUNCTION
869 template <
typename T>
870 KOKKOS_INLINE_FUNCTION
880 KOKKOS_INLINE_FUNCTION
883 scalar_ptr =
reinterpret_cast<scalar_type*
>(ptr+span);
886 template <
class ExecSpace>
904 const unsigned pce_size,
906 m_space(space), m_p(p), m_sp(sp), m_span(span), m_pce_size(pce_size),
910 typedef Kokkos::RangePolicy< ExecSpace > PolicyType ;
911 const Kokkos::Impl::ParallelFor< PCEConstruct , PolicyType >
912 closure( *
this , PolicyType( 0 , m_span ) );
917 KOKKOS_INLINE_FUNCTION
918 void operator() (
const size_t i)
const {
919 new (m_p+i)
value_type(m_cijk, m_pce_size, m_sp+i*m_pce_size,
false);
923 template <
class ExecSpace>
936 const bool initialize,
938 const unsigned pce_size,
942 m_scalar_functor( space , scalar_ptr , span*pce_size ,
"Stokhos_UQ_PCE_Contig_ConstructDestructFunctor" ),
943 m_pce_functor( space , value_ptr , scalar_ptr , span , pce_size , cijk ),
944 m_initialize(initialize) {}
949 m_scalar_functor.construct_shared_allocation();
961 m_pce_functor.execute();
968 m_scalar_functor.destroy_shared_allocation();
973 template <
class ExecSpace>
974 inline ConstructDestructFunctor<ExecSpace>
976 const bool initialize,
978 const unsigned pce_size,
980 return ConstructDestructFunctor<ExecSpace>(space, initialize, span,
981 pce_size,
cijk, scalar_ptr,
987 template <
typename T>
989 value_ptr =
reinterpret_cast<value_type*
>(ptr);
991 scalar_ptr = value_ptr->coeff();
1002 template<
class Traits >
1003 class ViewMapping< Traits ,
1004 typename std::enable_if<
1005 ( std::is_same< typename Traits::specialize
1006 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1008 ( std::is_same< typename Traits::array_layout
1009 , Kokkos::LayoutLeft >::value
1011 std::is_same< typename Traits::array_layout
1012 , Kokkos::LayoutRight >::value
1014 std::is_same< typename Traits::array_layout
1015 , Kokkos::LayoutStride >::value
1018 , typename Traits::specialize
1023 template< class ,
class ... >
friend class ViewMapping ;
1024 template< class ,
class ... >
friend class Kokkos::View ;
1037 typedef ViewOffset<
typename Traits::dimension
1038 ,
typename Traits::array_layout
1045 typedef ViewOffset<
typename array_dimension::
1046 template append<0>::type,
1047 typename Traits::array_layout,
1050 typedef ViewOffset<
typename array_dimension::
1051 template prepend<0>::type,
1052 typename Traits::array_layout,
1055 typedef typename std::conditional<
1056 std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft>::value,
1069 KOKKOS_INLINE_FUNCTION
1071 const size_t sz = this->span();
1075 m_impl_handle.value_ptr[sz-1].coeff();
1077 m_impl_handle.scalar_ptr + (sz-1)*m_sacado_size;
1078 return last_coeff == last_coeff_expected;
1086 enum { Rank = Traits::dimension::rank };
1089 enum { Sacado_Rank = std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft >::value ? 0 : Rank+1 };
1092 template<
typename iType >
1093 KOKKOS_INLINE_FUNCTION constexpr
size_t extent(
const iType & r )
const
1094 {
return m_impl_offset.m_dim.extent(r); }
1096 KOKKOS_INLINE_FUNCTION constexpr
1098 {
return m_impl_offset.layout(); }
1101 {
return m_impl_offset.dimension_0(); }
1103 {
return m_impl_offset.dimension_1(); }
1105 {
return m_impl_offset.dimension_2(); }
1107 {
return m_impl_offset.dimension_3(); }
1109 {
return m_impl_offset.dimension_4(); }
1111 {
return m_impl_offset.dimension_5(); }
1113 {
return m_impl_offset.dimension_6(); }
1115 {
return m_impl_offset.dimension_7(); }
1122 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_0()
const
1123 {
return m_impl_offset.stride_0(); }
1124 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_1()
const
1125 {
return m_impl_offset.stride_1(); }
1126 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_2()
const
1127 {
return m_impl_offset.stride_2(); }
1128 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_3()
const
1129 {
return m_impl_offset.stride_3(); }
1130 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_4()
const
1131 {
return m_impl_offset.stride_4(); }
1132 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_5()
const
1133 {
return m_impl_offset.stride_5(); }
1134 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_6()
const
1135 {
return m_impl_offset.stride_6(); }
1136 KOKKOS_INLINE_FUNCTION constexpr
size_t stride_7()
const
1137 {
return m_impl_offset.stride_7(); }
1139 template<
typename iType >
1140 KOKKOS_INLINE_FUNCTION
void stride( iType *
const s )
const
1141 { m_impl_offset.stride(s); }
1145 {
return m_sacado_size; }
1148 KOKKOS_FORCEINLINE_FUNCTION
1153 KOKKOS_FORCEINLINE_FUNCTION
1158 KOKKOS_INLINE_FUNCTION
1160 {
return m_is_contiguous; }
1163 static const bool is_static = false ;
1166 static const bool is_contiguous =
true;
1178 KOKKOS_INLINE_FUNCTION constexpr
size_t span()
const
1179 {
return m_impl_offset.span(); }
1183 {
return m_impl_offset.span_is_contiguous() ; }
1187 {
return m_impl_handle.value_ptr ; }
1191 KOKKOS_FORCEINLINE_FUNCTION
1193 {
return *m_impl_handle.value_ptr; }
1196 template<
typename I0 >
1197 KOKKOS_FORCEINLINE_FUNCTION
1199 std::enable_if< std::is_integral<I0>::value &&
1200 ! std::is_same< typename Traits::array_layout , Kokkos::LayoutStride >::value
1201 , reference_type >::type
1203 {
return m_impl_handle.value_ptr[i0]; }
1206 template<
typename I0 >
1207 KOKKOS_FORCEINLINE_FUNCTION
1209 std::enable_if< std::is_integral<I0>::value &&
1210 std::is_same< typename Traits::array_layout , Kokkos::LayoutStride >::value
1211 , reference_type >::type
1213 {
return m_impl_handle.value_ptr[ m_impl_offset(i0) ]; }
1215 template<
typename I0 ,
typename I1 >
1216 KOKKOS_FORCEINLINE_FUNCTION
1218 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1) ]; }
1220 template<
typename I0 ,
typename I1 ,
typename I2 >
1221 KOKKOS_FORCEINLINE_FUNCTION
1223 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2) ]; }
1225 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3 >
1226 KOKKOS_FORCEINLINE_FUNCTION
1228 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3) ]; }
1230 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1232 KOKKOS_FORCEINLINE_FUNCTION
1234 ,
const I4 & i4 )
const
1235 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3,i4) ]; }
1237 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1238 ,
typename I4 ,
typename I5 >
1239 KOKKOS_FORCEINLINE_FUNCTION
1241 ,
const I4 & i4 ,
const I5 & i5 )
const
1242 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5) ]; }
1244 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1245 ,
typename I4 ,
typename I5 ,
typename I6 >
1246 KOKKOS_FORCEINLINE_FUNCTION
1248 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 )
const
1249 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5,i6) ]; }
1251 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1252 ,
typename I4 ,
typename I5 ,
typename I6 ,
typename I7 >
1253 KOKKOS_FORCEINLINE_FUNCTION
1255 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 ,
const I7 & i7 )
const
1256 {
return m_impl_handle.value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5,i6,i7) ]; }
1261 KOKKOS_INLINE_FUNCTION
1262 static size_t memory_span(
typename Traits::array_layout
const & layout )
1265 typedef std::integral_constant< unsigned , 0 > padding ;
1267 unsigned sacado_size =
1269 return handle_type::memory_span( offset.span(), sacado_size );
1274 KOKKOS_DEFAULTED_FUNCTION ~ViewMapping() = default ;
1280 m_is_contiguous(
true)
1283 KOKKOS_DEFAULTED_FUNCTION ViewMapping(
const ViewMapping & ) = default ;
1284 KOKKOS_DEFAULTED_FUNCTION ViewMapping & operator = (
const ViewMapping & ) = default ;
1286 KOKKOS_DEFAULTED_FUNCTION ViewMapping( ViewMapping && ) = default ;
1287 KOKKOS_DEFAULTED_FUNCTION ViewMapping & operator = ( ViewMapping && ) = default ;
1289 template<
class ... P >
1290 KOKKOS_INLINE_FUNCTION
1292 ( ViewCtorProp< P ... >
const & prop
1293 ,
typename Traits::array_layout
const & layout
1296 , m_impl_offset( std::integral_constant< unsigned , 0 >() , layout )
1299 m_impl_handle.set( ( (ViewCtorProp<void,pointer_type>
const &) prop ).value
1300 , m_impl_offset.span(), m_sacado_size );
1301 m_cijk = extract_cijk<cijk_type>(prop);
1302 #ifndef __CUDA_ARCH__
1303 if (m_cijk.dimension() == 0)
1304 m_cijk = getGlobalCijkTensor<cijk_type>();
1307 if (m_sacado_size == 0 ||
1308 m_sacado_size ==
unsigned(KOKKOS_IMPL_CTOR_DEFAULT_ARG))
1309 m_sacado_size = m_cijk.dimension();
1311 m_is_contiguous = this->is_data_contiguous();
1315 KOKKOS_INLINE_FUNCTION
1317 { m_impl_handle.set( arg_ptr, m_impl_offset.span(), m_sacado_size ); }
1324 template<
class ... P >
1325 SharedAllocationRecord<> *
1327 ,
typename Traits::array_layout
const & layout )
1329 typedef ViewCtorProp< P... > ctor_prop ;
1332 typedef typename Traits::memory_space memory_space ;
1333 typedef typename handle_type::template ConstructDestructFunctor<execution_space> functor_type ;
1334 typedef SharedAllocationRecord< memory_space , functor_type > record_type ;
1337 typedef std::integral_constant< unsigned , 0 > padding ;
1341 m_cijk = extract_cijk<cijk_type>(prop);
1342 if (m_cijk.dimension() == 0)
1343 m_cijk = getGlobalCijkTensor<cijk_type>();
1346 if (m_sacado_size == 0 ||
1347 m_sacado_size ==
unsigned(KOKKOS_IMPL_CTOR_DEFAULT_ARG))
1348 m_sacado_size = m_cijk.dimension();
1349 m_is_contiguous =
true;
1351 const size_t alloc_size =
1352 handle_type::memory_span( m_impl_offset.span(), m_sacado_size );
1355 record_type *
const record =
1356 record_type::allocate( ( (ViewCtorProp<void,memory_space>
const &) prop ).value
1357 , ( (ViewCtorProp<void,std::string>
const &) prop ).value
1363 auto space = ((ViewCtorProp<void,execution_space>
const &) prop).value;
1365 m_impl_handle.set( reinterpret_cast< pointer_type >( record->data() ),
1366 m_impl_offset.span(), m_sacado_size );
1370 record->m_destroy = m_impl_handle.create_functor(
1372 , ctor_prop::initialize
1373 , m_impl_offset.span()
1378 record->m_destroy.construct_shared_allocation();
1385 template<
class ... P >
1386 SharedAllocationRecord<> *
1388 ,
typename Traits::array_layout
const & layout
1391 return allocate_shared(prop, layout);
1408 template<
class DstTraits ,
class SrcTraits >
1409 class ViewMapping< DstTraits , SrcTraits ,
1410 typename std::enable_if<(
1411 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1412 , typename SrcTraits::memory_space >::assignable
1415 std::is_same< typename DstTraits::specialize
1416 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1419 std::is_same< typename SrcTraits::specialize
1420 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1422 , typename DstTraits::specialize
1427 enum { is_assignable =
true };
1428 enum { is_assignable_data_type =
true };
1431 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1432 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1434 KOKKOS_INLINE_FUNCTION
static
1441 std::is_same<
typename DstTraits::array_layout
1442 , Kokkos::LayoutLeft >::value ||
1443 std::is_same<
typename DstTraits::array_layout
1444 , Kokkos::LayoutRight >::value ||
1445 std::is_same<
typename DstTraits::array_layout
1446 , Kokkos::LayoutStride >::value
1450 std::is_same<
typename SrcTraits::array_layout
1451 , Kokkos::LayoutLeft >::value ||
1452 std::is_same<
typename SrcTraits::array_layout
1453 , Kokkos::LayoutRight >::value ||
1454 std::is_same<
typename SrcTraits::array_layout
1455 , Kokkos::LayoutStride >::value
1457 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1460 std::is_same<
typename DstTraits::array_layout
1461 ,
typename SrcTraits::array_layout >::value ||
1462 std::is_same<
typename DstTraits::array_layout
1463 , Kokkos::LayoutStride >::value ||
1464 (
unsigned(DstTraits::rank) == 1 &&
unsigned(SrcTraits::rank) == 1 ) ,
1465 "View assignment must have compatible layout" );
1471 ,
typename SrcTraits::const_value_type >::value ,
1472 "View assignment must have same value type or const = non-const" );
1475 ViewDimensionAssignable
1476 <
typename DstType::offset_type::dimension_type
1477 ,
typename SrcType::offset_type::dimension_type >::value ,
1478 "View assignment must have compatible dimensions" );
1480 dst.m_impl_handle = src.m_impl_handle ;
1481 dst.m_impl_offset = src.m_impl_offset ;
1482 dst.m_sacado_size = src.m_sacado_size ;
1483 dst.m_cijk = src.m_cijk ;
1484 dst.m_is_contiguous = src.m_is_contiguous ;
1493 template<
class DstTraits ,
class SrcTraits >
1494 class ViewMapping< DstTraits , SrcTraits ,
1495 typename std::enable_if<(
1496 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1497 , typename SrcTraits::memory_space >::assignable
1500 std::is_same< typename DstTraits::specialize , void >::value
1503 std::is_same< typename SrcTraits::specialize
1504 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1507 unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)+1
1509 , typename DstTraits::specialize
1514 enum { is_assignable =
true };
1515 enum { is_assignable_data_type =
true };
1518 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1519 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1521 KOKKOS_INLINE_FUNCTION
static
1528 std::is_same<
typename DstTraits::array_layout
1529 , Kokkos::LayoutLeft >::value ||
1530 std::is_same<
typename DstTraits::array_layout
1531 , Kokkos::LayoutRight >::value ||
1532 std::is_same<
typename DstTraits::array_layout
1533 , Kokkos::LayoutStride >::value
1537 std::is_same<
typename SrcTraits::array_layout
1538 , Kokkos::LayoutLeft >::value ||
1539 std::is_same<
typename SrcTraits::array_layout
1540 , Kokkos::LayoutRight >::value ||
1541 std::is_same<
typename SrcTraits::array_layout
1542 , Kokkos::LayoutStride >::value
1544 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1547 std::is_same<
typename DstTraits::array_layout
1548 ,
typename SrcTraits::array_layout >::value ||
1549 std::is_same<
typename DstTraits::array_layout
1550 , Kokkos::LayoutStride >::value ,
1551 "View assignment must have compatible layout" );
1554 std::is_same<
typename DstTraits::scalar_array_type
1555 ,
typename SrcTraits::scalar_array_type >::value ||
1556 std::is_same<
typename DstTraits::scalar_array_type
1557 ,
typename SrcTraits::const_scalar_array_type >::value ,
1558 "View assignment must have same value type or const = non-const" );
1561 ViewDimensionAssignable<
1562 typename DstType::offset_type::dimension_type,
1563 typename SrcType::array_offset_type::dimension_type >::value,
1564 "View assignment must have compatible dimensions" );
1566 if ( !src.m_is_contiguous )
1567 Kokkos::abort(
"\n\n ****** Kokkos::View< Sacado::UQ::PCE ... >: can't assign non-contiguous view ******\n\n");
1570 dims[0] = src.m_impl_offset.dimension_0();
1571 dims[1] = src.m_impl_offset.dimension_1();
1572 dims[2] = src.m_impl_offset.dimension_2();
1573 dims[3] = src.m_impl_offset.dimension_3();
1574 dims[4] = src.m_impl_offset.dimension_4();
1575 dims[5] = src.m_impl_offset.dimension_5();
1576 dims[6] = src.m_impl_offset.dimension_6();
1577 dims[7] = src.m_impl_offset.dimension_7();
1578 unsigned rank = SrcTraits::dimension::rank;
1579 unsigned sacado_size = src.m_sacado_size;
1580 if (std::is_same<typename SrcTraits::array_layout, LayoutLeft>::value) {
1582 for (
unsigned i=rank; i>0; --i)
1583 dims[i] = dims[i-1];
1584 dims[0] = sacado_size;
1587 dims[rank] = sacado_size;
1589 typedef typename DstType::offset_type dst_offset_type;
1590 dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1591 typename DstTraits::array_layout(
1592 dims[0] , dims[1] , dims[2] , dims[3] ,
1593 dims[4] , dims[5] , dims[6] , dims[7] ) );
1598 dst.m_impl_handle =
typename DstType::handle_type(src.m_impl_handle.scalar_ptr);
1608 template<
class DstTraits ,
class SrcTraits >
1609 class ViewMapping< DstTraits , SrcTraits ,
1610 typename std::enable_if<(
1611 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1612 , typename SrcTraits::memory_space >::assignable
1615 std::is_same< typename DstTraits::specialize , void >::value
1618 std::is_same< typename SrcTraits::specialize
1619 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1622 unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)
1624 , typename DstTraits::specialize
1629 enum { is_assignable =
true };
1630 enum { is_assignable_data_type =
true };
1633 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1634 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1636 KOKKOS_INLINE_FUNCTION
static
1643 std::is_same<
typename DstTraits::array_layout
1644 , Kokkos::LayoutLeft >::value ||
1645 std::is_same<
typename DstTraits::array_layout
1646 , Kokkos::LayoutRight >::value ||
1647 std::is_same<
typename DstTraits::array_layout
1648 , Kokkos::LayoutStride >::value
1652 std::is_same<
typename SrcTraits::array_layout
1653 , Kokkos::LayoutLeft >::value ||
1654 std::is_same<
typename SrcTraits::array_layout
1655 , Kokkos::LayoutRight >::value ||
1656 std::is_same<
typename SrcTraits::array_layout
1657 , Kokkos::LayoutStride >::value
1659 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1662 std::is_same<
typename DstTraits::array_layout
1663 ,
typename SrcTraits::array_layout >::value ||
1664 std::is_same<
typename DstTraits::array_layout
1665 , Kokkos::LayoutStride >::value ,
1666 "View assignment must have compatible layout" );
1673 "View assignment must have same value type or const = non-const" );
1676 ViewDimensionAssignable<
1677 typename DstType::offset_type::dimension_type,
1678 typename SrcType::offset_type::dimension_type >::value,
1679 "View assignment must have compatible dimensions" );
1681 if ( !src.m_is_contiguous )
1682 Kokkos::abort(
"\n\n ****** Kokkos::View< Sacado::UQ::PCE ... >: can't assign non-contiguous view ******\n\n");
1685 dims[0] = src.m_impl_offset.dimension_0();
1686 dims[1] = src.m_impl_offset.dimension_1();
1687 dims[2] = src.m_impl_offset.dimension_2();
1688 dims[3] = src.m_impl_offset.dimension_3();
1689 dims[4] = src.m_impl_offset.dimension_4();
1690 dims[5] = src.m_impl_offset.dimension_5();
1691 dims[6] = src.m_impl_offset.dimension_6();
1692 dims[7] = src.m_impl_offset.dimension_7();
1693 unsigned rank = SrcTraits::dimension::rank;
1694 unsigned sacado_size = src.m_sacado_size;
1695 if (std::is_same<typename DstTraits::array_layout, LayoutLeft>::value) {
1696 dims[0] = dims[0]*sacado_size;
1700 dims[rank-1] = dims[rank-1]*sacado_size;
1703 typedef typename DstType::offset_type dst_offset_type;
1704 dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1705 typename DstTraits::array_layout(
1706 dims[0] , dims[1] , dims[2] , dims[3] ,
1707 dims[4] , dims[5] , dims[6] , dims[7] ) );
1708 dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1722 template<
class DataType,
class ... P ,
class Arg0,
class ... Args >
1724 < typename std::enable_if<(
1726 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::specialize
1727 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1730 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1731 , Kokkos::LayoutLeft >::value ||
1732 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1733 , Kokkos::LayoutRight >::value ||
1734 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1735 , Kokkos::LayoutStride >::value
1738 , Kokkos::ViewTraits<DataType,P...>
1749 , R0 = bool(is_integral_extent<0,Arg0,Args...>::value)
1750 , R1 = bool(is_integral_extent<1,Arg0,Args...>::value)
1751 , R2 = bool(is_integral_extent<2,Arg0,Args...>::value)
1752 , R3 = bool(is_integral_extent<3,Arg0,Args...>::value)
1753 , R4 = bool(is_integral_extent<4,Arg0,Args...>::value)
1754 , R5 = bool(is_integral_extent<5,Arg0,Args...>::value)
1755 , R6 = bool(is_integral_extent<6,Arg0,Args...>::value)
1759 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
1760 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
1763 enum { R0_rev = ( 0 == SrcTraits::rank ? RZ : (
1764 1 == SrcTraits::rank ? R0 : (
1765 2 == SrcTraits::rank ? R1 : (
1766 3 == SrcTraits::rank ? R2 : (
1767 4 == SrcTraits::rank ? R3 : (
1768 5 == SrcTraits::rank ? R4 : (
1769 6 == SrcTraits::rank ? R5 : R6 ))))))) };
1772 typedef typename std::conditional<
1778 ( rank <= 2 && R0 && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutLeft >::value )
1782 ( rank <= 2 && R0_rev && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutRight >::value )
1783 ),
typename SrcTraits::array_layout , Kokkos::LayoutStride
1788 typedef typename std::conditional< rank == 0 , sacado_uq_pce_type ,
1789 typename std::conditional< rank == 1 , sacado_uq_pce_type * ,
1790 typename std::conditional< rank == 2 , sacado_uq_pce_type ** ,
1791 typename std::conditional< rank == 3 , sacado_uq_pce_type *** ,
1792 typename std::conditional< rank == 4 , sacado_uq_pce_type **** ,
1793 typename std::conditional< rank == 5 , sacado_uq_pce_type ***** ,
1794 typename std::conditional< rank == 6 , sacado_uq_pce_type ****** ,
1795 sacado_uq_pce_type *******
1801 typedef Kokkos::ViewTraits
1804 ,
typename SrcTraits::device_type
1807 typedef Kokkos::View
1810 ,
typename SrcTraits::device_type
1811 ,
typename SrcTraits::memory_traits >
type ;
1816 template<
class DstTraits >
1817 KOKKOS_INLINE_FUNCTION
1818 static void assign( ViewMapping< DstTraits , typename DstTraits::specialize > & dst
1819 , ViewMapping< SrcTraits , typename SrcTraits::specialize >
const & src
1820 , Arg0 arg0, Args ... args )
1823 ViewMapping< DstTraits , traits_type , typename DstTraits::specialize >::is_assignable ,
1824 "Subview destination type must be compatible with subview derived type" );
1826 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1827 typedef typename DstType::offset_type dst_offset_type ;
1829 const SubviewExtents< SrcTraits::rank , rank >
1830 extents( src.m_impl_offset.m_dim , arg0 , args... );
1832 const size_t offset = src.m_impl_offset( extents.domain_offset(0)
1833 , extents.domain_offset(1)
1834 , extents.domain_offset(2)
1835 , extents.domain_offset(3)
1836 , extents.domain_offset(4)
1837 , extents.domain_offset(5)
1838 , extents.domain_offset(6)
1839 , extents.domain_offset(7) );
1841 dst.m_impl_offset = dst_offset_type( src.m_impl_offset , extents );
1842 dst.m_impl_handle.value_ptr = src.m_impl_handle.value_ptr + offset;
1843 dst.m_impl_handle.scalar_ptr =
1844 src.m_impl_handle.scalar_ptr + offset * src.m_sacado_size;
1845 dst.m_sacado_size = src.m_sacado_size;
1846 dst.m_cijk = src.m_cijk;
1847 dst.m_is_contiguous = src.m_is_contiguous;
1863 #if defined( KOKKOS_ENABLE_CUDA )
1864 template<
class OutputView >
1865 struct StokhosViewFill< OutputView ,
1866 typename std::enable_if< std::is_same< typename OutputView::specialize,
1867 Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&
1868 std::is_same< typename OutputView::execution_space,
1869 Cuda >::value >::type >
1871 typedef typename OutputView::const_value_type const_value_type ;
1872 typedef typename Sacado::ScalarType<const_value_type>::type
scalar_type ;
1874 typedef typename OutputView::size_type size_type ;
1876 template <
unsigned VectorLength>
1879 const OutputView output;
1880 const_value_type input;
1882 PCEKernel(
const OutputView & arg_out , const_value_type & arg_in ) :
1883 output(arg_out), input(arg_in) {}
1885 typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1887 KOKKOS_INLINE_FUNCTION
1888 void operator()(
const team_member & dev )
const
1890 const size_type tidx = dev.team_rank() % VectorLength;
1891 const size_type tidy = dev.team_rank() / VectorLength;
1892 const size_type nrow = dev.team_size() / VectorLength;
1895 const size_type i0 = dev.league_rank() * nrow + tidy;
1896 if ( i0 >= output.extent(0) )
return;
1898 for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1899 for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1900 for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1901 for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1902 for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1903 for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1904 for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1905 for ( size_type is = tidx ; is < nvec ; is+=VectorLength ) {
1906 output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1907 input.fastAccessCoeff(is) ;
1912 template <
unsigned VectorLength>
1913 struct ScalarKernel {
1915 const OutputView output;
1918 ScalarKernel(
const OutputView & arg_out ,
const scalar_type & arg_in ) :
1919 output(arg_out), input(arg_in) {}
1921 typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1922 KOKKOS_INLINE_FUNCTION
1923 void operator()(
const team_member & dev )
const
1925 const size_type tidx = dev.team_rank() % VectorLength;
1926 const size_type tidy = dev.team_rank() / VectorLength;
1927 const size_type nrow = dev.team_size() / VectorLength;
1930 const size_type i0 = dev.league_rank() * nrow + tidy;
1931 if ( i0 >= output.extent(0) )
return;
1933 for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1934 for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1935 for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1936 for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1937 for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1938 for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1939 for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1940 for ( size_type is = tidx ; is < npce ; is+=VectorLength ) {
1941 output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1947 StokhosViewFill(
const OutputView & output , const_value_type & input )
1951 const unsigned vector_length =
1955 const size_type block_size = 256;
1957 const size_type rows_per_block = block_size / vector_length;
1958 const size_type
n = output.extent(0);
1959 const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
1960 const size_type team_size = rows_per_block * vector_length;
1961 Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
1965 Kokkos::abort(
"StokhosViewFill: Invalid input value size");
1967 if (input.size() == 1)
1969 config, ScalarKernel<vector_length>(output, input.fastAccessCoeff(0)) );
1971 parallel_for( config, PCEKernel<vector_length>(output, input) );
1975 StokhosViewFill(
const OutputView & output ,
const scalar_type & input )
1979 const unsigned vector_length =
1983 const size_type block_size = 256;
1985 const size_type rows_per_block = block_size / vector_length;
1986 const size_type n = output.extent(0);
1987 const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
1988 const size_type team_size = rows_per_block * vector_length;
1989 Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
1991 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
KOKKOS_FUNCTION std::enable_if_t< N==View< Args...>::rank &&std::is_same< typename ViewTraits< Args...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value, View< Args...> > as_view_of_rank_n(View< Args...> v)
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
Impl::MirrorViewType< Space, T, P...>::view_type create_mirror_view_and_copy(const Space &, const Kokkos::View< T, P...> &src, std::string const &name="", typename std::enable_if< std::is_same< typename ViewTraits< T, P...>::specialize, Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&Impl::MirrorViewType< Space, T, P...>::is_same_memspace >::type *=nullptr)
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 &)
SharedAllocationRecord * allocate_shared(ViewCtorProp< P... > const &prop, typename Traits::array_layout const &layout, bool)
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)