1 #ifndef VIENNACL_BACKEND_UTIL_HPP 
    2 #define VIENNACL_BACKEND_UTIL_HPP 
   31 #ifdef VIENNACL_WITH_OPENCL 
   51 #ifdef VIENNACL_WITH_OPENCL 
   53   struct convert_to_opencl<unsigned int>
 
   61   struct convert_to_opencl<int>
 
   70   struct convert_to_opencl<unsigned long>
 
   72     typedef cl_ulong    
type;
 
   78   struct convert_to_opencl<long>
 
   91 template<typename T, bool special = detail::convert_to_opencl<T>::special>
 
  110   void * 
get() { 
return reinterpret_cast<void *
>(bytes_buffer_); }
 
  117     reinterpret_cast<cpu_type *
>(bytes_buffer_)[index] = static_cast<cpu_type>(value);
 
  127     buffer_size_ = 
sizeof(cpu_type) * num;
 
  131       delete[] bytes_buffer_;
 
  133       bytes_buffer_ = 
new char[buffer_size_];
 
  145         bytes_buffer_[i] = 0;
 
  151     assert(index < 
size() && 
bool(
"index out of bounds"));
 
  153     return reinterpret_cast<cpu_type *
>(bytes_buffer_)[index];
 
  157   char * bytes_buffer_;
 
  188 #ifdef VIENNACL_WITH_OPENCL 
  189     if (convert_to_opencl_)
 
  190       reinterpret_cast<target_type *
>(bytes_buffer_)[index] = static_cast<target_type>(value);
 
  193       reinterpret_cast<cpu_type *
>(bytes_buffer_)[index] = static_cast<cpu_type>(value);
 
  196   void * 
get() { 
return reinterpret_cast<void *
>(bytes_buffer_); }
 
  199     assert(index < 
size() && 
bool(
"index out of bounds"));
 
  200 #ifdef VIENNACL_WITH_OPENCL 
  201     if (convert_to_opencl_)
 
  202       return static_cast<cpu_type
>(
reinterpret_cast<target_type *
>(bytes_buffer_)[index]);
 
  204     return reinterpret_cast<cpu_type *
>(bytes_buffer_)[index];
 
  210 #ifdef VIENNACL_WITH_OPENCL 
  211     if (convert_to_opencl_)
 
  212       return sizeof(target_type);
 
  214     return sizeof(cpu_type);
 
  225     buffer_size_ = 
sizeof(cpu_type) * num;
 
  228 #ifdef VIENNACL_WITH_OPENCL 
  235       convert_to_opencl_ = 
true;
 
  236       buffer_size_ = 
sizeof(target_type) * num;
 
  242       delete[] bytes_buffer_;
 
  244       bytes_buffer_ = 
new char[buffer_size_];
 
  256         bytes_buffer_[i] = 0;
 
  261   bool convert_to_opencl_;
 
  262   char * bytes_buffer_;
 
Helper class implementing an array on the host. Default case: No conversion necessary. 
void raw_resize(mem_handle const &, vcl_size_t num)
Resize without initializing the new memory. 
vcl_size_t element_size() const 
cpu_type operator[](vcl_size_t index) const 
typesafe_host_array(mem_handle const &handle, vcl_size_t num=0)
cpu_type operator[](vcl_size_t index) const 
This file provides the forward declarations for the main types used within ViennaCL. 
void resize(mem_handle const &handle, vcl_size_t num)
Resize including initialization of new memory (cf. std::vector<>) 
typesafe_host_array(mem_handle const &handle, vcl_size_t num=0)
vcl_size_t element_size() const 
void raw_resize(mem_handle const &handle, vcl_size_t num)
Resize without initializing the new memory. 
Implements the multi-memory-domain handle. 
void set(vcl_size_t index, U value)
memory_types default_memory_type()
Returns the default memory type for the given configuration. 
void resize(mem_handle const &handle, vcl_size_t num)
Resize including initialization of new memory (cf. std::vector<>) 
void set(vcl_size_t index, U value)
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
Implementations for the OpenCL backend functionality. 
viennacl::backend::mem_handle & handle(T &obj)
Returns the generic memory handle of an object. Non-const version. 
vcl_size_t raw_size() const 
vcl_size_t raw_size() const 
Helper struct for converting a type to its OpenCL pendant. 
memory_types get_active_handle_id() const 
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no da...