ViennaCL - The Vienna Computing Library  1.7.1
Free open-source GPU-accelerated linear algebra and solver library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
viennacl::backend::mem_handle Class Reference

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_typeram_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...
 

Detailed Description

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.

Member Typedef Documentation

Constructor & Destructor Documentation

viennacl::backend::mem_handle::mem_handle ( )
inline

Default CTOR. No memory is allocated.

Definition at line 96 of file mem_handle.hpp.

Member Function Documentation

memory_types viennacl::backend::mem_handle::get_active_handle_id ( ) const
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.

bool viennacl::backend::mem_handle::operator!= ( mem_handle const &  other) const
inline

Definition at line 203 of file mem_handle.hpp.

bool viennacl::backend::mem_handle::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.

Definition at line 179 of file mem_handle.hpp.

bool viennacl::backend::mem_handle::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.

Definition at line 153 of file mem_handle.hpp.

ram_handle_type& viennacl::backend::mem_handle::ram_handle ( )
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.

ram_handle_type const& viennacl::backend::mem_handle::ram_handle ( ) const
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.

vcl_size_t viennacl::backend::mem_handle::raw_size ( ) const
inline

Returns the number of bytes of the currently active buffer.

Definition at line 230 of file mem_handle.hpp.

void viennacl::backend::mem_handle::raw_size ( vcl_size_t  new_size)
inline

Sets the size of the currently active buffer. Use with care!

Definition at line 233 of file mem_handle.hpp.

void viennacl::backend::mem_handle::swap ( mem_handle other)
inline

Implements a fast swapping method. No data is copied, only the handles are exchanged.

Definition at line 206 of file mem_handle.hpp.

void viennacl::backend::mem_handle::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.

Definition at line 121 of file mem_handle.hpp.


The documentation for this class was generated from the following file: