ViennaCL - The Vienna Computing Library
1.5.1
|
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM, an OpenCL context, or a CUDA device. More...
#include <mem_handle.hpp>
Public Types | |
typedef viennacl::tools::shared_ptr < char > | ram_handle_type |
typedef viennacl::tools::shared_ptr < char > | cuda_handle_type |
Public Member Functions | |
mem_handle () | |
Default CTOR. No memory is allocated. | |
ram_handle_type & | ram_handle () |
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated. | |
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. | |
memory_types | get_active_handle_id () const |
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no data. | |
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 thrown. | |
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 to the same buffer. | |
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 buffer with inferior address useful to store handles into a map, since they naturally have strong ordering. | |
bool | operator!= (mem_handle const &other) const |
void | swap (mem_handle &other) |
Implements a fast swapping method. No data is copied, only the handles are exchanged. | |
vcl_size_t | raw_size () const |
Returns the number of bytes of the currently active buffer. | |
void | raw_size (vcl_size_t new_size) |
Sets the size of the currently active buffer. Use with care! |
Main abstraction class for multiple memory domains. Represents a buffer in either main RAM, an OpenCL context, or a CUDA device.
The idea is to wrap all possible handle types inside this class so that higher-level code does not need to be cluttered with preprocessor switches. Instead, this class collects all the necessary conditional compilations.
typedef viennacl::tools::shared_ptr<char> cuda_handle_type |
typedef viennacl::tools::shared_ptr<char> ram_handle_type |
mem_handle | ( | ) | [inline] |
Default CTOR. No memory is allocated.
memory_types get_active_handle_id | ( | ) | const [inline] |
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no data.
bool operator!= | ( | mem_handle const & | other | ) | const [inline] |
bool operator< | ( | mem_handle const & | other | ) | const [inline] |
Compares the two handles and returns true if the active memory handles in the two mem_handles point a buffer with inferior address useful to store handles into a map, since they naturally have strong ordering.
bool operator== | ( | mem_handle const & | other | ) | const [inline] |
Compares the two handles and returns true if the active memory handles in the two mem_handles point to the same buffer.
ram_handle_type& ram_handle | ( | ) | [inline] |
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated.
ram_handle_type const& ram_handle | ( | ) | const [inline] |
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated.
vcl_size_t raw_size | ( | ) | const [inline] |
Returns the number of bytes of the currently active buffer.
void raw_size | ( | vcl_size_t | new_size | ) | [inline] |
Sets the size of the currently active buffer. Use with care!
void swap | ( | mem_handle & | other | ) | [inline] |
Implements a fast swapping method. No data is copied, only the handles are exchanged.
void switch_active_handle_id | ( | memory_types | new_id | ) | [inline] |
Switches the currently active handle. If no support for that backend is provided, an exception is thrown.