Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

cmtk::DeviceMemoryCUDA Class Reference
[cmtkGPU library]

Resource managing class for raw memory allocated on a GPU device through CUDA. More...

#include <cmtkDeviceMemoryCUDA.h>

Inheritance diagram for cmtk::DeviceMemoryCUDA:
Inheritance graph
[legend]
Collaboration diagram for cmtk::DeviceMemoryCUDA:
Collaboration graph
[legend]

List of all members.

Classes

class  bad_alloc
 Exception for failed allocation. More...

Public Types

typedef DeviceMemoryCUDA Self
 This class.
typedef SmartConstPointer< SelfSmartConstPtr
 Smart pointer-to-const.
typedef SmartPointer< SelfSmartPtr
 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.

Detailed Description

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.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

cmtk::DeviceMemoryCUDA::DeviceMemoryCUDA ( const size_t  nBytes,
const size_t  padToMultiple = 1 
)

Constructor: allocate memory through CUDA.

Parameters:
nBytesNumber of bytes to allocate
padToMultiplePad 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.


Member Function Documentation

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.


Member Data Documentation

Total number of bytes allocated on device.

Definition at line 105 of file cmtkDeviceMemoryCUDA.h.

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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines