My Project
Public Member Functions | List of all members
cuda_mlp::DeviceBuffer< T > Class Template Reference

Owning buffer for device memory. More...

Public Member Functions

 DeviceBuffer ()=default
 Construct an empty buffer. More...
 
 DeviceBuffer (size_t n)
 Construct and allocate a buffer of size n. More...
 
 DeviceBuffer (const DeviceBuffer &)=delete
 
DeviceBufferoperator= (const DeviceBuffer &)=delete
 
 DeviceBuffer (DeviceBuffer &&other) noexcept
 Move-construct, transferring ownership. More...
 
DeviceBufferoperator= (DeviceBuffer &&other) noexcept
 Move-assign, transferring ownership and releasing previous memory. More...
 
 ~DeviceBuffer ()
 Release any owned device memory. More...
 
void resize (size_t n)
 Resize the buffer, reallocating if needed. More...
 
void release ()
 Free device memory, if allocated. More...
 
T * data ()
 Mutable raw pointer to device memory. More...
 
const T * data () const
 Const raw pointer to device memory. More...
 
size_t size () const
 Current number of elements. More...
 
void copy_from_host (const T *host, size_t n)
 Copy from host to device, resizing as needed. More...
 
void copy_to_host (T *host, size_t n) const
 Copy from device to host. More...
 

Detailed Description

template<typename T>
class cuda_mlp::DeviceBuffer< T >

Owning buffer for device memory.

Constructor & Destructor Documentation

◆ DeviceBuffer() [1/4]

template<typename T >
cuda_mlp::DeviceBuffer< T >::DeviceBuffer ( )
default

Construct an empty buffer.

◆ DeviceBuffer() [2/4]

template<typename T >
cuda_mlp::DeviceBuffer< T >::DeviceBuffer ( size_t  n)
inlineexplicit

Construct and allocate a buffer of size n.

Parameters
nNumber of elements.
Here is the call graph for this function:

◆ DeviceBuffer() [3/4]

template<typename T >
cuda_mlp::DeviceBuffer< T >::DeviceBuffer ( const DeviceBuffer< T > &  )
delete

◆ DeviceBuffer() [4/4]

template<typename T >
cuda_mlp::DeviceBuffer< T >::DeviceBuffer ( DeviceBuffer< T > &&  other)
inlinenoexcept

Move-construct, transferring ownership.

◆ ~DeviceBuffer()

template<typename T >
cuda_mlp::DeviceBuffer< T >::~DeviceBuffer ( )
inline

Release any owned device memory.

Here is the call graph for this function:

Member Function Documentation

◆ copy_from_host()

template<typename T >
void cuda_mlp::DeviceBuffer< T >::copy_from_host ( const T *  host,
size_t  n 
)
inline

Copy from host to device, resizing as needed.

Parameters
hostHost pointer.
nNumber of elements.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_to_host()

template<typename T >
void cuda_mlp::DeviceBuffer< T >::copy_to_host ( T *  host,
size_t  n 
) const
inline

Copy from device to host.

Parameters
hostHost pointer to write into.
nNumber of elements to copy.
Here is the call graph for this function:

◆ data() [1/2]

template<typename T >
T* cuda_mlp::DeviceBuffer< T >::data ( )
inline

Mutable raw pointer to device memory.

Here is the caller graph for this function:

◆ data() [2/2]

template<typename T >
const T* cuda_mlp::DeviceBuffer< T >::data ( ) const
inline

Const raw pointer to device memory.

◆ operator=() [1/2]

template<typename T >
DeviceBuffer& cuda_mlp::DeviceBuffer< T >::operator= ( const DeviceBuffer< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
DeviceBuffer& cuda_mlp::DeviceBuffer< T >::operator= ( DeviceBuffer< T > &&  other)
inlinenoexcept

Move-assign, transferring ownership and releasing previous memory.

Here is the call graph for this function:

◆ release()

template<typename T >
void cuda_mlp::DeviceBuffer< T >::release ( )
inline

Free device memory, if allocated.

Here is the caller graph for this function:

◆ resize()

template<typename T >
void cuda_mlp::DeviceBuffer< T >::resize ( size_t  n)
inline

Resize the buffer, reallocating if needed.

Parameters
nNew element count.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

template<typename T >
size_t cuda_mlp::DeviceBuffer< T >::size ( ) const
inline

Current number of elements.

Here is the caller graph for this function:

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