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. More... | |
ram_handle_type & | ram_handle () |
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
vcl_size_t | raw_size () const |
Returns the number of bytes of the currently active buffer. More... | |
void | raw_size (vcl_size_t new_size) |
Sets the size of the currently active buffer. Use with care! More... | |
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.
Definition at line 89 of file mem_handle.hpp.
Definition at line 93 of file mem_handle.hpp.
Definition at line 92 of file mem_handle.hpp.
|
inline |
Default CTOR. No memory is allocated.
Definition at line 96 of file mem_handle.hpp.
|
inline |
Returns an ID for the currently active memory buffer. Other memory buffers might contain old or no data.
Definition at line 118 of file mem_handle.hpp.
|
inline |
Definition at line 203 of file mem_handle.hpp.
|
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.
Definition at line 179 of file mem_handle.hpp.
|
inline |
Compares the two handles and returns true if the active memory handles in the two mem_handles point to the same buffer.
Definition at line 153 of file mem_handle.hpp.
|
inline |
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated.
Definition at line 99 of file mem_handle.hpp.
|
inline |
Returns the handle to a buffer in CPU RAM. NULL is returned if no such buffer has been allocated.
Definition at line 101 of file mem_handle.hpp.
|
inline |
Returns the number of bytes of the currently active buffer.
Definition at line 230 of file mem_handle.hpp.
|
inline |
Sets the size of the currently active buffer. Use with care!
Definition at line 233 of file mem_handle.hpp.
|
inline |
Implements a fast swapping method. No data is copied, only the handles are exchanged.
Definition at line 206 of file mem_handle.hpp.
|
inline |
Switches the currently active handle. If no support for that backend is provided, an exception is thrown.
Definition at line 121 of file mem_handle.hpp.