42#ifndef KOKKOS_EXPERIMENTAL_VIEW_UQ_PCE_CONTIGUOUS_HPP
43#define KOKKOS_EXPERIMENTAL_VIEW_UQ_PCE_CONTIGUOUS_HPP
51#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
52#define KOKKOS_IMPL_PUBLIC_INCLUDE
53#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
55#include "Kokkos_Layout.hpp"
56#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
57#undef KOKKOS_IMPL_PUBLIC_INCLUDE
58#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_CORE
69namespace Experimental {
74template<
class ... Args >
77template<
class D ,
class ... P ,
class ... Args >
80 std::is_same<
typename Kokkos::ViewTraits<D,P...>::specialize
83 ( (
sizeof...(Args) == 0 ) ||
93template <
typename T,
typename ... P>
97 std::is_same<
typename view_type::specialize,
101template <
typename ViewType>
103 typename
std::enable_if< is_view_uq_pce< ViewType >::value >::type > {
104 typedef typename ViewType::non_const_value_type::cijk_type
type;
107template <
typename T,
typename ... P>
108KOKKOS_INLINE_FUNCTION
112 return view.impl_map().dimension_scalar();
115template <
typename view_type>
116KOKKOS_INLINE_FUNCTION
118std::enable_if< is_view_uq_pce<view_type>::value,
119 typename CijkType<view_type>::type >::type
121 return view.impl_map().cijk();
124template <
typename view_type>
125KOKKOS_INLINE_FUNCTION
127std::enable_if< is_view_uq_pce<view_type>::value,
bool >::type
129 return view.impl_map().is_allocation_contiguous();
132template <
typename ViewType>
136 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
137 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
139 return ViewType(view_alloc(label,
cijk),
140 N0, N1, N2, N3, N4, N5, N6, N7);
143template <
typename ViewType>
146 const Impl::WithoutInitializing_t& init,
148 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
149 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
151 return ViewType(view_alloc(label,init,
cijk),
152 N0, N1, N2, N3, N4, N5, N6, N7);
155template <
typename ViewType>
159 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
160 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
162 return ViewType(view_alloc(((Kokkos::Impl::ViewCtorProp<void, std::string>)init).value,
165 N0, N1, N2, N3, N4, N5, N6, N7);
168template <
typename ViewType>
169typename std::enable_if< is_view_uq_pce<ViewType>::value, ViewType>::type
172 size_t N0 = 0,
size_t N1 = 0,
size_t N2 = 0,
size_t N3 = 0,
173 size_t N4 = 0,
size_t N5 = 0,
size_t N6 = 0,
size_t N7 = 0)
175 size_t N[8] = { N0, N1, N2, N3, N4, N5, N6, N7 };
176 N[ViewType::rank] =
cijk.dimension();
177 ViewType v(view_wrap(ptr,
cijk),
178 N[0], N[1], N[2], N[3], N[4], N[5], N[6], N[7]);
184#include "Sacado_Traits.hpp"
187#include "Kokkos_Core.hpp"
191template <
typename D,
typename ... P>
193 typename
std::enable_if< is_view_uq_pce< View<D,P...> >::value >::type > {
195 typedef typename view_type::traits::dimension
dimension;
197 typedef typename Kokkos::Impl::ViewDataType< flat_value_type , dimension >::type
flat_data_type;
201template<
class T ,
class ... P >
203typename std::enable_if<
204 std::is_same<
typename ViewTraits<T,P...>::specialize ,
206 !std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
207 Kokkos::LayoutStride >::value,
208 typename Kokkos::View<T,P...>::HostMirror>::type
211 typedef View<T,P...> src_type ;
212 typedef typename src_type::HostMirror dst_type ;
214 typename src_type::array_layout layout = src.layout();
217 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"),
218 src.impl_map().cijk()), layout);
221template<
class T ,
class ... P >
223typename std::enable_if<
224 std::is_same<
typename ViewTraits<T,P...>::specialize ,
226 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
227 Kokkos::LayoutStride >::value,
228 typename Kokkos::View<T,P...>::HostMirror>::type
231 typedef View<T,P...> src_type ;
232 typedef typename src_type::HostMirror dst_type ;
234 Kokkos::LayoutStride layout ;
236 layout.dimension[0] = src.extent(0);
237 layout.dimension[1] = src.extent(1);
238 layout.dimension[2] = src.extent(2);
239 layout.dimension[3] = src.extent(3);
240 layout.dimension[4] = src.extent(4);
241 layout.dimension[5] = src.extent(5);
242 layout.dimension[6] = src.extent(6);
243 layout.dimension[7] = src.extent(7);
245 layout.stride[0] = src.stride_0();
246 layout.stride[1] = src.stride_1();
247 layout.stride[2] = src.stride_2();
248 layout.stride[3] = src.stride_3();
249 layout.stride[4] = src.stride_4();
250 layout.stride[5] = src.stride_5();
251 layout.stride[6] = src.stride_6();
252 layout.stride[7] = src.stride_7();
256 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"),
257 src.impl_map().cijk()), layout);
260template<
class Space,
class T,
class ... P,
typename Enabled>
261 typename std::enable_if<
262 std::is_same<
typename ViewTraits<T,P...>::specialize ,
264 typename Impl::MirrorType<Space,T,P ...>::view_type>::type
267 typedef View<T,P...> src_type ;
268 typename src_type::array_layout layout = src.layout();
271 view_alloc(src.label(), src.impl_map().cijk()),layout);
274template<
class T ,
class ... P >
276typename std::enable_if<
277 std::is_same<
typename ViewTraits<T,P...>::specialize ,
279 !std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
280 Kokkos::LayoutStride >::value,
281 typename Kokkos::View<T,P...>::HostMirror>::type
283 const Kokkos::View<T,P...> & src)
285 typedef View<T,P...> src_type ;
286 typedef typename src_type::HostMirror dst_type ;
288 typename src_type::array_layout layout = src.layout();
291 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"), wi,
292 src.impl_map().cijk()), layout);
295template<
class T ,
class ... P >
297typename std::enable_if<
298 std::is_same<
typename ViewTraits<T,P...>::specialize ,
300 std::is_same<
typename Kokkos::ViewTraits<T,P...>::array_layout,
301 Kokkos::LayoutStride >::value,
302 typename Kokkos::View<T,P...>::HostMirror>::type
304 const Kokkos::View<T,P...> & src)
306 typedef View<T,P...> src_type ;
307 typedef typename src_type::HostMirror dst_type ;
309 Kokkos::LayoutStride layout ;
311 layout.dimension[0] = src.extent(0);
312 layout.dimension[1] = src.extent(1);
313 layout.dimension[2] = src.extent(2);
314 layout.dimension[3] = src.extent(3);
315 layout.dimension[4] = src.extent(4);
316 layout.dimension[5] = src.extent(5);
317 layout.dimension[6] = src.extent(6);
318 layout.dimension[7] = src.extent(7);
320 layout.stride[0] = src.stride_0();
321 layout.stride[1] = src.stride_1();
322 layout.stride[2] = src.stride_2();
323 layout.stride[3] = src.stride_3();
324 layout.stride[4] = src.stride_4();
325 layout.stride[5] = src.stride_5();
326 layout.stride[6] = src.stride_6();
327 layout.stride[7] = src.stride_7();
331 return dst_type(view_alloc(std::string(src.label()).append(
"_mirror"), wi,
332 src.impl_map().cijk()), layout);
335template<
class Space,
class T,
class ... P,
typename Enable>
336typename std::enable_if<
337 std::is_same<
typename ViewTraits<T,P...>::specialize ,
339 typename Impl::MirrorType<Space,T,P ...>::view_type>::type
341 const Space& ,
const Kokkos::View<T,P...> & src)
343 typedef View<T,P...> src_type ;
344 typename src_type::array_layout layout = src.layout();
347 view_alloc(src.label(), wi, src.impl_map().cijk()), layout);
350template <
class Space,
class T,
class... P>
351typename Impl::MirrorViewType<Space, T, P...>::view_type
353 const Space&,
const Kokkos::View<T, P...>& src,
354 std::string
const& name,
355 typename std::enable_if<
356 std::is_same<
typename ViewTraits<T, P...>::specialize,
362 "Kokkos::create_mirror_view_and_copy: fence before returning src view");
366template <
class Space,
class T,
class... P>
367typename Impl::MirrorViewType<Space, T, P...>::view_type
369 const Space&,
const Kokkos::View<T, P...>& src,
370 std::string
const& name,
371 typename std::enable_if<
372 std::is_same<
typename ViewTraits<T, P...>::specialize,
376 using src_type =
View<T,P...>;
378 std::string label = name.empty() ? src.label() : name;
379 typename src_type::array_layout layout = src.layout();
381 auto mirror =
typename Mirror::non_const_type{
382 view_alloc(WithoutInitializing, label, src.impl_map().cijk()), layout};
388template<
class DT,
class ... DP >
390 const View<DT,DP...> & view ,
391 const typename View<DT,DP...>::array_type::value_type & value
392 ,
typename std::enable_if<(
393 std::is_same<
typename ViewTraits<DT,DP...>::specialize
398 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
399 typename ViewTraits<DT,DP...>::non_const_value_type >::value
400 ,
"Can only deep copy into non-const type" );
402 typedef View<DT,DP...> view_type;
403 typedef typename view_type::array_type::value_type scalar_type;
405 if (value == scalar_type(0))
412template<
class DT,
class ... DP >
414 const View<DT,DP...> & view ,
415 const typename View<DT,DP...>::value_type & value
416 ,
typename std::enable_if<(
417 std::is_same<
typename ViewTraits<DT,DP...>::specialize
422 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
423 typename ViewTraits<DT,DP...>::non_const_value_type >::value
424 ,
"Can only deep copy into non-const type" );
430template<
class ExecSpace ,
class DT,
class ... DP >
433 const View<DT,DP...> & view ,
434 const typename View<DT,DP...>::array_type::value_type & value
435 ,
typename std::enable_if<(
436 Kokkos::is_execution_space< ExecSpace >::value &&
437 std::is_same<
typename ViewTraits<DT,DP...>::specialize
442 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
443 typename ViewTraits<DT,DP...>::non_const_value_type >::value
444 ,
"Can only deep copy into non-const type" );
446 typedef View<DT,DP...> view_type;
447 typedef typename view_type::array_type::value_type scalar_type;
449 if (value == scalar_type(0))
456template<
class ExecSpace ,
class DT,
class ... DP >
459 const View<DT,DP...> & view ,
460 const typename View<DT,DP...>::value_type & value
461 ,
typename std::enable_if<(
462 Kokkos::is_execution_space< ExecSpace >::value &&
463 std::is_same<
typename ViewTraits<DT,DP...>::specialize
468 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
469 typename ViewTraits<DT,DP...>::non_const_value_type >::value
470 ,
"Can only deep copy into non-const type" );
475namespace Experimental {
480template<
class OutputView ,
class InputView >
490 const InputView & arg_in ) :
493 parallel_for(
output.extent(0) , *
this );
497 KOKKOS_INLINE_FUNCTION
507 output.access(i0,i1,i2,i3,i4,i5,i6,i7) =
input.access(i0,i1,i2,i3,i4,i5,i6,i7) ;
516template<
class ExecSpace,
class DT ,
class ... DP ,
class ST ,
class ... SP >
519 const View<DT,DP...> & dst ,
520 const View<ST,SP...> & src
521 ,
typename std::enable_if<(
522 std::is_same<
typename ViewTraits<DT,DP...>::specialize
525 std::is_same<
typename ViewTraits<ST,SP...>::specialize
530 std::is_same<
typename ViewTraits<DT,DP...>::value_type ,
531 typename ViewTraits<DT,DP...>::non_const_value_type >::value
532 ,
"Deep copy destination must be non-const" );
535 ( unsigned(ViewTraits<DT,DP...>::rank) ==
536 unsigned(ViewTraits<ST,SP...>::rank) )
537 ,
"Deep copy destination and source must have same rank" );
539 typedef View<DT,DP...> dst_type ;
540 typedef View<ST,SP...> src_type ;
541 typedef typename dst_type::array_type dst_array_type ;
542 typedef typename src_type::array_type src_array_type ;
545 dst_array_type dst_array = dst ;
546 src_array_type src_array = src ;
547 deep_copy( ExecSpace(), dst_array , src_array );
554 if ( std::is_same<
typename dst_type::memory_space ,
555 typename src_type::memory_space >::value ) {
561 typedef View<
typename src_type::non_const_data_type ,
562 std::conditional_t<std::is_same<
typename src_type::array_layout,
563 Kokkos::LayoutStride>::value,
565 typename src_type::array_layout>,
566 typename src_type::execution_space > tmp_src_type;
567 typedef typename tmp_src_type::array_type tmp_src_array_type;
568 typedef View<
typename dst_type::non_const_data_type ,
569 std::conditional_t<std::is_same<
typename dst_type::array_layout,
570 Kokkos::LayoutStride>::value,
572 typename dst_type::array_layout>,
573 typename dst_type::execution_space > tmp_dst_type;
574 typedef typename tmp_dst_type::array_type tmp_dst_array_type;
582 src_dims[0] = src.extent(0);
583 src_dims[1] = src.extent(1);
584 src_dims[2] = src.extent(2);
585 src_dims[3] = src.extent(3);
586 src_dims[4] = src.extent(4);
587 src_dims[5] = src.extent(5);
588 src_dims[6] = src.extent(6);
589 src_dims[7] = src.extent(7);
591 tmp_src_type src_tmp(
592 view_alloc(
"src_tmp" , WithoutInitializing,
cijk(src) ) ,
593 src_dims[0], src_dims[1], src_dims[2], src_dims[3],
594 src_dims[4], src_dims[5], src_dims[6], src_dims[7] );
596 dst_array_type dst_array = dst ;
597 tmp_src_array_type src_array = src_tmp ;
598 deep_copy( ExecSpace(), dst_array , src_array );
607 dst_dims[0] = dst.extent(0);
608 dst_dims[1] = dst.extent(1);
609 dst_dims[2] = dst.extent(2);
610 dst_dims[3] = dst.extent(3);
611 dst_dims[4] = dst.extent(4);
612 dst_dims[5] = dst.extent(5);
613 dst_dims[6] = dst.extent(6);
614 dst_dims[7] = dst.extent(7);
616 tmp_dst_type dst_tmp(
617 view_alloc(
"dst_tmp" , WithoutInitializing,
cijk(dst) ) ,
618 dst_dims[0], dst_dims[1], dst_dims[2], dst_dims[3],
619 dst_dims[4], dst_dims[5], dst_dims[6], dst_dims[7] );
620 tmp_dst_array_type dst_array = dst_tmp ;
621 src_array_type src_array = src ;
622 deep_copy( ExecSpace(), dst_array , src_array );
631 src_dims[0] = src.extent(0);
632 src_dims[1] = src.extent(1);
633 src_dims[2] = src.extent(2);
634 src_dims[3] = src.extent(3);
635 src_dims[4] = src.extent(4);
636 src_dims[5] = src.extent(5);
637 src_dims[6] = src.extent(6);
638 src_dims[7] = src.extent(7);
640 tmp_src_type src_tmp(
641 view_alloc(
"src_tmp" , WithoutInitializing,
cijk(src) ) ,
642 src_dims[0], src_dims[1], src_dims[2], src_dims[3],
643 src_dims[4], src_dims[5], src_dims[6], src_dims[7] );
647 dst_dims[0] = dst.extent(0);
648 dst_dims[1] = dst.extent(1);
649 dst_dims[2] = dst.extent(2);
650 dst_dims[3] = dst.extent(3);
651 dst_dims[4] = dst.extent(4);
652 dst_dims[5] = dst.extent(5);
653 dst_dims[6] = dst.extent(6);
654 dst_dims[7] = dst.extent(7);
656 tmp_dst_type dst_tmp(
657 view_alloc(
"dst_tmp" , WithoutInitializing,
cijk(dst) ) ,
658 dst_dims[0], dst_dims[1], dst_dims[2], dst_dims[3],
659 dst_dims[4], dst_dims[5], dst_dims[6], dst_dims[7] );
660 tmp_dst_array_type dst_array = dst_tmp ;
661 tmp_src_array_type src_array = src_tmp ;
662 deep_copy( ExecSpace(), dst_array , src_array );
670template<
class DT ,
class ... DP ,
class ST ,
class ... SP >
673 const View<ST,SP...> & src
674 ,
typename std::enable_if<(
675 std::is_same<
typename ViewTraits<DT,DP...>::specialize
678 std::is_same<
typename ViewTraits<ST,SP...>::specialize
690template <
unsigned N,
typename... Args>
691KOKKOS_FUNCTION std::enable_if_t<
692 N ==
View<Args...>::Rank &&
693 std::is_same<
typename ViewTraits<Args...>::specialize,
702template <
unsigned N,
typename T,
typename... Args>
704 N !=
View<T, Args...>::Rank &&
705 std::is_same<
typename ViewTraits<T, Args...>::specialize,
707 View<
typename RankDataType<
typename View<T, Args...>::value_type, N>::type,
710 Kokkos::Impl::throw_runtime_exception(
711 "Trying to get at a View of the wrong rank");
728template<
typename Value,
typename Execution,
typename Memory >
729struct ViewCtorProp< void ,
Stokhos::CrsProductTensor<Value, Execution, Memory> >
733 ViewCtorProp & operator = (
const ViewCtorProp & ) = default ;
743template <
typename AllocProp>
749template<
typename T >
755template<
typename Value,
typename Execution,
typename Memory >
757 ViewCtorProp<
Stokhos::CrsProductTensor<Value, Execution, Memory> >
763template<
typename T,
typename ... P >
774template <
typename CijkType,
typename AllocProp>
775KOKKOS_INLINE_FUNCTION
776typename std::enable_if< !Impl::ctor_prop_has_cijk<AllocProp>::value,
783template <
typename CijkType,
typename AllocProp>
784KOKKOS_INLINE_FUNCTION
785typename std::enable_if< Impl::ctor_prop_has_cijk<AllocProp>::value,
789 return ( (
const Impl::ViewCtorProp<void,CijkType>&) prop ).value;
801template<
class DataType ,
class ArrayLayout ,
typename StorageType >
802struct ViewDataAnalysis< DataType
804 ,
Sacado::UQ::PCE< StorageType > >
823 ViewDataType< value_type , dimension >::type
type ;
825 ViewDataType< const_value_type , dimension >::type
const_type ;
832 enum { is_const = std::is_same< value_type , const_value_type >::value };
836 std::conditional< is_const , const ScalarType , ScalarType >::type
843 typedef typename array_analysis::dimension::
844 template prepend<0>::type
846 typedef typename array_analysis::dimension::
847 template append<0>::type
849 typedef typename std::conditional<
850 std::is_same< ArrayLayout, Kokkos::LayoutLeft>::value,
861 ViewDataType< const_scalar_type , scalar_dimension >::type
865 ViewDataType< non_const_scalar_type , scalar_dimension >::type
875namespace Experimental {
883template <
class ValueType>
892 KOKKOS_INLINE_FUNCTION
893 static constexpr size_t
898 KOKKOS_INLINE_FUNCTION
901 template <
typename T>
902 KOKKOS_INLINE_FUNCTION
912 KOKKOS_INLINE_FUNCTION
918 template <
class ExecSpace>
936 const unsigned pce_size,
942 if ( !
m_space.in_parallel() ) {
943 typedef Kokkos::RangePolicy< ExecSpace > PolicyType ;
944 const Kokkos::Impl::ParallelFor< PCEConstruct , PolicyType >
945 closure( *
this , PolicyType( 0 ,
m_span ) );
950 for (
size_t i = 0 ; i <
m_span ; ++i )
operator()(i);
954 KOKKOS_INLINE_FUNCTION
960 template <
class ExecSpace>
973 const bool initialize,
975 const unsigned pce_size,
1010 template <
class ExecSpace>
1011 inline ConstructDestructFunctor<ExecSpace>
1013 const bool initialize,
1015 const unsigned pce_size,
1024 template <
typename T>
1039template<
class Traits >
1040class ViewMapping< Traits ,
1041 typename
std::enable_if<
1042 ( std::is_same< typename Traits::specialize
1043 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1045 ( std::is_same< typename Traits::array_layout
1046 , Kokkos::LayoutLeft >::value
1048 std::is_same< typename Traits::array_layout
1049 , Kokkos::LayoutRight >::value
1051 std::is_same< typename Traits::array_layout
1052 , Kokkos::LayoutStride >::value
1055 , typename Traits::specialize
1060 template< class ,
class ... >
friend class ViewMapping ;
1061 template< class ,
class ... >
friend class Kokkos::View ;
1074 typedef ViewOffset<
typename Traits::dimension
1075 ,
typename Traits::array_layout
1082 typedef ViewOffset<
typename array_dimension::
1083 template append<0>::type,
1084 typename Traits::array_layout,
1087 typedef ViewOffset<
typename array_dimension::
1088 template prepend<0>::type,
1089 typename Traits::array_layout,
1092 typedef typename std::conditional<
1093 std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft>::value,
1106 KOKKOS_INLINE_FUNCTION
1108 const size_t sz = this->span();
1114 m_impl_handle.
scalar_ptr + (sz-1)*m_sacado_size;
1115 return last_coeff == last_coeff_expected;
1123 enum { Rank = Traits::dimension::rank };
1126 enum { Sacado_Rank = std::is_same< typename Traits::array_layout, Kokkos::LayoutLeft >::value ? 0 : Rank+1 };
1129 template<
typename iType >
1130 KOKKOS_INLINE_FUNCTION
constexpr size_t extent(
const iType & r )
const
1131 {
return m_impl_offset.m_dim.extent(r); }
1133 KOKKOS_INLINE_FUNCTION
constexpr
1135 {
return m_impl_offset.layout(); }
1138 {
return m_impl_offset.dimension_0(); }
1140 {
return m_impl_offset.dimension_1(); }
1142 {
return m_impl_offset.dimension_2(); }
1144 {
return m_impl_offset.dimension_3(); }
1146 {
return m_impl_offset.dimension_4(); }
1148 {
return m_impl_offset.dimension_5(); }
1150 {
return m_impl_offset.dimension_6(); }
1152 {
return m_impl_offset.dimension_7(); }
1159 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_0()
const
1160 {
return m_impl_offset.stride_0(); }
1161 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_1()
const
1162 {
return m_impl_offset.stride_1(); }
1163 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_2()
const
1164 {
return m_impl_offset.stride_2(); }
1165 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_3()
const
1166 {
return m_impl_offset.stride_3(); }
1167 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_4()
const
1168 {
return m_impl_offset.stride_4(); }
1169 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_5()
const
1170 {
return m_impl_offset.stride_5(); }
1171 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_6()
const
1172 {
return m_impl_offset.stride_6(); }
1173 KOKKOS_INLINE_FUNCTION
constexpr size_t stride_7()
const
1174 {
return m_impl_offset.stride_7(); }
1176 template<
typename iType >
1177 KOKKOS_INLINE_FUNCTION
void stride( iType *
const s )
const
1178 { m_impl_offset.stride(s); }
1182 {
return m_sacado_size; }
1185 KOKKOS_FORCEINLINE_FUNCTION
1190 KOKKOS_FORCEINLINE_FUNCTION
1195 KOKKOS_INLINE_FUNCTION
1197 {
return m_is_contiguous; }
1200 static const bool is_static = false ;
1203 static const bool is_contiguous =
true;
1215 KOKKOS_INLINE_FUNCTION
constexpr size_t span()
const
1216 {
return m_impl_offset.span(); }
1220 {
return m_impl_offset.span_is_contiguous() ; }
1228 KOKKOS_FORCEINLINE_FUNCTION
1233 template<
typename I0 >
1234 KOKKOS_FORCEINLINE_FUNCTION
1236 std::enable_if< std::is_integral<I0>::value &&
1237 ! std::is_same< typename Traits::array_layout , Kokkos::LayoutStride >::value
1238 , reference_type >::type
1243 template<
typename I0 >
1244 KOKKOS_FORCEINLINE_FUNCTION
1246 std::enable_if< std::is_integral<I0>::value &&
1247 std::is_same< typename Traits::array_layout , Kokkos::LayoutStride >::value
1248 , reference_type >::type
1250 {
return m_impl_handle.
value_ptr[ m_impl_offset(i0) ]; }
1252 template<
typename I0 ,
typename I1 >
1253 KOKKOS_FORCEINLINE_FUNCTION
1255 {
return m_impl_handle.
value_ptr[ m_impl_offset(i0,i1) ]; }
1257 template<
typename I0 ,
typename I1 ,
typename I2 >
1258 KOKKOS_FORCEINLINE_FUNCTION
1260 {
return m_impl_handle.
value_ptr[ m_impl_offset(i0,i1,i2) ]; }
1262 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3 >
1263 KOKKOS_FORCEINLINE_FUNCTION
1265 {
return m_impl_handle.
value_ptr[ m_impl_offset(i0,i1,i2,i3) ]; }
1267 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1269 KOKKOS_FORCEINLINE_FUNCTION
1271 ,
const I4 & i4 )
const
1272 {
return m_impl_handle.
value_ptr[ m_impl_offset(i0,i1,i2,i3,i4) ]; }
1274 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1275 ,
typename I4 ,
typename I5 >
1276 KOKKOS_FORCEINLINE_FUNCTION
1278 ,
const I4 & i4 ,
const I5 & i5 )
const
1279 {
return m_impl_handle.
value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5) ]; }
1281 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1282 ,
typename I4 ,
typename I5 ,
typename I6 >
1283 KOKKOS_FORCEINLINE_FUNCTION
1285 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 )
const
1286 {
return m_impl_handle.
value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5,i6) ]; }
1288 template<
typename I0 ,
typename I1 ,
typename I2 ,
typename I3
1289 ,
typename I4 ,
typename I5 ,
typename I6 ,
typename I7 >
1290 KOKKOS_FORCEINLINE_FUNCTION
1292 ,
const I4 & i4 ,
const I5 & i5 ,
const I6 & i6 ,
const I7 & i7 )
const
1293 {
return m_impl_handle.
value_ptr[ m_impl_offset(i0,i1,i2,i3,i4,i5,i6,i7) ]; }
1298 KOKKOS_INLINE_FUNCTION
1299 static size_t memory_span(
typename Traits::array_layout
const & layout )
1302 typedef std::integral_constant< unsigned , 0 > padding ;
1304 unsigned sacado_size =
1306 return handle_type::memory_span( offset.span(), sacado_size );
1317 m_is_contiguous(
true)
1320 KOKKOS_DEFAULTED_FUNCTION
ViewMapping(
const ViewMapping & ) = default ;
1321 KOKKOS_DEFAULTED_FUNCTION ViewMapping & operator = (
const ViewMapping & ) = default ;
1324 KOKKOS_DEFAULTED_FUNCTION ViewMapping & operator = ( ViewMapping && ) = default ;
1326 template<
class ... P >
1327 KOKKOS_INLINE_FUNCTION
1329 ( ViewCtorProp< P ... >
const & prop
1330 ,
typename Traits::array_layout
const & layout
1333 , m_impl_offset(
std::integral_constant< unsigned , 0 >() , layout )
1336 m_impl_handle.
set( ( (ViewCtorProp<void,pointer_type>
const &) prop ).value
1337 , m_impl_offset.span(), m_sacado_size );
1338 m_cijk = extract_cijk<cijk_type>(prop);
1339#ifndef __CUDA_ARCH__
1340 if (m_cijk.dimension() == 0)
1341 m_cijk = getGlobalCijkTensor<cijk_type>();
1344 if (m_sacado_size == 0 ||
1345 m_sacado_size ==
unsigned(KOKKOS_IMPL_CTOR_DEFAULT_ARG))
1346 m_sacado_size = m_cijk.dimension();
1348 m_is_contiguous = this->is_data_contiguous();
1352 KOKKOS_INLINE_FUNCTION
1354 { m_impl_handle.
set( arg_ptr, m_impl_offset.span(), m_sacado_size ); }
1361 template<
class ... P >
1362 SharedAllocationRecord<> *
1364 ,
typename Traits::array_layout
const & layout )
1366 typedef ViewCtorProp< P... > ctor_prop ;
1369 typedef typename Traits::memory_space memory_space ;
1370 typedef typename handle_type::template ConstructDestructFunctor<execution_space> functor_type ;
1371 typedef SharedAllocationRecord< memory_space , functor_type > record_type ;
1374 typedef std::integral_constant< unsigned , 0 > padding ;
1378 m_cijk = extract_cijk<cijk_type>(prop);
1379 if (m_cijk.dimension() == 0)
1380 m_cijk = getGlobalCijkTensor<cijk_type>();
1383 if (m_sacado_size == 0 ||
1384 m_sacado_size ==
unsigned(KOKKOS_IMPL_CTOR_DEFAULT_ARG))
1385 m_sacado_size = m_cijk.dimension();
1386 m_is_contiguous =
true;
1388 const size_t alloc_size =
1389 handle_type::memory_span( m_impl_offset.span(), m_sacado_size );
1392 record_type *
const record =
1393 record_type::allocate( ( (ViewCtorProp<void,memory_space>
const &) prop ).value
1394 , ( (ViewCtorProp<void,std::string>
const &) prop ).value
1401 m_impl_handle.
set(
reinterpret_cast< pointer_type >( record->data() ),
1402 m_impl_offset.span(), m_sacado_size );
1407 ( (ViewCtorProp<void,execution_space>
const &) prop).value
1408 , ctor_prop::initialize
1409 , m_impl_offset.span()
1414 record->m_destroy.construct_shared_allocation();
1420 template<
class ... P >
1421 SharedAllocationRecord<> *
1423 ,
typename Traits::array_layout
const & layout
1426 return allocate_shared(prop, layout);
1443template<
class DstTraits ,
class SrcTraits >
1444class ViewMapping< DstTraits , SrcTraits ,
1445 typename
std::enable_if<(
1446 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1447 , typename SrcTraits::memory_space >::assignable
1450 std::is_same< typename DstTraits::specialize
1451 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1454 std::is_same< typename SrcTraits::specialize
1455 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1457 , typename DstTraits::specialize
1462 enum { is_assignable =
true };
1463 enum { is_assignable_data_type =
true };
1466 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1467 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1469 KOKKOS_INLINE_FUNCTION
static
1476 std::is_same<
typename DstTraits::array_layout
1477 , Kokkos::LayoutLeft >::value ||
1478 std::is_same<
typename DstTraits::array_layout
1479 , Kokkos::LayoutRight >::value ||
1480 std::is_same<
typename DstTraits::array_layout
1481 , Kokkos::LayoutStride >::value
1485 std::is_same<
typename SrcTraits::array_layout
1486 , Kokkos::LayoutLeft >::value ||
1487 std::is_same<
typename SrcTraits::array_layout
1488 , Kokkos::LayoutRight >::value ||
1489 std::is_same<
typename SrcTraits::array_layout
1490 , Kokkos::LayoutStride >::value
1492 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1495 std::is_same<
typename DstTraits::array_layout
1496 ,
typename SrcTraits::array_layout >::value ||
1497 std::is_same<
typename DstTraits::array_layout
1498 , Kokkos::LayoutStride >::value ||
1499 ( unsigned(DstTraits::rank) == 1 && unsigned(SrcTraits::rank) == 1 ) ,
1500 "View assignment must have compatible layout" );
1503 std::is_same<
typename DstTraits::value_type
1504 ,
typename SrcTraits::value_type >::value ||
1505 std::is_same<
typename DstTraits::value_type
1506 ,
typename SrcTraits::const_value_type >::value ,
1507 "View assignment must have same value type or const = non-const" );
1510 ViewDimensionAssignable
1511 <
typename DstType::offset_type::dimension_type
1512 ,
typename SrcType::offset_type::dimension_type >::value ,
1513 "View assignment must have compatible dimensions" );
1515 dst.m_impl_handle = src.m_impl_handle ;
1516 dst.m_impl_offset = src.m_impl_offset ;
1517 dst.m_sacado_size = src.m_sacado_size ;
1518 dst.m_cijk = src.m_cijk ;
1519 dst.m_is_contiguous = src.m_is_contiguous ;
1528template<
class DstTraits ,
class SrcTraits >
1529class ViewMapping< DstTraits , SrcTraits ,
1530 typename
std::enable_if<(
1531 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1532 , typename SrcTraits::memory_space >::assignable
1535 std::is_same< typename DstTraits::specialize , void >::value
1538 std::is_same< typename SrcTraits::specialize
1539 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1542 unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)+1
1544 , typename DstTraits::specialize
1549 enum { is_assignable =
true };
1550 enum { is_assignable_data_type =
true };
1553 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1554 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1556 KOKKOS_INLINE_FUNCTION
static
1563 std::is_same<
typename DstTraits::array_layout
1564 , Kokkos::LayoutLeft >::value ||
1565 std::is_same<
typename DstTraits::array_layout
1566 , Kokkos::LayoutRight >::value ||
1567 std::is_same<
typename DstTraits::array_layout
1568 , Kokkos::LayoutStride >::value
1572 std::is_same<
typename SrcTraits::array_layout
1573 , Kokkos::LayoutLeft >::value ||
1574 std::is_same<
typename SrcTraits::array_layout
1575 , Kokkos::LayoutRight >::value ||
1576 std::is_same<
typename SrcTraits::array_layout
1577 , Kokkos::LayoutStride >::value
1579 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1582 std::is_same<
typename DstTraits::array_layout
1583 ,
typename SrcTraits::array_layout >::value ||
1584 std::is_same<
typename DstTraits::array_layout
1585 , Kokkos::LayoutStride >::value ,
1586 "View assignment must have compatible layout" );
1589 std::is_same<
typename DstTraits::scalar_array_type
1590 ,
typename SrcTraits::scalar_array_type >::value ||
1591 std::is_same<
typename DstTraits::scalar_array_type
1592 ,
typename SrcTraits::const_scalar_array_type >::value ,
1593 "View assignment must have same value type or const = non-const" );
1596 ViewDimensionAssignable<
1597 typename DstType::offset_type::dimension_type,
1598 typename SrcType::array_offset_type::dimension_type >::value,
1599 "View assignment must have compatible dimensions" );
1601 if ( !src.m_is_contiguous )
1602 Kokkos::abort(
"\n\n ****** Kokkos::View< Sacado::UQ::PCE ... >: can't assign non-contiguous view ******\n\n");
1605 dims[0] = src.m_impl_offset.dimension_0();
1606 dims[1] = src.m_impl_offset.dimension_1();
1607 dims[2] = src.m_impl_offset.dimension_2();
1608 dims[3] = src.m_impl_offset.dimension_3();
1609 dims[4] = src.m_impl_offset.dimension_4();
1610 dims[5] = src.m_impl_offset.dimension_5();
1611 dims[6] = src.m_impl_offset.dimension_6();
1612 dims[7] = src.m_impl_offset.dimension_7();
1613 unsigned rank = SrcTraits::dimension::rank;
1614 unsigned sacado_size = src.m_sacado_size;
1615 if (std::is_same<typename SrcTraits::array_layout, LayoutLeft>::value) {
1617 for (
unsigned i=rank; i>0; --i)
1618 dims[i] = dims[i-1];
1619 dims[0] = sacado_size;
1622 dims[rank] = sacado_size;
1624 typedef typename DstType::offset_type dst_offset_type;
1625 dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1626 typename DstTraits::array_layout(
1627 dims[0] , dims[1] , dims[2] , dims[3] ,
1628 dims[4] , dims[5] , dims[6] , dims[7] ) );
1629 dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1639template<
class DstTraits ,
class SrcTraits >
1640class ViewMapping< DstTraits , SrcTraits ,
1641 typename
std::enable_if<(
1642 Kokkos::Impl::MemorySpaceAccess< typename DstTraits::memory_space
1643 , typename SrcTraits::memory_space >::assignable
1646 std::is_same< typename DstTraits::specialize , void >::value
1649 std::is_same< typename SrcTraits::specialize
1650 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1653 unsigned(DstTraits::dimension::rank) == unsigned(SrcTraits::dimension::rank)
1655 , typename DstTraits::specialize
1660 enum { is_assignable =
true };
1661 enum { is_assignable_data_type =
true };
1664 typedef ViewMapping< DstTraits , typename DstTraits::specialize >
DstType ;
1665 typedef ViewMapping< SrcTraits , typename SrcTraits::specialize >
SrcType ;
1667 KOKKOS_INLINE_FUNCTION
static
1674 std::is_same<
typename DstTraits::array_layout
1675 , Kokkos::LayoutLeft >::value ||
1676 std::is_same<
typename DstTraits::array_layout
1677 , Kokkos::LayoutRight >::value ||
1678 std::is_same<
typename DstTraits::array_layout
1679 , Kokkos::LayoutStride >::value
1683 std::is_same<
typename SrcTraits::array_layout
1684 , Kokkos::LayoutLeft >::value ||
1685 std::is_same<
typename SrcTraits::array_layout
1686 , Kokkos::LayoutRight >::value ||
1687 std::is_same<
typename SrcTraits::array_layout
1688 , Kokkos::LayoutStride >::value
1690 ,
"View of UQ::PCE requires LayoutLeft, LayoutRight, or LayoutStride" );
1693 std::is_same<
typename DstTraits::array_layout
1694 ,
typename SrcTraits::array_layout >::value ||
1695 std::is_same<
typename DstTraits::array_layout
1696 , Kokkos::LayoutStride >::value ,
1697 "View assignment must have compatible layout" );
1700 std::is_same<
typename DstTraits::value_type
1701 ,
typename SrcTraits::non_const_value_type::value_type >::value ||
1702 std::is_same<
typename DstTraits::value_type
1703 ,
const typename SrcTraits::non_const_value_type::value_type >::value ,
1704 "View assignment must have same value type or const = non-const" );
1707 ViewDimensionAssignable<
1708 typename DstType::offset_type::dimension_type,
1709 typename SrcType::offset_type::dimension_type >::value,
1710 "View assignment must have compatible dimensions" );
1712 if ( !src.m_is_contiguous )
1713 Kokkos::abort(
"\n\n ****** Kokkos::View< Sacado::UQ::PCE ... >: can't assign non-contiguous view ******\n\n");
1716 dims[0] = src.m_impl_offset.dimension_0();
1717 dims[1] = src.m_impl_offset.dimension_1();
1718 dims[2] = src.m_impl_offset.dimension_2();
1719 dims[3] = src.m_impl_offset.dimension_3();
1720 dims[4] = src.m_impl_offset.dimension_4();
1721 dims[5] = src.m_impl_offset.dimension_5();
1722 dims[6] = src.m_impl_offset.dimension_6();
1723 dims[7] = src.m_impl_offset.dimension_7();
1724 unsigned rank = SrcTraits::dimension::rank;
1725 unsigned sacado_size = src.m_sacado_size;
1726 if (std::is_same<typename DstTraits::array_layout, LayoutLeft>::value) {
1727 dims[0] = dims[0]*sacado_size;
1731 dims[rank-1] = dims[rank-1]*sacado_size;
1734 typedef typename DstType::offset_type dst_offset_type;
1735 dst.m_impl_offset = dst_offset_type( std::integral_constant< unsigned , 0 >(),
1736 typename DstTraits::array_layout(
1737 dims[0] , dims[1] , dims[2] , dims[3] ,
1738 dims[4] , dims[5] , dims[6] , dims[7] ) );
1739 dst.m_impl_handle = src.m_impl_handle.scalar_ptr ;
1753template<
class DataType,
class ... P ,
class Arg0,
class ... Args >
1755 < typename
std::enable_if<(
1757 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::specialize
1758 , Kokkos::Experimental::Impl::ViewPCEContiguous >::value
1761 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1762 , Kokkos::LayoutLeft >::value ||
1763 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1764 , Kokkos::LayoutRight >::value ||
1765 std::is_same< typename Kokkos::ViewTraits<DataType,P...>::array_layout
1766 , Kokkos::LayoutStride >::value
1769 , Kokkos::ViewTraits<DataType,P...>
1780 , R0 = bool(is_integral_extent<0,Arg0,Args...>::value)
1781 , R1 = bool(is_integral_extent<1,Arg0,Args...>::value)
1782 , R2 = bool(is_integral_extent<2,Arg0,Args...>::value)
1783 , R3 = bool(is_integral_extent<3,Arg0,Args...>::value)
1784 , R4 = bool(is_integral_extent<4,Arg0,Args...>::value)
1785 , R5 = bool(is_integral_extent<5,Arg0,Args...>::value)
1786 , R6 = bool(is_integral_extent<6,Arg0,Args...>::value)
1790 enum { rank = unsigned(R0) + unsigned(R1) + unsigned(R2) + unsigned(R3)
1791 + unsigned(R4) + unsigned(R5) + unsigned(R6) };
1794 enum { R0_rev = ( 0 == SrcTraits::rank ? RZ : (
1795 1 == SrcTraits::rank ? R0 : (
1796 2 == SrcTraits::rank ? R1 : (
1797 3 == SrcTraits::rank ? R2 : (
1798 4 == SrcTraits::rank ? R3 : (
1799 5 == SrcTraits::rank ? R4 : (
1800 6 == SrcTraits::rank ? R5 : R6 ))))))) };
1803 typedef typename std::conditional<
1809 ( rank <= 2 && R0 && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutLeft >::value )
1813 ( rank <= 2 && R0_rev && std::is_same< typename SrcTraits::array_layout , Kokkos::LayoutRight >::value )
1814 ),
typename SrcTraits::array_layout , Kokkos::LayoutStride
1827 >::type >::type >::type >::type >::type >::type >::type
1832 typedef Kokkos::ViewTraits
1835 ,
typename SrcTraits::device_type
1838 typedef Kokkos::View
1841 ,
typename SrcTraits::device_type
1842 ,
typename SrcTraits::memory_traits >
type ;
1847 template<
class DstTraits >
1848 KOKKOS_INLINE_FUNCTION
1849 static void assign( ViewMapping< DstTraits , typename DstTraits::specialize > & dst
1850 , ViewMapping< SrcTraits , typename SrcTraits::specialize >
const & src
1851 , Arg0 arg0, Args ... args )
1854 ViewMapping< DstTraits , traits_type , typename DstTraits::specialize >::is_assignable ,
1855 "Subview destination type must be compatible with subview derived type" );
1857 typedef ViewMapping< DstTraits , typename DstTraits::specialize > DstType ;
1858 typedef typename DstType::offset_type dst_offset_type ;
1860 const SubviewExtents< SrcTraits::rank , rank >
1861 extents( src.m_impl_offset.m_dim , arg0 , args... );
1863 const size_t offset = src.m_impl_offset( extents.domain_offset(0)
1864 , extents.domain_offset(1)
1865 , extents.domain_offset(2)
1866 , extents.domain_offset(3)
1867 , extents.domain_offset(4)
1868 , extents.domain_offset(5)
1869 , extents.domain_offset(6)
1870 , extents.domain_offset(7) );
1872 dst.m_impl_offset = dst_offset_type( src.m_impl_offset , extents );
1873 dst.m_impl_handle.value_ptr = src.m_impl_handle.value_ptr + offset;
1874 dst.m_impl_handle.scalar_ptr =
1875 src.m_impl_handle.scalar_ptr + offset * src.m_sacado_size;
1876 dst.m_sacado_size = src.m_sacado_size;
1877 dst.m_cijk = src.m_cijk;
1878 dst.m_is_contiguous = src.m_is_contiguous;
1894#if defined( KOKKOS_ENABLE_CUDA )
1895template<
class OutputView >
1896struct StokhosViewFill< OutputView ,
1897 typename
std::enable_if< std::is_same< typename OutputView::specialize,
1898 Kokkos::Experimental::Impl::ViewPCEContiguous >::value &&
1899 std::is_same< typename OutputView::execution_space,
1900 Cuda >::value >::type >
1903 typedef typename Sacado::ScalarType<const_value_type>::type
scalar_type ;
1905 typedef typename OutputView::size_type size_type ;
1907 template <
unsigned VectorLength>
1910 const OutputView output;
1911 const_value_type input;
1913 PCEKernel(
const OutputView & arg_out , const_value_type & arg_in ) :
1914 output(arg_out), input(arg_in) {}
1916 typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1918 KOKKOS_INLINE_FUNCTION
1919 void operator()(
const team_member & dev )
const
1921 const size_type tidx = dev.team_rank() % VectorLength;
1922 const size_type tidy = dev.team_rank() / VectorLength;
1923 const size_type nrow = dev.team_size() / VectorLength;
1926 const size_type i0 = dev.league_rank() * nrow + tidy;
1927 if ( i0 >= output.extent(0) )
return;
1929 for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1930 for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1931 for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1932 for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1933 for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1934 for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1935 for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1936 for ( size_type is = tidx ; is < nvec ; is+=VectorLength ) {
1937 output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1938 input.fastAccessCoeff(is) ;
1943 template <
unsigned VectorLength>
1944 struct ScalarKernel {
1946 const OutputView output;
1949 ScalarKernel(
const OutputView & arg_out ,
const scalar_type & arg_in ) :
1950 output(arg_out), input(arg_in) {}
1952 typedef typename Kokkos::TeamPolicy< execution_space >::member_type team_member ;
1953 KOKKOS_INLINE_FUNCTION
1954 void operator()(
const team_member & dev )
const
1956 const size_type tidx = dev.team_rank() % VectorLength;
1957 const size_type tidy = dev.team_rank() / VectorLength;
1958 const size_type nrow = dev.team_size() / VectorLength;
1961 const size_type i0 = dev.league_rank() * nrow + tidy;
1962 if ( i0 >= output.extent(0) )
return;
1964 for ( size_type i1 = 0 ; i1 < output.extent(1) ; ++i1 ) {
1965 for ( size_type i2 = 0 ; i2 < output.extent(2) ; ++i2 ) {
1966 for ( size_type i3 = 0 ; i3 < output.extent(3) ; ++i3 ) {
1967 for ( size_type i4 = 0 ; i4 < output.extent(4) ; ++i4 ) {
1968 for ( size_type i5 = 0 ; i5 < output.extent(5) ; ++i5 ) {
1969 for ( size_type i6 = 0 ; i6 < output.extent(6) ; ++i6 ) {
1970 for ( size_type i7 = 0 ; i7 < output.extent(7) ; ++i7 ) {
1971 for ( size_type is = tidx ; is < npce ; is+=VectorLength ) {
1972 output.access(i0,i1,i2,i3,i4,i5,i6,i7).fastAccessCoeff(is) =
1981 typedef typename OutputView::array_type::value_type
scalar_type;
1982 const unsigned vector_length =
1986 const size_type block_size = 256;
1988 const size_type rows_per_block = block_size / vector_length;
1989 const size_type n =
output.extent(0);
1990 const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
1991 const size_type team_size = rows_per_block * vector_length;
1992 Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
1996 Kokkos::abort(
"StokhosViewFill: Invalid input value size");
1998 if (
input.size() == 1)
2000 config, ScalarKernel<vector_length>(
output,
input.fastAccessCoeff(0)) );
2002 parallel_for( config, PCEKernel<vector_length>(
output,
input) );
2009 typedef typename OutputView::array_type::value_type
scalar_type;
2010 const unsigned vector_length =
2014 const size_type block_size = 256;
2016 const size_type rows_per_block = block_size / vector_length;
2017 const size_type n =
output.extent(0);
2018 const size_type league_size = ( n + rows_per_block-1 ) / rows_per_block;
2019 const size_type team_size = rows_per_block * vector_length;
2020 Kokkos::TeamPolicy< execution_space > config( league_size, team_size );
2022 parallel_for( config, ScalarKernel<vector_length>(
output,
input) );
Kokkos::DefaultExecutionSpace execution_space
ViewMapping< DstTraits, typename DstTraits::specialize > DstType
Kokkos::Impl::SharedAllocationTracker TrackType
ViewMapping< SrcTraits, typename SrcTraits::specialize > SrcType
static KOKKOS_INLINE_FUNCTION void assign(DstType &dst, const SrcType &src, const TrackType &)
static KOKKOS_INLINE_FUNCTION void assign(DstType &dst, const SrcType &src, const TrackType &)
ViewMapping< SrcTraits, typename SrcTraits::specialize > SrcType
Kokkos::Impl::SharedAllocationTracker TrackType
ViewMapping< DstTraits, typename DstTraits::specialize > DstType
Kokkos::Impl::SharedAllocationTracker TrackType
ViewMapping< SrcTraits, typename SrcTraits::specialize > SrcType
static KOKKOS_INLINE_FUNCTION void assign(DstType &dst, const SrcType &src, const TrackType &)
ViewMapping< DstTraits, typename DstTraits::specialize > DstType
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
SharedAllocationRecord * allocate_shared(ViewCtorProp< P... > const &prop, typename Traits::array_layout const &layout, bool)
SharedAllocationRecord * allocate_shared(ViewCtorProp< P... > const &prop, typename Traits::array_layout const &layout)
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_3() const
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_0() const
sacado_uq_pce_type & reference_type
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_7() const
KOKKOS_FORCEINLINE_FUNCTION reference_type reference() const
handle_type m_impl_handle
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1, const I2 &i2) const
ViewOffset< typename Traits::dimension, typename Traits::array_layout, void > offset_type
offset_type m_impl_offset
KOKKOS_INLINE_FUNCTION void assign_data(pointer_type arg_ptr)
Assign data.
ViewOffset< typename array_dimension::template append< 0 >::type, typename Traits::array_layout, void > append_offset_type
ViewArrayAnalysis< typename Traits::data_type > array_analysis
KOKKOS_INLINE_FUNCTION constexpr size_t stride_3() const
stokhos_storage_type::value_type intrinsic_scalar_type
KOKKOS_INLINE_FUNCTION ViewMapping()
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_1() const
KOKKOS_INLINE_FUNCTION ViewMapping(ViewCtorProp< P ... > const &prop, typename Traits::array_layout const &layout)
KOKKOS_FORCEINLINE_FUNCTION void set_cijk(const cijk_type &cijk)
KOKKOS_DEFAULTED_FUNCTION ~ViewMapping()=default
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
KOKKOS_INLINE_FUNCTION bool is_data_contiguous() const
KOKKOS_FORCEINLINE_FUNCTION cijk_type cijk() const
KOKKOS_INLINE_FUNCTION constexpr size_t stride_5() const
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_5() const
KOKKOS_INLINE_FUNCTION constexpr bool span_is_contiguous() const
Is the mapped range span contiguous.
KOKKOS_INLINE_FUNCTION constexpr size_t extent(const iType &r) const
KOKKOS_INLINE_FUNCTION constexpr Traits::array_layout layout() 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 size_t dimension_2() const
ViewOffset< typename array_dimension::template prepend< 0 >::type, typename Traits::array_layout, void > prepend_offset_type
KOKKOS_DEFAULTED_FUNCTION ViewMapping(ViewMapping &&)=default
KOKKOS_INLINE_FUNCTION constexpr size_t span() const
Span of the mapped range : [ data() .. data() + span() )
Traits::value_type sacado_uq_pce_type
KOKKOS_INLINE_FUNCTION constexpr size_t stride_1() const
KOKKOS_DEFAULTED_FUNCTION ViewMapping(const ViewMapping &)=default
KOKKOS_INLINE_FUNCTION constexpr size_t stride_2() const
sacado_uq_pce_type * pointer_type
Pointer to underlying memory type.
KOKKOS_INLINE_FUNCTION constexpr pointer_type data() const
Raw data access.
Kokkos::Experimental::Impl::PCEAllocation< sacado_uq_pce_type > handle_type
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1) const
std::false_type is_regular
KOKKOS_INLINE_FUNCTION constexpr size_t stride_7() const
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_6() const
std::conditional< std::is_same< typenameTraits::array_layout, Kokkos::LayoutLeft >::value, prepend_offset_type, append_offset_type >::type array_offset_type
sacado_uq_pce_type::cijk_type cijk_type
sacado_uq_pce_type::storage_type stokhos_storage_type
KOKKOS_INLINE_FUNCTION constexpr size_t stride_6() const
KOKKOS_FORCEINLINE_FUNCTION std::enable_if< std::is_integral< I0 >::value &&!std::is_same< typenameTraits::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 I3 &i3, const I4 &i4) const
KOKKOS_FORCEINLINE_FUNCTION reference_type reference(const I0 &i0, const I1 &i1, const I2 &i2, const I3 &i3) const
KOKKOS_INLINE_FUNCTION constexpr size_t stride_4() const
KOKKOS_INLINE_FUNCTION constexpr size_t dimension_4() 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
KOKKOS_INLINE_FUNCTION void stride(iType *const s) const
KOKKOS_INLINE_FUNCTION bool is_allocation_contiguous() const
KOKKOS_FORCEINLINE_FUNCTION constexpr unsigned dimension_scalar() const
KOKKOS_FORCEINLINE_FUNCTION std::enable_if< std::is_integral< I0 >::value &&std::is_same< typenameTraits::array_layout, Kokkos::LayoutStride >::value, reference_type >::type reference(const I0 &i0) const
KOKKOS_INLINE_FUNCTION constexpr size_t stride_0() const
std::add_const< intrinsic_scalar_type >::type const_intrinsic_scalar_type
Sparse product tensor with replicated entries to provide subsets with a given coordinate.
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)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P... > >::value, unsigned >::type dimension_scalar(const View< T, P... > &view)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, bool >::type is_allocation_contiguous(const view_type &view)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, typenameCijkType< view_type >::type >::type cijk(const view_type &view)
KOKKOS_INLINE_FUNCTION std::enable_if<!Impl::ctor_prop_has_cijk< AllocProp >::value, CijkType >::type extract_cijk(const AllocProp &prop)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)
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)
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)
Top-level namespace for Stokhos classes and functions.
ViewType::non_const_value_type::cijk_type type
execution_space::size_type size_type
DeepCopyNonContiguous(const OutputView &arg_out, const InputView &arg_in)
KOKKOS_INLINE_FUNCTION void operator()(const size_type i0) const
OutputView::execution_space execution_space
PCEConstruct< ExecSpace > PCEFunctorType
ScalarFunctorType m_scalar_functor
PCEFunctorType m_pce_functor
void construct_shared_allocation()
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)
ConstructDestructFunctor & operator=(const ConstructDestructFunctor &)=default
ConstructDestructFunctor()=default
void destroy_shared_allocation()
Kokkos::Impl::ViewValueFunctor< ExecSpace, scalar_type > ScalarFunctorType
ConstructDestructFunctor(const ConstructDestructFunctor &)=default
KOKKOS_INLINE_FUNCTION void operator()(const size_t i) const
PCEConstruct(const PCEConstruct &)=default
PCEConstruct & operator=(const PCEConstruct &)=default
PCEConstruct(const ExecSpace &space, value_type *p, scalar_type *sp, const size_t span, const unsigned pce_size, const cijk_type &cijk)
static KOKKOS_INLINE_FUNCTION constexpr size_t memory_span(const size_t span, const unsigned pce_size)
Sacado::ValueType< value_type >::type scalar_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_INLINE_FUNCTION PCEAllocation()
KOKKOS_INLINE_FUNCTION void set(value_type *ptr, const size_t span, const unsigned pce_size)
value_type::cijk_type cijk_type
KOKKOS_INLINE_FUNCTION PCEAllocation & operator=(const PCEAllocation< T > &a)
Kokkos::Impl::ViewDataType< flat_value_type, dimension >::type flat_data_type
View< flat_data_type, P... > type
view_type::traits::dimension dimension
view_type::array_type::value_type flat_value_type
View< D, P... > view_type
OutputView::const_value_type const_value_type
OutputView::execution_space execution_space
StokhosViewFill(const OutputView &arg_out, const_value_type &arg_in)
ViewCtorProp(const type &arg)
ViewCtorProp(const ViewCtorProp &)=default
Stokhos::CrsProductTensor< Value, Execution, Memory > type
ViewDataType< non_const_scalar_type, scalar_dimension >::type non_const_scalar_array_type
array_analysis::dimension dimension
array_analysis::non_const_value_type non_const_value_type
StorageType::value_type ScalarType
ViewDataType< non_const_value_type, dimension >::type non_const_type
ViewDataType< value_type, dimension >::type type
std::conditional< is_const, constScalarType, ScalarType >::type scalar_type
ViewDataType< const_scalar_type, scalar_dimension >::type const_scalar_array_type
array_analysis::dimension::template append< 0 >::type append_scalar_dimension
ViewDataType< scalar_type, scalar_dimension >::type scalar_array_type
array_analysis::value_type value_type
ViewDataType< const_value_type, dimension >::type const_type
std::conditional< std::is_same< ArrayLayout, Kokkos::LayoutLeft >::value, prepend_scalar_dimension, append_scalar_dimension >::type scalar_dimension
ScalarType non_const_scalar_type
const ScalarType const_scalar_type
array_analysis::dimension::template prepend< 0 >::type prepend_scalar_dimension
ViewArrayAnalysis< DataType > array_analysis
array_analysis::const_value_type const_value_type
Kokkos::Experimental::Impl::ViewPCEContiguous specialize
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, typenamestd::conditional< rank==1, sacado_uq_pce_type *, typenamestd::conditional< rank==2, sacado_uq_pce_type **, typenamestd::conditional< rank==3, sacado_uq_pce_type ***, typenamestd::conditional< rank==4, sacado_uq_pce_type ****, typenamestd::conditional< rank==5, sacado_uq_pce_type *****, typenamestd::conditional< rank==6, sacado_uq_pce_type ******, sacado_uq_pce_type ******* >::type >::type >::type >::type >::type >::type >::type data_type
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::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::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< typenameSrcTraits::array_layout, Kokkos::LayoutLeft >::value)||(rank<=2 &&R0_rev &&std::is_same< typenameSrcTraits::array_layout, Kokkos::LayoutRight >::value)), typenameSrcTraits::array_layout, Kokkos::LayoutStride >::type array_layout
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
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 ... >::SrcTraits Kokkos::ViewTraits< DataType, P... > SrcTraits
View< T, P... > view_type