10 #ifndef KOKKOS_BLAS1_MP_VECTOR_HPP
11 #define KOKKOS_BLAS1_MP_VECTOR_HPP
13 #include "Sacado_ConfigDefs.h"
18 #include "KokkosBlas.hpp"
24 namespace KokkosBlas {
26 #if defined(HAVE_STOKHOS_ENSEMBLE_REDUCT)
28 template <
typename XD,
typename ... XP,
29 typename YD,
typename ... YP>
30 typename std::enable_if<
33 typename Kokkos::Details::InnerProductSpaceTraits<
34 typename Kokkos::View<XD,XP...>::non_const_value_type >::dot_type
36 dot(
const Kokkos::View<XD,XP...>& x,
37 const Kokkos::View<YD,YP...>& y)
39 typedef Kokkos::View<XD,XP...> XVector;
40 typedef Kokkos::View<YD,YP...> YVector;
45 return dot( x_flat, y_flat );
48 template <
typename RV,
49 typename XD,
typename ... XP,
50 typename YD,
typename ... YP>
51 typename std::enable_if<
55 const Kokkos::View<XD,XP...>& x,
56 const Kokkos::View<YD,YP...>& y)
58 typedef Kokkos::View<XD,XP...> XVector;
59 typedef Kokkos::View<YD,YP...> YVector;
64 dot( r, x_flat, y_flat );
67 template <
typename XD,
typename ... XP>
68 typename std::enable_if<
70 fill(
const Kokkos::View<XD,XP...>& x,
71 const typename Kokkos::View<XD,XP...>::non_const_value_type&
val) {
72 typedef Kokkos::View<XD,XP...> XVector;
77 fill( x_flat, val.coeff(0) );
84 template <
typename RV,
85 typename XD,
typename ... XP>
86 typename std::enable_if<
90 const Kokkos::View<XD,XP...>& x)
92 typedef Kokkos::View<XD,XP...> XVector;
99 template <
typename RV,
100 typename XD,
typename ... XP>
101 typename std::enable_if<
105 const Kokkos::View<XD,XP...>& x)
107 typedef Kokkos::View<XD,XP...> XVector;
114 template <
typename RV,
115 typename XD,
typename ... XP>
116 typename std::enable_if<
120 const Kokkos::View<XD,XP...>& x)
122 typedef Kokkos::View<XD,XP...> XVector;
129 template <
typename AV,
130 typename XD,
typename ... XP,
132 typename YD,
typename ... YP>
133 typename std::enable_if<
137 const Kokkos::View<XD,XP...>& x,
139 const Kokkos::View<YD,YP...>& y)
141 typedef Kokkos::View<XD,XP...> XVector;
142 typedef Kokkos::View<YD,YP...> YVector;
150 auto aa = Sacado::Value<AV>::eval(a);
151 auto bb = Sacado::Value<BV>::eval(b);
152 axpby( aa, x_flat, bb, y_flat );
157 template <
typename RD,
typename ... RP,
158 typename XD,
typename ... XP>
159 typename std::enable_if<
162 scal(
const Kokkos::View<RD,RP...>& r,
163 const typename Kokkos::View<XD,XP...>::non_const_value_type& a,
164 const Kokkos::View<XD,XP...>& x)
166 typedef Kokkos::View<RD,RP...> RVector;
167 typedef Kokkos::View<XD,XP...> XVector;
175 scal( r_flat, a.coeff(0), x_flat );
183 template <
typename XD,
typename ... XP,
184 typename YD,
typename ... YP,
185 typename ZD,
typename ... ZP>
186 typename std::enable_if<
191 const typename Kokkos::View<XD,XP...>::array_type::non_const_value_type& alpha,
192 const Kokkos::View<XD,XP...>& x,
193 const typename Kokkos::View<YD,YP...>::array_type::non_const_value_type& beta,
194 const Kokkos::View<YD,YP...>& y,
195 const typename Kokkos::View<ZD,ZP...>::array_type::non_const_value_type& gamma,
196 const Kokkos::View<ZD,ZP...>& z)
198 typedef Kokkos::View<XD,XP...> XVector;
199 typedef Kokkos::View<YD,YP...> YVector;
200 typedef Kokkos::View<ZD,ZP...> ZVector;
206 update( alpha, x_flat, beta, y_flat, gamma, z_flat);
210 template <
typename XD,
typename ... XP,
211 typename YD,
typename ... YP,
212 typename ZD,
typename ... ZP>
213 typename std::enable_if<
218 const typename Kokkos::View<XD,XP...>::non_const_value_type& alpha,
219 const Kokkos::View<XD,XP...>& x,
220 const typename Kokkos::View<YD,YP...>::non_const_value_type& beta,
221 const Kokkos::View<YD,YP...>& y,
222 const typename Kokkos::View<ZD,ZP...>::non_const_value_type& gamma,
223 const Kokkos::View<ZD,ZP...>& z)
228 "update not implemented for non-constant alpha, beta, gamma");
231 update( alpha.coeff(0), x, beta.coeff(0), y, gamma.coeff(0), z );
234 template <
typename RD,
typename ... RP,
235 typename XD,
typename ... XP>
236 typename std::enable_if<
240 const Kokkos::View<RD,RP...>& r,
241 const Kokkos::View<XD,XP...>& x)
243 typedef Kokkos::View<RD,RP...> RVector;
244 typedef Kokkos::View<XD,XP...> XVector;
248 reciprocal( r_flat, x_flat );
251 template <
typename RD,
typename ... RP,
252 typename XD,
typename ... XP>
253 typename std::enable_if<
257 const Kokkos::View<RD,RP...>& r,
258 const Kokkos::View<XD,XP...>& x)
260 typedef Kokkos::View<RD,RP...> RVector;
261 typedef Kokkos::View<XD,XP...> XVector;
265 sum( r_flat, x_flat );
268 template <
typename RD,
typename ... RP,
269 typename XD,
typename ... XP,
270 typename WD,
typename ... WP>
271 typename std::enable_if<
276 const Kokkos::View<RD,RP...>& r,
277 const Kokkos::View<XD,XP...>& x,
278 const Kokkos::View<WD,WP...>& w)
280 typedef Kokkos::View<RD,RP...> RVector;
281 typedef Kokkos::View<XD,XP...> XVector;
282 typedef Kokkos::View<WD,WP...> WVector;
290 template <
typename CD,
typename ... CP,
291 typename AD,
typename ... AP,
292 typename BD,
typename ... BP>
293 typename std::enable_if<
298 const typename Kokkos::View<CD,CP...>::const_value_type& c,
299 const Kokkos::View<CD,CP...>&
C,
300 const typename Kokkos::View<AD,AP...>::const_value_type& ab,
301 const Kokkos::View<AD,AP...>&
A,
302 const Kokkos::View<BD,BP...>&
B)
308 typedef Kokkos::View<CD,CP...> CVector;
309 typedef Kokkos::View<AD,AP...> AVector;
310 typedef Kokkos::View<BD,BP...> BVector;
315 mult( c.coeff(0), C_flat, ab.coeff(0), A_flat, B_flat );
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_INLINE_FUNCTION void raise_error(const char *msg)
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)
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)
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)
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
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)
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)
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)