Resource managing class for raw memory allocated on a GPU device through CUDA. More...
#include <cmtkDeviceMemoryCUDA.h>
Classes | |
class | bad_alloc |
Exception for failed allocation. More... | |
Public Types | |
typedef DeviceMemoryCUDA | Self |
This class. | |
typedef SmartConstPointer< Self > | SmartConstPtr |
Smart pointer-to-const. | |
typedef SmartPointer< Self > | SmartPtr |
Smart pointer. | |
Public Member Functions | |
DeviceMemoryCUDA (const size_t nBytes, const size_t padToMultiple=1) | |
Constructor: allocate memory through CUDA. | |
virtual | ~DeviceMemoryCUDA () |
Destructor: free memory through CUDA. | |
size_t | GetNumberOfBytesAllocated () |
Get number of bytes allocated on device. | |
Protected Member Functions | |
Self::SmartPtr | Alloc (const size_t nBytes, const size_t padToMultiple=1) |
Create new object and allocate memory. | |
void | CopyToDevice (const void *const srcPtrHost, const size_t nBytes) |
Copy from host to device memory. | |
void | CopyToHost (void *const dstPtrHost, const size_t nBytes) const |
Copy from device to host memory. | |
void | CopyOnDevice (const Self &srcPtrDevice, const size_t nBytes) |
Copy between two device memory locations. | |
void | Memset (const int value, const size_t nBytes) |
Copy between two device memory locations. | |
Protected Attributes | |
void * | m_PointerDevice |
Raw pointer to allocated device memory. | |
size_t | m_NumberOfBytesAllocated |
Total number of bytes allocated on device. |
Resource managing class for raw memory allocated on a GPU device through CUDA.
Make sure this is never copied.
Definition at line 50 of file cmtkDeviceMemoryCUDA.h.
This class.
Definition at line 56 of file cmtkDeviceMemoryCUDA.h.
Smart pointer-to-const.
Definition at line 59 of file cmtkDeviceMemoryCUDA.h.
Smart pointer.
Definition at line 62 of file cmtkDeviceMemoryCUDA.h.
cmtk::DeviceMemoryCUDA::DeviceMemoryCUDA | ( | const size_t | nBytes, |
const size_t | padToMultiple = 1 |
||
) |
Constructor: allocate memory through CUDA.
nBytes | Number of bytes to allocate |
padToMultiple | Pad to allocate nearest multiple of this many bytes. |
Definition at line 42 of file cmtkDeviceMemoryCUDA.cxx.
References cmtkCheckCallCUDA.
cmtk::DeviceMemoryCUDA::~DeviceMemoryCUDA | ( | ) | [virtual] |
Destructor: free memory through CUDA.
Definition at line 50 of file cmtkDeviceMemoryCUDA.cxx.
References cmtkCheckCallCUDA.
Self::SmartPtr cmtk::DeviceMemoryCUDA::Alloc | ( | const size_t | nBytes, |
const size_t | padToMultiple = 1 |
||
) | [inline, protected] |
Create new object and allocate memory.
Definition at line 81 of file cmtkDeviceMemoryCUDA.h.
void cmtk::DeviceMemoryCUDA::CopyOnDevice | ( | const Self & | srcPtrDevice, |
const size_t | nBytes | ||
) | [protected] |
Copy between two device memory locations.
Definition at line 72 of file cmtkDeviceMemoryCUDA.cxx.
References cmtkCheckCallCUDA, and m_PointerDevice.
void cmtk::DeviceMemoryCUDA::CopyToDevice | ( | const void *const | srcPtrHost, |
const size_t | nBytes | ||
) | [protected] |
Copy from host to device memory.
Definition at line 58 of file cmtkDeviceMemoryCUDA.cxx.
References cmtkCheckCallCUDA.
void cmtk::DeviceMemoryCUDA::CopyToHost | ( | void *const | dstPtrHost, |
const size_t | nBytes | ||
) | const [protected] |
Copy from device to host memory.
Definition at line 65 of file cmtkDeviceMemoryCUDA.cxx.
References cmtkCheckCallCUDA.
size_t cmtk::DeviceMemoryCUDA::GetNumberOfBytesAllocated | ( | ) | [inline] |
Get number of bytes allocated on device.
Definition at line 74 of file cmtkDeviceMemoryCUDA.h.
void cmtk::DeviceMemoryCUDA::Memset | ( | const int | value, |
const size_t | nBytes | ||
) | [protected] |
Copy between two device memory locations.
Definition at line 79 of file cmtkDeviceMemoryCUDA.cxx.
References cmtkCheckCallCUDA.
size_t cmtk::DeviceMemoryCUDA::m_NumberOfBytesAllocated [protected] |
Total number of bytes allocated on device.
Definition at line 105 of file cmtkDeviceMemoryCUDA.h.
void* cmtk::DeviceMemoryCUDA::m_PointerDevice [protected] |
Raw pointer to allocated device memory.
Note that this is a device memory space pointer, which is not valid in host memory and can, therefore, not be dereferenced in host code.
Definition at line 102 of file cmtkDeviceMemoryCUDA.h.
Referenced by CopyOnDevice().