1 #ifndef VIENNACL_LINALG_CUDA_COMMON_HPP_
2 #define VIENNACL_LINALG_CUDA_COMMON_HPP_
27 #define VIENNACL_CUDA_LAST_ERROR_CHECK(message) detail::cuda_last_error_check (message, __FILE__, __LINE__)
39 return static_cast<unsigned int>( ((length > 1) ? (static_cast<unsigned int>(length) << 2) : 0) + (reciprocal ? 2 : 0) + (flip_sign ? 1 : 0) );
44 cudaError_t error_code = cudaGetLastError();
46 if(cudaSuccess != error_code)
48 std::cerr << file <<
"(" << line <<
"): " <<
": getLastCudaError() CUDA error " << error_code <<
": " << cudaGetErrorString( error_code ) <<
" @ " << message << std::endl;
53 template <
typename T,
typename U>
59 template <
typename T,
typename U>
65 template <
typename NumericT,
typename F>
71 template <
typename NumericT,
typename F>
78 template <
typename ScalarType,
typename T>
86 template <
typename ScalarType,
typename T>
88 const ScalarType *>::type
94 template <
typename ScalarType>
97 return reinterpret_cast<ScalarType *
>(h.
get());
100 template <
typename ScalarType>
103 return reinterpret_cast<const ScalarType *
>(h.
get());
109 inline unsigned int cuda_arg(
unsigned int val) {
return val; }
111 template <
typename T>
char cuda_arg(
char val) {
return val; }
112 template <
typename T>
unsigned char cuda_arg(
unsigned char val) {
return val; }
114 template <
typename T>
short cuda_arg(
short val) {
return val; }
115 template <
typename T>
unsigned short cuda_arg(
unsigned short val) {
return val; }
117 template <
typename T>
int cuda_arg(
int val) {
return val; }
118 template <
typename T>
unsigned int cuda_arg(
unsigned int val) {
return val; }
120 template <
typename T>
long cuda_arg(
long val) {
return val; }
121 template <
typename T>
unsigned long cuda_arg(
unsigned long val) {
return val; }
123 template <
typename T>
float cuda_arg(
float val) {
return val; }
124 template <
typename T>
double cuda_arg(
double val) {
return val; }
126 template <
typename T,
typename U>
129 template <
typename T,
typename U>
133 template <
typename T>
138 template <
typename T>
140 unsigned char const &>::type
143 template <
typename T>
148 template <
typename T>
150 unsigned short const &>::type
153 template <
typename T>
158 template <
typename T>
160 unsigned int const &>::type
163 template <
typename T>
168 template <
typename T>
170 unsigned long const &>::type
173 template <
typename T>
178 template <
typename T>
180 double const &>::type
Simple enable-if variant that uses the SFINAE pattern.
Definition: enable_if.hpp:29
std::size_t vcl_size_t
Definition: forwards.h:58
unsigned int make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
Definition: common.hpp:37
viennacl::backend::mem_handle::cuda_handle_type & arg_reference(viennacl::scalar< T > &s, U)
Definition: common.hpp:127
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
Definition: forwards.h:172
Common base class for dense vectors, vector ranges, and vector slices.
Definition: forwards.h:205
void cuda_last_error_check(const char *message, const char *file, const int line)
Definition: common.hpp:42
A dense matrix class.
Definition: forwards.h:290
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
NumericT flip_sign(NumericT val)
Definition: vector_operations.hpp:54
handle_type & handle()
Returns the memory handle, non-const version.
Definition: scalar.hpp:704
T * cuda_arg(vector_base< U > &obj)
Definition: common.hpp:54
Extracts the underlying OpenCL handle from a vector, a matrix, an expression etc. ...
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version.
Definition: handle.hpp:41