OpenMPCD
Public Member Functions | List of all members
OpenMPCD::CUDA::DeviceBuffer< T > Class Template Reference

Represents a memory buffer on the Device. More...

#include <DeviceBuffer.hpp>

Public Member Functions

 DeviceBuffer (const std::size_t elementCount_)
 The constructor. More...
 
 ~DeviceBuffer ()
 The destructor. More...
 
T * getPointer ()
 Returns the Device pointer. More...
 
const T * getPointer () const
 Returns the Device pointer. More...
 
std::size_t getElementCount () const
 Returns the number of elements the buffer can store. More...
 
void copyFromDevice (const T *const src)
 Copies getElementCount() elements from the given Device pointer to this buffer. More...
 
void zeroMemory ()
 Writes zero-bytes to the entirety of this buffer. More...
 

Detailed Description

template<typename T>
class OpenMPCD::CUDA::DeviceBuffer< T >

Represents a memory buffer on the Device.

The memory for this buffer will be allocated and freed automatically.

Template Parameters
TThe underlying data type.

Definition at line 24 of file DeviceBuffer.hpp.

Constructor & Destructor Documentation

◆ DeviceBuffer()

template<typename T >
OpenMPCD::CUDA::DeviceBuffer< T >::DeviceBuffer ( const std::size_t  elementCount_)

The constructor.

Exceptions
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if elemtCount_ == 0.
Parameters
[in]elementCount_The number of elements to allocate memory for. No constructors will be called. Must not be 0.

Definition at line 19 of file ImplementationDetails/DeviceBuffer.hpp.

◆ ~DeviceBuffer()

template<typename T >
OpenMPCD::CUDA::DeviceBuffer< T >::~DeviceBuffer

The destructor.

This will free the allocated memory, but will not call any destructors.

Definition at line 31 of file ImplementationDetails/DeviceBuffer.hpp.

Member Function Documentation

◆ copyFromDevice()

template<typename T >
void OpenMPCD::CUDA::DeviceBuffer< T >::copyFromDevice ( const T *const  src)

Copies getElementCount() elements from the given Device pointer to this buffer.

Exceptions
OpenMPCD::NULLPointerExceptionIf OPENMPCD_DEBUG is defined, throws if src == nullptr.
Parameters
[in]srcThe Device pointer to copy from, which must not be nullptr and must point to at least getElementCount() elements.

Definition at line 55 of file ImplementationDetails/DeviceBuffer.hpp.

◆ getElementCount()

template<typename T >
std::size_t OpenMPCD::CUDA::DeviceBuffer< T >::getElementCount

Returns the number of elements the buffer can store.

Definition at line 49 of file ImplementationDetails/DeviceBuffer.hpp.

◆ getPointer() [1/2]

template<typename T >
const T * OpenMPCD::CUDA::DeviceBuffer< T >::getPointer

Returns the Device pointer.

Definition at line 37 of file ImplementationDetails/DeviceBuffer.hpp.

◆ getPointer() [2/2]

template<typename T >
const T* OpenMPCD::CUDA::DeviceBuffer< T >::getPointer ( ) const

Returns the Device pointer.

◆ zeroMemory()

template<typename T >
void OpenMPCD::CUDA::DeviceBuffer< T >::zeroMemory

Writes zero-bytes to the entirety of this buffer.

Definition at line 64 of file ImplementationDetails/DeviceBuffer.hpp.


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