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__)
40 return static_cast<unsigned int>( ((length > 1) ? (static_cast<unsigned int>(length) << 2) : 0) + (reciprocal ? 2 : 0) + (flip_sign ? 1 : 0) );
45 cudaError_t error_code = cudaGetLastError();
47 if (cudaSuccess != error_code)
49 std::cerr << file <<
"(" << line <<
"): " <<
": getLastCudaError() CUDA error " << error_code <<
": " << cudaGetErrorString( error_code ) <<
" @ " << message << std::endl;
54 template<
typename ReturnT,
typename NumericT>
60 template<
typename ReturnT,
typename NumericT>
66 template<
typename NumericT>
72 template<
typename NumericT>
79 template<
typename ReturnT,
typename ArgT>
87 template<
typename ReturnT,
typename ArgT>
89 const ReturnT *>::type
95 template<
typename ReturnT>
98 return reinterpret_cast<ReturnT *
>(h.
get());
101 template<
typename ReturnT>
104 return reinterpret_cast<const ReturnT *
>(h.
get());
107 template<
typename NumericT>
119 inline unsigned int cuda_arg(
unsigned int val) {
return val; }
121 template<
typename NumericT>
char cuda_arg(
char val) {
return val; }
122 template<
typename NumericT>
unsigned char cuda_arg(
unsigned char val) {
return val; }
124 template<
typename NumericT>
short cuda_arg(
short val) {
return val; }
125 template<
typename NumericT>
unsigned short cuda_arg(
unsigned short val) {
return val; }
127 template<
typename NumericT>
int cuda_arg(
int val) {
return val; }
128 template<
typename NumericT>
unsigned int cuda_arg(
unsigned int val) {
return val; }
130 template<
typename NumericT>
long cuda_arg(
long val) {
return val; }
131 template<
typename NumericT>
unsigned long cuda_arg(
unsigned long val) {
return val; }
133 template<
typename NumericT>
float cuda_arg(
float val) {
return val; }
134 template<
typename NumericT>
double cuda_arg(
double val) {
return val; }
136 template<
typename NumericT,
typename OtherT>
139 template<
typename NumericT,
typename OtherT>
143 template<
typename ArgT>
148 template<
typename ArgT>
150 unsigned char const &>::type
153 template<
typename ArgT>
158 template<
typename ArgT>
160 unsigned short const &>::type
163 template<
typename ArgT>
168 template<
typename ArgT>
170 unsigned int const &>::type
173 template<
typename ArgT>
178 template<
typename ArgT>
180 unsigned long const &>::type
183 template<
typename ArgT>
188 template<
typename ArgT>
190 double const &>::type
Simple enable-if variant that uses the SFINAE pattern.
unsigned int make_options(vcl_size_t length, bool reciprocal, bool flip_sign)
This class represents a single scalar value on the GPU and behaves mostly like a built-in scalar type...
handle_type & handle()
Returns the memory handle, non-const version.
void cuda_last_error_check(const char *message, const char *file, const int line)
NumericT flip_sign(NumericT val)
ReturnT * cuda_arg(vector_base< NumericT > &obj)
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.
viennacl::backend::mem_handle::cuda_handle_type & arg_reference(viennacl::scalar< NumericT > &s, OtherT)