10 #ifndef KOKKOS_BLAS1_UQ_PCE_HPP
11 #define KOKKOS_BLAS1_UQ_PCE_HPP
16 #include "KokkosBlas.hpp"
22 namespace KokkosBlas {
24 template <
typename XD,
typename ... XP,
25 typename YD,
typename ... YP>
26 typename std::enable_if<
29 typename Kokkos::Details::InnerProductSpaceTraits<
30 typename Kokkos::View<XD,XP...>::non_const_value_type >::dot_type
32 dot(
const Kokkos::View<XD,XP...>& x,
33 const Kokkos::View<YD,YP...>& y)
35 typedef Kokkos::View<XD,XP...> XVector;
36 typedef Kokkos::View<YD,YP...> YVector;
41 return dot( x_flat, y_flat );
44 template <
typename RV,
45 typename XD,
typename ... XP,
46 typename YD,
typename ... YP>
47 typename std::enable_if<
51 const Kokkos::View<XD,XP...>& x,
52 const Kokkos::View<YD,YP...>& y)
54 typedef Kokkos::View<XD,XP...> XVector;
55 typedef Kokkos::View<YD,YP...> YVector;
60 dot( r, x_flat, y_flat );
63 template <
typename XD,
typename ... XP>
64 typename std::enable_if<
66 fill(
const Kokkos::View<XD,XP...>& x,
67 const typename Kokkos::View<XD,XP...>::non_const_value_type&
val) {
68 typedef Kokkos::View<XD,XP...> XVector;
73 fill( x_flat, val.coeff(0) );
80 template <
typename RV,
81 typename XD,
typename ... XP>
82 typename std::enable_if<
86 const Kokkos::View<XD,XP...>& x)
88 typedef Kokkos::View<XD,XP...> XVector;
95 template <
typename RV,
96 typename XD,
typename ... XP>
97 typename std::enable_if<
101 const Kokkos::View<XD,XP...>& x)
103 typedef Kokkos::View<XD,XP...> XVector;
110 template <
typename RV,
111 typename XD,
typename ... XP>
112 typename std::enable_if<
116 const Kokkos::View<XD,XP...>& x)
118 typedef Kokkos::View<XD,XP...> XVector;
125 template <
typename AV,
126 typename XD,
typename ... XP,
128 typename YD,
typename ... YP>
129 typename std::enable_if<
133 const Kokkos::View<XD,XP...>& x,
135 const Kokkos::View<YD,YP...>& y)
137 typedef Kokkos::View<XD,XP...> XVector;
138 typedef Kokkos::View<YD,YP...> YVector;
146 auto aa = Sacado::Value<AV>::eval(a);
147 auto bb = Sacado::Value<BV>::eval(b);
148 axpby( aa, x_flat, bb, y_flat );
153 template <
typename RD,
typename ... RP,
154 typename XD,
typename ... XP>
155 typename std::enable_if<
158 scal(
const Kokkos::View<RD,RP...>& r,
159 const typename Kokkos::View<XD,XP...>::non_const_value_type& a,
160 const Kokkos::View<XD,XP...>& x)
162 typedef Kokkos::View<RD,RP...> RVector;
163 typedef Kokkos::View<XD,XP...> XVector;
171 scal( r_flat, a.coeff(0), x_flat );
179 template <
typename XD,
typename ... XP,
180 typename YD,
typename ... YP,
181 typename ZD,
typename ... ZP>
182 typename std::enable_if<
187 const typename Kokkos::View<XD,XP...>::array_type::non_const_value_type& alpha,
188 const Kokkos::View<XD,XP...>& x,
189 const typename Kokkos::View<YD,YP...>::array_type::non_const_value_type& beta,
190 const Kokkos::View<YD,YP...>& y,
191 const typename Kokkos::View<ZD,ZP...>::array_type::non_const_value_type& gamma,
192 const Kokkos::View<ZD,ZP...>& z)
194 typedef Kokkos::View<XD,XP...> XVector;
195 typedef Kokkos::View<YD,YP...> YVector;
196 typedef Kokkos::View<ZD,ZP...> ZVector;
202 update( alpha, x_flat, beta, y_flat, gamma, z_flat);
206 template <
typename XD,
typename ... XP,
207 typename YD,
typename ... YP,
208 typename ZD,
typename ... ZP>
209 typename std::enable_if<
214 const typename Kokkos::View<XD,XP...>::non_const_value_type& alpha,
215 const Kokkos::View<XD,XP...>& x,
216 const typename Kokkos::View<YD,YP...>::non_const_value_type& beta,
217 const Kokkos::View<YD,YP...>& y,
218 const typename Kokkos::View<ZD,ZP...>::non_const_value_type& gamma,
219 const Kokkos::View<ZD,ZP...>& z)
224 "update not implemented for non-constant alpha, beta, gamma");
227 update( alpha.coeff(0), x, beta.coeff(0), y, gamma.coeff(0), z );
233 template<
class RS,
class ... RP,
234 class XS,
class ... XP,
236 struct MV_Reciprocal_Functor<
237 Kokkos::
View<Sacado::UQ::PCE<RS>**,RP...>,
238 Kokkos::View<const Sacado::UQ::PCE<XS>**,XP...>,
241 typedef Kokkos::View<Sacado::UQ::PCE<RS>**,RP...>
RMV;
242 typedef Kokkos::View<const Sacado::UQ::PCE<XS>**,XP...>
XMV;
245 #if KOKKOS_VERSION >= 40799
246 typedef KokkosKernels::ArithTraits<typename Kokkos::IntrinsicScalarType<XMV>::type>
ATS;
248 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<XMV>::type>
ATS;
256 numCols (X.extent(1)), R_ (R), X_ (X)
260 KOKKOS_INLINE_FUNCTION
263 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
267 R_(i,
j) = ATS::one () / X_(i,
j).fastAccessCoeff(0);
272 template<
class RS,
class ... RP,
274 struct MV_ReciprocalSelf_Functor<
275 Kokkos::
View<Sacado::UQ::PCE<RS>**,RP...>,
278 typedef Kokkos::View<Sacado::UQ::PCE<RS>**,RP...>
RMV;
281 #if KOKKOS_VERSION >= 40799
282 typedef KokkosKernels::ArithTraits<typename Kokkos::IntrinsicScalarType<RMV>::type>
ATS;
284 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<RMV>::type>
ATS;
291 numCols (R.extent(1)), R_ (R)
295 KOKKOS_INLINE_FUNCTION
298 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
302 R_(i,
j) = ATS::one () / R_(i,
j).fastAccessCoeff(0);
307 template<
class RS,
class ... RP,
308 class XS,
class ... XP,
310 struct V_Reciprocal_Functor<
311 Kokkos::
View<Sacado::UQ::PCE<RS>*,RP...>,
312 Kokkos::View<const Sacado::UQ::PCE<XS>*,XP...>,
315 typedef Kokkos::View<Sacado::UQ::PCE<RS>*,RP...>
RV;
316 typedef Kokkos::View<const Sacado::UQ::PCE<XS>*,XP...>
XV;
319 #if KOKKOS_VERSION >= 40799
320 typedef KokkosKernels::ArithTraits<typename Kokkos::IntrinsicScalarType<XV>::type>
ATS;
322 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<XV>::type>
ATS;
332 KOKKOS_INLINE_FUNCTION
335 R_(i) = ATS::one () / X_(i).fastAccessCoeff(0);
339 template<
class RS,
class ... RP,
341 struct V_ReciprocalSelf_Functor<
342 Kokkos::
View<Sacado::UQ::PCE<RS>*,RP...>,
345 typedef Kokkos::View<Sacado::UQ::PCE<RS>*,RP...>
RV;
348 #if KOKKOS_VERSION >= 40799
349 typedef KokkosKernels::ArithTraits<typename Kokkos::IntrinsicScalarType<RV>::type>
ATS;
351 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<RV>::type>
ATS;
360 KOKKOS_INLINE_FUNCTION
363 R_(i) = ATS::one () / R_(i).fastAccessCoeff(0);
369 template <
typename RD,
typename ... RP,
370 typename XD,
typename ... XP>
371 typename std::enable_if<
375 const Kokkos::View<RD,RP...>& r,
376 const Kokkos::View<XD,XP...>& x)
378 typedef Kokkos::View<RD,RP...> RVector;
379 typedef Kokkos::View<XD,XP...> XVector;
383 sum( r_flat, x_flat );
386 template <
typename RD,
typename ... RP,
387 typename XD,
typename ... XP,
388 typename WD,
typename ... WP>
389 typename std::enable_if<
394 const Kokkos::View<RD,RP...>& r,
395 const Kokkos::View<XD,XP...>& x,
396 const Kokkos::View<WD,WP...>& w)
398 typedef Kokkos::View<RD,RP...> RVector;
399 typedef Kokkos::View<XD,XP...> XVector;
400 typedef Kokkos::View<WD,WP...> WVector;
411 template<
class CS,
class ... CP,
412 class AS,
class ... AP,
413 class BS,
class ... BP,
414 int scalar_ab,
int scalar_c,
class SizeType>
415 struct MV_MultFunctor<
416 Kokkos::
View<Sacado::UQ::PCE<CS>**,CP...>,
417 Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>,
418 Kokkos::View<const Sacado::UQ::PCE<BS>**,BP...>,
419 scalar_ab, scalar_c, SizeType>
421 typedef Kokkos::View<Sacado::UQ::PCE<CS>**,CP...>
CMV;
422 typedef Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>
AV;
423 typedef Kokkos::View<const Sacado::UQ::PCE<BS>**,BP...>
BMV;
426 #if KOKKOS_VERSION >= 40799
427 typedef KokkosKernels::ArithTraits<typename Kokkos::IntrinsicScalarType<CMV>::type>
ATS;
429 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<CMV>::type>
ATS;
442 typename AV::const_value_type& ab,
447 m_c (c.coeff(0)), m_C (C), m_ab (ab.coeff(0)), m_A (A), m_B (B)
454 KOKKOS_INLINE_FUNCTION
void
458 if (scalar_ab == 0) {
460 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
464 m_C(i,
j).fastAccessCoeff(l) = ATS::zero ();
470 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
474 m_C(i,
j).fastAccessCoeff(l) =
475 m_ab * Ai * m_B(i,
j).fastAccessCoeff(l);
479 if (scalar_ab == 0) {
481 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
485 m_C(i,
j).fastAccessCoeff(l) = m_c * m_C(i,
j).fastAccessCoeff(l);
491 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
495 m_C(i,
j).fastAccessCoeff(l) =
496 m_c * m_C(i,
j).fastAccessCoeff(l) + m_ab * Ai * m_B(i,
j).fastAccessCoeff(l);
503 template<
class CS,
class ... CP,
504 class AS,
class ... AP,
505 class BS,
class ... BP,
506 int scalar_ab,
int scalar_c,
class SizeType>
507 struct V_MultFunctor<
508 Kokkos::
View<Sacado::UQ::PCE<CS>*,CP...>,
509 Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>,
510 Kokkos::View<const Sacado::UQ::PCE<BS>*,BP...>,
511 scalar_ab, scalar_c, SizeType>
513 typedef Kokkos::View<Sacado::UQ::PCE<CS>*,CP...>
CV;
514 typedef Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>
AV;
515 typedef Kokkos::View<const Sacado::UQ::PCE<BS>*,BP...>
BV;
518 #if KOKKOS_VERSION >= 40799
519 typedef KokkosKernels::ArithTraits<typename Kokkos::IntrinsicScalarType<CV>::type>
ATS;
521 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<CV>::type>
ATS;
533 typename AV::const_value_type& ab,
537 m_c (c.coeff(0)), m_C (C), m_ab (ab.coeff(0)), m_A (A), m_B (B)
544 KOKKOS_INLINE_FUNCTION
void
548 if (scalar_ab == 0) {
549 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
553 m_C(i).fastAccessCoeff(l) = ATS::zero ();
557 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
561 m_C(i).fastAccessCoeff(l) = m_ab * Ai * m_B(i).fastAccessCoeff(l);
564 if (scalar_ab == 0) {
565 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
569 m_C(i).fastAccessCoeff(l) = m_c * m_C(i).fastAccessCoeff(l);
573 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
577 m_C(i).fastAccessCoeff(l) =
578 m_c * m_C(i).fastAccessCoeff(l) + m_ab * Ai * m_B(i).fastAccessCoeff(l);
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< RMV >::type > ATS
RV::execution_space execution_space
Kokkos::View< const Sacado::UQ::PCE< BS > *, BP...> BV
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< XMV >::type > ATS
Kokkos::View< Sacado::UQ::PCE< RS > **, RP...> RMV
const Kokkos::IntrinsicScalarType< CMV >::type m_c
Kokkos::View< Sacado::UQ::PCE< CS > **, CP...> CMV
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< RV >::type > ATS
Kokkos::DefaultExecutionSpace execution_space
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< CMV >::type > ATS
Kokkos::View< const Sacado::UQ::PCE< BS > **, BP...> BMV
Kokkos::View< const Sacado::UQ::PCE< AS > *, AP...> AV
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type fill(const Kokkos::View< XD, XP...> &x, const typename Kokkos::View< XD, XP...>::non_const_value_type &val)
Kokkos::View< const Sacado::UQ::PCE< XS > *, XP...> XV
KOKKOS_INLINE_FUNCTION void raise_error(const char *msg)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
RV::execution_space execution_space
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< YD, YP...> >::value, typename Kokkos::Details::InnerProductSpaceTraits< typename Kokkos::View< XD, XP...>::non_const_value_type >::dot_type >::type dot(const Kokkos::View< XD, XP...> &x, const Kokkos::View< YD, YP...> &y)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type nrm1(const RV &r, const Kokkos::View< XD, XP...> &x)
RMV::execution_space execution_space
const Kokkos::IntrinsicScalarType< AV >::type m_ab
CMV::execution_space execution_space
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< RD, RP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< WD, WP...> >::value >::type nrm2w_squared(const Kokkos::View< RD, RP...> &r, const Kokkos::View< XD, XP...> &x, const Kokkos::View< WD, WP...> &w)
V_ReciprocalSelf_Functor(const RV &R)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type nrm2_squared(const RV &r, const Kokkos::View< XD, XP...> &x)
V_Reciprocal_Functor(const RV &R, const XV &X)
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
MV_Reciprocal_Functor(const RMV &R, const XMV &X)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
MV_MultFunctor(typename CMV::const_value_type &c, const CMV &C, typename AV::const_value_type &ab, const AV &A, const BMV &B)
Kokkos::View< Sacado::UQ::PCE< RS > *, RP...> RV
RMV::execution_space execution_space
view_type::array_type::non_const_value_type type
Kokkos::View< Sacado::UQ::PCE< RS > **, RP...> RMV
CV::execution_space execution_space
Kokkos::View< Sacado::UQ::PCE< CS > *, CP...> CV
MV_ReciprocalSelf_Functor(const RMV &R)
Kokkos::View< Sacado::UQ::PCE< RS > *, RP...> RV
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< YD, YP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< ZD, ZP...> >::value >::type update(const typename Kokkos::View< XD, XP...>::array_type::non_const_value_type &alpha, const Kokkos::View< XD, XP...> &x, const typename Kokkos::View< YD, YP...>::array_type::non_const_value_type &beta, const Kokkos::View< YD, YP...> &y, const typename Kokkos::View< ZD, ZP...>::array_type::non_const_value_type &gamma, const Kokkos::View< ZD, ZP...> &z)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type nrmInf(const RV &r, const Kokkos::View< XD, XP...> &x)
const Kokkos::IntrinsicScalarType< AV >::type m_ab
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< YD, YP...> >::value >::type axpby(const AV &a, const Kokkos::View< XD, XP...> &x, const BV &b, const Kokkos::View< YD, YP...> &y)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< RD, RP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type scal(const Kokkos::View< RD, RP...> &r, const typename Kokkos::View< XD, XP...>::non_const_value_type &a, const Kokkos::View< XD, XP...> &x)
Kokkos::View< const Sacado::UQ::PCE< AS > *, AP...> AV
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< XV >::type > ATS
const Kokkos::IntrinsicScalarType< CV >::type m_c
V_MultFunctor(typename CV::const_value_type &c, const CV &C, typename AV::const_value_type &ab, const AV &A, const BV &B)
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< CV >::type > ATS
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< RD, RP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type sum(const Kokkos::View< RD, RP...> &r, const Kokkos::View< XD, XP...> &x)
Kokkos::View< const Sacado::UQ::PCE< XS > **, XP...> XMV