xpu
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
xpu::buffer< T > Class Template Reference

Public Types

using value_type = T
 

Public Member Functions

 buffer ()=default
 Create an emtpy buffer. More...
 
 buffer (size_t N, buffer_type type, T *data=nullptr)
 Create a buffer with the given size. More...
 
XPU_H XPU_D ~buffer ()
 Free the buffer. More...
 
XPU_H XPU_D buffer (const buffer &other)
 
XPU_H XPU_D buffer (buffer &&other)
 
XPU_H XPU_D bufferoperator= (const buffer &other)
 
XPU_H XPU_D bufferoperator= (buffer &&other)
 
template<typename U >
XPU_H XPU_D buffer (const buffer< U > &other)
 
template<typename U >
XPU_H XPU_D buffer (buffer< U > &&other)
 
template<typename U >
XPU_H XPU_D bufferoperator= (const buffer< U > &other)
 
template<typename U >
XPU_H XPU_D bufferoperator= (buffer< U > &&other)
 
XPU_H XPU_D void reset ()
 
void reset (size_t N, buffer_type type, T *data=nullptr)
 
XPU_H XPU_D T * get () const
 
XPU_H XPU_D T & operator* () const
 
XPU_H XPU_D T * operator-> () const
 
XPU_H XPU_D T & operator[] (size_t i) const
 

Member Typedef Documentation

◆ value_type

template<typename T >
using xpu::buffer< T >::value_type = T

Constructor & Destructor Documentation

◆ buffer() [1/6]

template<typename T >
xpu::buffer< T >::buffer ( )
default

Create an emtpy buffer.

◆ buffer() [2/6]

template<typename T >
xpu::buffer< T >::buffer ( size_t  N,
buffer_type  type,
T *  data = nullptr 
)

Create a buffer with the given size.

Parameters
NSize of the buffer.
typeType of the buffer.
dataPointer to the data to use for the buffer.

Allocates a buffer of the given size and type. Behavior depends on the type of the buffer:

  • buf_pinned: Allocates a buffer in host memory. The buffer is accessible from the device. If data is not null, the buffer is initialized with the data.
  • buf_device: Allocates a buffer in device memory that is not accessible from the host. Memory is not initialized and 'data' pointer has no effect
  • buf_managed: Allocates a shared (managed) buffer that is accessible from the host and the device. GPU driver synchronizes memory between host and device. If data is not null, the buffer is initialized with the data.
  • buf_io: Allocates a buffer in device memory. Excepts that data points to a memory region with at least N elements. Buffer may be copied to / from the device using queue::copy from / to 'data'. Note: If the device is a CPU, the underlying pointer simply points to 'data' and no additional allocation takes place. queue::copy calls become no-ops in this case.
  • buf_stack: Allocates a buffer in the stack on the device. The buffer is not accessible from the host. Memory is not initialized and 'data' pointer has no effect. The stack memory must be allocated beforehand using xpu::stack_alloc. Note that, no additional allocation takes place. The buffer simply points to the stack memory. The buffer is not freed automatically when it goes out of scope. Instead use xpu::stack_pop to reset the stack head. Note: This also means stack buffers may overlap.

◆ ~buffer()

template<typename T >
XPU_H XPU_D xpu::buffer< T >::~buffer ( )
inline

Free the buffer.

◆ buffer() [3/6]

template<typename T >
XPU_H XPU_D xpu::buffer< T >::buffer ( const buffer< T > &  other)

◆ buffer() [4/6]

template<typename T >
XPU_H XPU_D xpu::buffer< T >::buffer ( buffer< T > &&  other)

◆ buffer() [5/6]

template<typename T >
template<typename U >
XPU_H XPU_D xpu::buffer< T >::buffer ( const buffer< U > &  other)

◆ buffer() [6/6]

template<typename T >
template<typename U >
XPU_H XPU_D xpu::buffer< T >::buffer ( buffer< U > &&  other)

Member Function Documentation

◆ get()

template<typename T >
XPU_H XPU_D T* xpu::buffer< T >::get ( ) const
inline

◆ operator*()

template<typename T >
XPU_H XPU_D T& xpu::buffer< T >::operator* ( ) const
inline

◆ operator->()

template<typename T >
XPU_H XPU_D T* xpu::buffer< T >::operator-> ( ) const
inline

◆ operator=() [1/4]

template<typename T >
XPU_H XPU_D buffer& xpu::buffer< T >::operator= ( buffer< T > &&  other)

◆ operator=() [2/4]

template<typename T >
template<typename U >
XPU_H XPU_D buffer& xpu::buffer< T >::operator= ( buffer< U > &&  other)

◆ operator=() [3/4]

template<typename T >
XPU_H XPU_D buffer& xpu::buffer< T >::operator= ( const buffer< T > &  other)

◆ operator=() [4/4]

template<typename T >
template<typename U >
XPU_H XPU_D buffer& xpu::buffer< T >::operator= ( const buffer< U > &  other)

◆ operator[]()

template<typename T >
XPU_H XPU_D T& xpu::buffer< T >::operator[] ( size_t  i) const
inline

◆ reset() [1/2]

template<typename T >
XPU_H XPU_D void xpu::buffer< T >::reset ( )

◆ reset() [2/2]

template<typename T >
void xpu::buffer< T >::reset ( size_t  N,
buffer_type  type,
T *  data = nullptr 
)

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