1 #ifndef VIENNACL_BACKEND_MEM_HANDLE_HPP 
    2 #define VIENNACL_BACKEND_MEM_HANDLE_HPP 
   31 #ifdef VIENNACL_WITH_OPENCL 
   35 #ifdef VIENNACL_WITH_CUDA 
   54 #ifdef VIENNACL_WITH_CUDA 
   56 #elif defined(VIENNACL_WITH_OPENCL) 
   63       mem_type = *new_mem_type;
 
  103 #ifdef VIENNACL_WITH_OPENCL 
  110 #ifdef VIENNACL_WITH_CUDA 
  123     if (new_id != active_handle_)
 
  126         active_handle_ = new_id;
 
  129         active_handle_ = new_id;
 
  133 #ifdef VIENNACL_WITH_OPENCL 
  134         active_handle_ = new_id;
 
  141 #ifdef VIENNACL_WITH_CUDA 
  142         active_handle_ = new_id;
 
  155     if (active_handle_ != other.active_handle_)
 
  158     switch (active_handle_)
 
  161       return ram_handle_.
get() == other.ram_handle_.
get();
 
  162 #ifdef VIENNACL_WITH_OPENCL 
  164       return opencl_handle_.get() == other.opencl_handle_.get();
 
  166 #ifdef VIENNACL_WITH_CUDA 
  168       return cuda_handle_.get() == other.cuda_handle_.get();
 
  181     if (active_handle_ != other.active_handle_)
 
  184     switch (active_handle_)
 
  187       return ram_handle_.
get() < other.ram_handle_.
get();
 
  188 #ifdef VIENNACL_WITH_OPENCL 
  190       return opencl_handle_.get() < other.opencl_handle_.get();
 
  192 #ifdef VIENNACL_WITH_CUDA 
  194       return cuda_handle_.get() < other.cuda_handle_.get();
 
  210     other.active_handle_ = active_handle_;
 
  211     active_handle_ = active_handle_tmp;
 
  215     other.ram_handle_ = ram_handle_;
 
  216     ram_handle_ = ram_handle_tmp;
 
  219 #ifdef VIENNACL_WITH_OPENCL 
  220     opencl_handle_.
swap(other.opencl_handle_);
 
  222 #ifdef VIENNACL_WITH_CUDA 
  224     other.cuda_handle_ = cuda_handle_;
 
  225     cuda_handle_ = cuda_handle_tmp;
 
  238 #ifdef VIENNACL_WITH_OPENCL 
  241 #ifdef VIENNACL_WITH_CUDA 
Exception class in case of memory errors. 
bool operator<(mem_handle const &other) const 
Compares the two handles and returns true if the active memory handles in the two mem_handles point a...
viennacl::tools::shared_ptr< char > ram_handle_type
ram_handle_type const & ram_handle() const 
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated...
void swap(mem_handle &other)
Implements a fast swapping method. No data is copied, only the handles are exchanged. 
This file provides the forward declarations for the main types used within ViennaCL. 
mem_handle()
Default CTOR. No memory is allocated. 
Implementation of a shared pointer class (cf. std::shared_ptr, boost::shared_ptr). Will be used until C++11 is widely available. 
void raw_size(vcl_size_t new_size)
Sets the size of the currently active buffer. Use with care! 
Implementations for the OpenCL backend functionality. 
viennacl::tools::shared_ptr< char > cuda_handle_type
bool operator==(mem_handle const &other) const 
Compares the two handles and returns true if the active memory handles in the two mem_handles point t...
Implementations for the CUDA backend functionality. 
memory_types default_memory_type()
Returns the default memory type for the given configuration. 
void switch_active_handle_id(memory_types new_id)
Switches the currently active handle. If no support for that backend is provided, an exception is thr...
bool operator!=(mem_handle const &other) const 
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM...
vcl_size_t raw_size() const 
Returns the number of bytes of the currently active buffer. 
Implementations for the OpenCL backend functionality. 
ram_handle_type & ram_handle()
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated...
memory_types get_set_default_memory_type(memory_types *new_mem_type)
Singleton for managing the default memory type. 
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...