HAMR
The Heterogeneous Accelerator Memory Resource
hamr::buffer_handle< T > Class Template Reference

#include <hamr_buffer_handle.h>

Collaboration diagram for hamr::buffer_handle< T >:

Public Member Functions

 buffer_handle ()
 construct an empty, and unusable object More...
 
 buffer_handle (const std::shared_ptr< T > &src, size_t size, int read_only, int host_accessible, int cuda_accessible, size_t stream)
 construct from existing data More...
 
 buffer_handle (const std::shared_ptr< const T > &src, size_t size, int host_accessible, int cuda_accessible, size_t stream)
 construct from existing read only data More...
 
 ~buffer_handle ()
 destruct More...
 
 buffer_handle (const buffer_handle< T > &other)
 copy construct More...
 
 buffer_handle (buffer_handle< T > &&other)
 move construct More...
 
buffer_handle< T > & operator= (const buffer_handle< T > &)=default
 copy assign More...
 
buffer_handle< T > & operator= (buffer_handle< T > &&)=default
 move assign More...
 
PyObject * get_cuda_array_interface ()
 
PyObject * get_numpy_array_interface ()
 
PyObject * get_array_interface ()
 
void to_stream (std::ostream &os) const
 

Public Attributes

std::shared_ptr< T > m_data
 
size_t m_size
 
int m_read_only
 
int m_host_accessible
 
int m_cuda_accessible
 
size_t m_stream
 

Detailed Description

template<typename T>
class hamr::buffer_handle< T >

A resource management class that is used to keep data shared with Python codes from a ::hamr_buffer alive while it is being accessed by the Python codes. The class also implements the Numpy array interface protocol and the Numba CUDA array interface protocol enabling seamless access by those libraries.

Constructor & Destructor Documentation

◆ buffer_handle() [1/5]

template<typename T >
hamr::buffer_handle< T >::buffer_handle ( )
inline

construct an empty, and unusable object

◆ buffer_handle() [2/5]

template<typename T >
hamr::buffer_handle< T >::buffer_handle ( const std::shared_ptr< T > &  src,
size_t  size,
int  read_only,
int  host_accessible,
int  cuda_accessible,
size_t  stream 
)

construct from existing data

◆ buffer_handle() [3/5]

template<typename T >
hamr::buffer_handle< T >::buffer_handle ( const std::shared_ptr< const T > &  src,
size_t  size,
int  host_accessible,
int  cuda_accessible,
size_t  stream 
)

construct from existing read only data

◆ ~buffer_handle()

template<typename T >
hamr::buffer_handle< T >::~buffer_handle

destruct

◆ buffer_handle() [4/5]

template<typename T >
hamr::buffer_handle< T >::buffer_handle ( const buffer_handle< T > &  other)

copy construct

◆ buffer_handle() [5/5]

template<typename T >
hamr::buffer_handle< T >::buffer_handle ( buffer_handle< T > &&  other)

move construct

Member Function Documentation

◆ get_array_interface()

template<typename T >
PyObject * hamr::buffer_handle< T >::get_array_interface

returns a dictionary as decribed in the Numpy array interface and Numba CUDA array interface protocols. The caller must ensure the data is accessible in the desired technology before use. See ::get_numpy_array_interface and ::get_cuda_array_interface which implement check ensuring that this is true.

◆ get_cuda_array_interface()

template<typename T >
PyObject * hamr::buffer_handle< T >::get_cuda_array_interface

returns a dictionary as described in the Numba CUDA array interface protocol if the data is accessible from CUDA. Otherwise, an AttributeError is rasied.

◆ get_numpy_array_interface()

template<typename T >
PyObject * hamr::buffer_handle< T >::get_numpy_array_interface

returns a dictionary as described in the Numpy array_interface protocol if the data is accessible from CUDA. Otherwise, an AttributeError is rasied.

◆ operator=() [1/2]

template<typename T >
buffer_handle<T>& hamr::buffer_handle< T >::operator= ( buffer_handle< T > &&  )
default

move assign

◆ operator=() [2/2]

template<typename T >
buffer_handle<T>& hamr::buffer_handle< T >::operator= ( const buffer_handle< T > &  )
default

copy assign


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