1 #ifndef VIENNACL_LINALG_CUDA_SCALAR_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_CUDA_SCALAR_OPERATIONS_HPP_
35 #include <cuda_runtime.h>
47 template<
typename NumericT>
51 if (options2 & (1 << 0))
53 if (options2 & (1 << 1))
59 template<
typename NumericT>
63 if (options2 & (1 << 0))
65 if (options2 & (1 << 1))
71 template<
typename ScalarT1,
72 typename ScalarT2,
typename NumericT>
78 ScalarT2
const &
s2,
NumericT const & alpha,
vcl_size_t len_alpha,
bool reciprocal_alpha,
bool flip_sign_alpha)
84 value_type temporary_alpha = 0;
86 temporary_alpha = alpha;
98 template<
typename NumericT>
104 if (options2 & (1 << 0))
106 if (options2 & (1 << 1))
110 if (options3 & (1 << 0))
112 if (options3 & (1 << 1))
115 *s1 = *s2 * alpha + *s3 * beta;
119 template<
typename NumericT>
125 if (options2 & (1 << 0))
127 if (options2 & (1 << 1))
131 if (options3 & (1 << 0))
133 if (options3 & (1 << 1))
136 *s1 = *s2 * alpha + *s3 * beta;
140 template<
typename NumericT>
146 if (options2 & (1 << 0))
148 if (options2 & (1 << 1))
152 if (options3 & (1 << 0))
154 if (options3 & (1 << 1))
157 *s1 = *s2 * alpha + *s3 * beta;
161 template<
typename NumericT>
167 if (options2 & (1 << 0))
169 if (options2 & (1 << 1))
173 if (options3 & (1 << 0))
175 if (options3 & (1 << 1))
178 *s1 = *s2 * alpha + *s3 * beta;
182 template<
typename ScalarT1,
183 typename ScalarT2,
typename NumericT1,
184 typename ScalarT3,
typename NumericT2>
192 ScalarT2
const &
s2, NumericT1
const & alpha,
vcl_size_t len_alpha,
bool reciprocal_alpha,
bool flip_sign_alpha,
193 ScalarT3
const & s3, NumericT2
const & beta,
vcl_size_t len_beta,
bool reciprocal_beta,
bool flip_sign_beta)
197 unsigned int options_alpha =
detail::make_options(len_alpha, reciprocal_alpha, flip_sign_alpha);
200 value_type temporary_alpha = 0;
202 temporary_alpha = alpha;
204 value_type temporary_beta = 0;
206 temporary_beta = beta;
221 template<
typename NumericT>
227 if (options2 & (1 << 0))
229 if (options2 & (1 << 1))
233 if (options3 & (1 << 0))
235 if (options3 & (1 << 1))
238 *s1 += *s2 * alpha + *s3 * beta;
242 template<
typename NumericT>
248 if (options2 & (1 << 0))
250 if (options2 & (1 << 1))
254 if (options3 & (1 << 0))
256 if (options3 & (1 << 1))
259 *s1 += *s2 * alpha + *s3 * beta;
263 template<
typename NumericT>
269 if (options2 & (1 << 0))
271 if (options2 & (1 << 1))
275 if (options3 & (1 << 0))
277 if (options3 & (1 << 1))
280 *s1 += *s2 * alpha + *s3 * beta;
284 template<
typename NumericT>
290 if (options2 & (1 << 0))
292 if (options2 & (1 << 1))
296 if (options3 & (1 << 0))
298 if (options3 & (1 << 1))
301 *s1 += *s2 * alpha + *s3 * beta;
305 template<
typename ScalarT1,
306 typename ScalarT2,
typename NumericT1,
307 typename ScalarT3,
typename NumericT2>
315 ScalarT2
const &
s2, NumericT1
const & alpha,
vcl_size_t len_alpha,
bool reciprocal_alpha,
bool flip_sign_alpha,
316 ScalarT3
const & s3, NumericT2
const & beta,
vcl_size_t len_beta,
bool reciprocal_beta,
bool flip_sign_beta)
320 unsigned int options_alpha =
detail::make_options(len_alpha, reciprocal_alpha, flip_sign_alpha);
323 value_type temporary_alpha = 0;
325 temporary_alpha = alpha;
327 value_type temporary_beta = 0;
329 temporary_beta = beta;
331 std::cout <<
"Launching asbs_s_kernel..." << std::endl;
344 template<
typename NumericT>
357 template<
typename ScalarT1,
typename ScalarT2>
Simple enable-if variant that uses the SFINAE pattern.
unsigned int make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
Generic size and resize functionality for different vector and matrix types.
Extracts the underlying OpenCL start index handle from a vector, a matrix, an expression etc...
This file provides the forward declarations for the main types used within ViennaCL.
Determines row and column increments for matrices and matrix proxies.
viennacl::scalar< int > s2
viennacl::scalar< float > s1
viennacl::enable_if< viennacl::is_scalar< ScalarT1 >::value &&viennacl::is_scalar< ScalarT2 >::value &&viennacl::is_scalar< ScalarT3 >::value &&viennacl::is_any_scalar< NumericT1 >::value &&viennacl::is_any_scalar< NumericT2 >::value >::type asbs(ScalarT1 &s1, ScalarT2 const &s2, NumericT1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, ScalarT3 const &s3, NumericT2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
__global__ void as_kernel(NumericT *s1, const NumericT *fac2, unsigned int options2, const NumericT *s2)
Helper struct for checking whether a type is a host scalar type (e.g. float, double) ...
Helper struct for checking whether the provided type represents a scalar (either host, from ViennaCL, or a flip-sign proxy)
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
viennacl::enable_if< viennacl::is_scalar< ScalarT1 >::value &&viennacl::is_scalar< ScalarT2 >::value >::type swap(ScalarT1 &s1, ScalarT2 &s2)
Swaps the contents of two scalars, data is copied.
viennacl::enable_if< viennacl::is_scalar< ScalarT1 >::value &&viennacl::is_scalar< ScalarT2 >::value &&viennacl::is_scalar< ScalarT3 >::value &&viennacl::is_any_scalar< NumericT1 >::value &&viennacl::is_any_scalar< NumericT2 >::value >::type asbs_s(ScalarT1 &s1, ScalarT2 const &s2, NumericT1 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, ScalarT3 const &s3, NumericT2 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
All the predicates used within ViennaCL. Checks for expressions to be vectors, etc.
Helper struct for checking whether a type is a viennacl::scalar<>
Common routines for CUDA execution.
viennacl::enable_if< viennacl::is_scalar< ScalarT1 >::value &&viennacl::is_scalar< ScalarT2 >::value &&viennacl::is_any_scalar< NumericT >::value >::type as(ScalarT1 &s1, ScalarT2 const &s2, NumericT const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha)
__global__ void scalar_swap_kernel(NumericT *s1, NumericT *s2)
__global__ void asbs_kernel(NumericT *s1, const NumericT *fac2, unsigned int options2, const NumericT *s2, const NumericT *fac3, unsigned int options3, const NumericT *s3)
#define VIENNACL_CUDA_LAST_ERROR_CHECK(message)
NumericT * cuda_arg(scalar< NumericT > &obj)
Convenience helper function for extracting the CUDA handle from a ViennaCL scalar. Non-const version.
__global__ void asbs_s_kernel(NumericT *s1, const NumericT *fac2, unsigned int options2, const NumericT *s2, const NumericT *fac3, unsigned int options3, const NumericT *s3)
viennacl::backend::mem_handle::cuda_handle_type & arg_reference(viennacl::scalar< NumericT > &s, OtherT)
Simple enable-if variant that uses the SFINAE pattern.