1 #ifndef VIENNACL_LINALG_OPENCL_SCALAR_OPERATIONS_HPP_
2 #define VIENNACL_LINALG_OPENCL_SCALAR_OPERATIONS_HPP_
48 template<
typename ScalarT1,
49 typename ScalarT2,
typename NumericT>
55 ScalarT2
const &
s2,
NumericT const & alpha,
vcl_size_t len_alpha,
bool reciprocal_alpha,
bool flip_sign_alpha)
57 assert( &viennacl::traits::opencl_handle(s1).
context() == &viennacl::traits::opencl_handle(s2).
context() &&
bool(
"Operands not in the same OpenCL context!"));
70 viennacl::traits::opencl_handle(viennacl::tools::promote_if_host_scalar<value_type>(alpha)),
72 viennacl::traits::opencl_handle(s2) )
77 template<
typename ScalarT1,
78 typename ScalarT2,
typename NumericT2,
79 typename ScalarT3,
typename NumericT3>
87 ScalarT2
const &
s2, NumericT2
const & alpha,
vcl_size_t len_alpha,
bool reciprocal_alpha,
bool flip_sign_alpha,
88 ScalarT3
const & s3, NumericT3
const & beta,
vcl_size_t len_beta,
bool reciprocal_beta,
bool flip_sign_beta)
90 assert( &viennacl::traits::opencl_handle(s1).
context() == &viennacl::traits::opencl_handle(s2).
context() &&
bool(
"Operands not in the same OpenCL context!"));
91 assert( &viennacl::traits::opencl_handle(s2).
context() == &viennacl::traits::opencl_handle(s3).
context() &&
bool(
"Operands not in the same OpenCL context!"));
97 std::string kernel_name;
100 if (is_cpu_2 && is_cpu_3)
101 kernel_name =
"asbs_cpu_cpu";
102 else if (is_cpu_2 && !is_cpu_3)
103 kernel_name =
"asbs_cpu_gpu";
104 else if (!is_cpu_2 && is_cpu_3)
105 kernel_name =
"asbs_gpu_cpu";
107 kernel_name =
"asbs_gpu_gpu";
116 viennacl::traits::opencl_handle(viennacl::tools::promote_if_host_scalar<value_type>(alpha)),
118 viennacl::traits::opencl_handle(s2),
119 viennacl::traits::opencl_handle(viennacl::tools::promote_if_host_scalar<value_type>(beta)),
121 viennacl::traits::opencl_handle(s3) )
126 template<
typename ScalarT1,
127 typename ScalarT2,
typename NumericT2,
128 typename ScalarT3,
typename NumericT3>
136 ScalarT2
const &
s2, NumericT2
const & alpha,
vcl_size_t len_alpha,
bool reciprocal_alpha,
bool flip_sign_alpha,
137 ScalarT3
const & s3, NumericT3
const & beta,
vcl_size_t len_beta,
bool reciprocal_beta,
bool flip_sign_beta)
139 assert( &viennacl::traits::opencl_handle(s1).
context() == &viennacl::traits::opencl_handle(s2).
context() &&
bool(
"Operands not in the same OpenCL context!"));
140 assert( &viennacl::traits::opencl_handle(s2).
context() == &viennacl::traits::opencl_handle(s3).
context() &&
bool(
"Operands not in the same OpenCL context!"));
146 std::string kernel_name;
148 kernel_name =
"asbs_s_cpu_cpu";
150 kernel_name =
"asbs_s_cpu_gpu";
152 kernel_name =
"asbs_s_gpu_cpu";
154 kernel_name =
"asbs_s_gpu_gpu";
163 viennacl::traits::opencl_handle(viennacl::tools::promote_if_host_scalar<value_type>(alpha)),
165 viennacl::traits::opencl_handle(s2),
166 viennacl::traits::opencl_handle(viennacl::tools::promote_if_host_scalar<value_type>(beta)),
168 viennacl::traits::opencl_handle(s3) )
178 template<
typename ScalarT1,
typename ScalarT2>
184 assert( &viennacl::traits::opencl_handle(s1).
context() == &viennacl::traits::opencl_handle(s2).
context() &&
bool(
"Operands not in the same OpenCL context!"));
194 viennacl::traits::opencl_handle(s2))
Simple enable-if variant that uses the SFINAE pattern.
Represents an OpenCL device within ViennaCL.
OpenCL kernel file for scalar operations.
Generic size and resize functionality for different vector and matrix types.
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.
Represents an OpenCL kernel within ViennaCL.
Extracts the underlying OpenCL start index handle from a vector, a matrix, an expression etc...
size_type local_work_size(int index=0) const
Returns the local work size at the respective dimension.
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
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
Common implementations shared by OpenCL-based operations.
Main kernel class for generating OpenCL kernels for operations involving viennacl::scalar<>, but not viennacl::vector<> or viennacl::matrix<>.
viennacl::enable_if< viennacl::is_scalar< ScalarT1 >::value &&viennacl::is_scalar< ScalarT2 >::value &&viennacl::is_scalar< ScalarT3 >::value &&viennacl::is_any_scalar< NumericT2 >::value &&viennacl::is_any_scalar< NumericT3 >::value >::type asbs_s(ScalarT1 &s1, ScalarT2 const &s2, NumericT2 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, ScalarT3 const &s3, NumericT3 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
Helper struct for checking whether a type is a host scalar type (e.g. float, double) ...
viennacl::ocl::kernel & get_kernel(std::string const &program_name, std::string const &kernel_name)
Convenience function for retrieving the kernel of a program directly from the context.
static void init(viennacl::ocl::context &ctx)
Helper struct for checking whether the provided type represents a scalar (either host, from ViennaCL, or a flip-sign proxy)
Implementation of a smart-pointer-like class for handling OpenCL handles.
cl_uint make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
T::ERROR_CANNOT_DEDUCE_CPU_SCALAR_TYPE_FOR_T type
viennacl::enable_if< viennacl::is_scalar< ScalarT1 >::value &&viennacl::is_scalar< ScalarT2 >::value &&viennacl::is_scalar< ScalarT3 >::value &&viennacl::is_any_scalar< NumericT2 >::value &&viennacl::is_any_scalar< NumericT3 >::value >::type asbs(ScalarT1 &s1, ScalarT2 const &s2, NumericT2 const &alpha, vcl_size_t len_alpha, bool reciprocal_alpha, bool flip_sign_alpha, ScalarT3 const &s3, NumericT3 const &beta, vcl_size_t len_beta, bool reciprocal_beta, bool flip_sign_beta)
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)
All the predicates used within ViennaCL. Checks for expressions to be vectors, etc.
Helper struct for checking whether a type is a viennacl::scalar<>
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
void enqueue(KernelType &k, viennacl::ocl::command_queue const &queue)
Enqueues a kernel in the provided queue.
Representation of an OpenCL kernel in ViennaCL.
size_type global_work_size(int index=0) const
Returns the global work size at the respective dimension.
Extracts the underlying OpenCL handle from a vector, a matrix, an expression etc. ...
A collection of compile time type deductions.
Simple enable-if variant that uses the SFINAE pattern.