1 #ifndef VIENNACL_LINALG_CUDA_COMMON_HPP_ 
    2 #define VIENNACL_LINALG_CUDA_COMMON_HPP_ 
   26 #include <cuda_runtime.h> 
   30 #define VIENNACL_CUDA_LAST_ERROR_CHECK(message)  detail::cuda_last_error_check (message, __FILE__, __LINE__) 
   38 template<
typename NumericT>
 
   45 template<
typename NumericT>
 
   55 template<
typename NumericT>
 
   62 template<
typename NumericT>
 
   69 template<
typename ReturnT, 
typename NumericT>
 
   76 template<
typename ReturnT, 
typename NumericT>
 
   86 template<
typename NumericT>
 
   93 template<
typename NumericT>
 
  105 template<
typename ReturnT>
 
  108   return reinterpret_cast<ReturnT *
>(h.cuda_handle().get());
 
  112 template<
typename ReturnT>
 
  115   return reinterpret_cast<const ReturnT *
>(h.cuda_handle().get());
 
  119 template<
typename ReturnT>
 
  122   return reinterpret_cast<ReturnT *
>(h.
get());
 
  125 template<
typename ReturnT>
 
  128   return reinterpret_cast<const ReturnT *
>(h.
get());
 
  131 inline unsigned int cuda_arg(
unsigned int val)  { 
return val; }
 
  133 template<
typename NumericT> 
char           cuda_arg(
char val)           { 
return val; }
 
  134 template<
typename NumericT> 
unsigned char  cuda_arg(
unsigned char val)  { 
return val; }
 
  136 template<
typename NumericT> 
short          cuda_arg(
short val)          { 
return val; }
 
  137 template<
typename NumericT> 
unsigned short cuda_arg(
unsigned short val) { 
return val; }
 
  139 template<
typename NumericT> 
int            cuda_arg(
int val)            { 
return val; }
 
  140 template<
typename NumericT> 
unsigned int   cuda_arg(
unsigned int val)   { 
return val; }
 
  142 template<
typename NumericT> 
long           cuda_arg(
long val)           { 
return val; }
 
  143 template<
typename NumericT> 
unsigned long  cuda_arg(
unsigned long val)  { 
return val; }
 
  145 template<
typename NumericT> 
float          cuda_arg(
float val)          { 
return val; }
 
  146 template<
typename NumericT> 
double         cuda_arg(
double val)         { 
return val; }
 
  162   return static_cast<unsigned int>( ((length > 1) ? (static_cast<unsigned int>(length) << 2) : 0) + (reciprocal ? 2 : 0) + (flip_sign ? 1 : 0) );
 
  167   cudaError_t error_code = cudaGetLastError();
 
  169   if (cudaSuccess != error_code)
 
  171     std::stringstream ss;
 
  172     ss << file << 
"(" << line << 
"): " << 
": getLastCudaError() CUDA error " << error_code << 
": " << cudaGetErrorString( error_code ) << 
" @ " << message << std::endl;
 
  177 template<
typename NumericT>
 
  187 template<
typename NumericT, 
typename OtherT>
 
  190 template<
typename NumericT, 
typename OtherT>
 
  194 template<
typename ArgT>
 
  199 template<
typename ArgT>
 
  201                               unsigned char const &>::type
 
  204 template<
typename ArgT>
 
  209 template<
typename ArgT>
 
  211                               unsigned short const &>::type
 
  214 template<
typename ArgT>
 
  219 template<
typename ArgT>
 
  221                               unsigned int const &>::type
 
  224 template<
typename ArgT>
 
  229 template<
typename ArgT>
 
  231                               unsigned long const &>::type
 
  234 template<
typename ArgT>
 
  239 template<
typename ArgT>
 
  241                               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)
Implementations for the CUDA backend functionality. 
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
NumericT * cuda_arg(scalar< NumericT > &obj)
Convenience helper function for extracting the CUDA handle from a ViennaCL scalar. Non-const version. 
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)