Simple memory buffer using un-managed pinned host memory when compiled with NVCC. Obviously this class is making explicit used of CUDA so replace it with your own memory allocator if you are not using CUDA.
More...
#include <CudaDeviceBuffer.h>
|
| CudaDeviceBuffer (uint64_t size=0, bool host=true, void *stream=nullptr) |
| Constructor. More...
|
|
| CudaDeviceBuffer (const CudaDeviceBuffer &)=delete |
| Disallow copy-construction. More...
|
|
| CudaDeviceBuffer (CudaDeviceBuffer &&other) noexcept |
| Move copy-constructor. More...
|
|
CudaDeviceBuffer & | operator= (const CudaDeviceBuffer &)=delete |
| Disallow copy assignment operation. More...
|
|
CudaDeviceBuffer & | operator= (CudaDeviceBuffer &&other) noexcept |
| Move copy assignment operation. More...
|
|
| ~CudaDeviceBuffer () |
| Destructor frees memory on both the host and device. More...
|
|
void | init (uint64_t size, bool host=true, void *stream=nullptr) |
| Initialize buffer. More...
|
|
uint8_t * | data () const |
| Retuns a raw pointer to the host/CPU buffer managed by this allocator. More...
|
|
uint8_t * | deviceData () const |
| Retuns a raw pointer to the device/GPU buffer managed by this allocator. More...
|
|
void | deviceUpload (void *stream=nullptr, bool sync=true) const |
| Upload this buffer from the host to the device, i.e. CPU -> GPU. More...
|
|
void | deviceDownload (void *stream=nullptr, bool sync=true) const |
| Upload this buffer from the device to the host, i.e. GPU -> CPU. More...
|
|
uint64_t | size () const |
| Returns the size in bytes of the raw memory buffer managed by this allocator. More...
|
|
void | clear (void *stream=nullptr) |
| De-allocate all memory managed by this allocator and set all pointers to NULL. More...
|
|
|
bool | empty () const |
| Returns true if this allocator is empty, i.e. has no allocated memory. More...
|
|
bool | isEmpty () const |
| Returns true if this allocator is empty, i.e. has no allocated memory. More...
|
|
Simple memory buffer using un-managed pinned host memory when compiled with NVCC. Obviously this class is making explicit used of CUDA so replace it with your own memory allocator if you are not using CUDA.
- Note
- While CUDA's pinned host memory allows for asynchronous memory copy between host and device it is significantly slower then cached (un-pinned) memory on the host.
Definition at line 32 of file CudaDeviceBuffer.h.
nanovdb::CudaDeviceBuffer::CudaDeviceBuffer |
( |
uint64_t |
size = 0 , |
|
|
bool |
host = true , |
|
|
void * |
stream = nullptr |
|
) |
| |
|
inline |
Constructor.
- Parameters
-
size | byte size of buffer to be initialized |
host | If true buffer is initialized only on the host/CPU, else on the device/GPU |
stream | optional stream argument (defaults to stream NULL) |
Definition at line 51 of file CudaDeviceBuffer.h.
Disallow copy-construction.
nanovdb::CudaDeviceBuffer::~CudaDeviceBuffer |
( |
| ) |
|
|
inline |
Destructor frees memory on both the host and device.
Definition at line 90 of file CudaDeviceBuffer.h.
void nanovdb::CudaDeviceBuffer::clear |
( |
void * |
stream = nullptr | ) |
|
|
inline |
De-allocate all memory managed by this allocator and set all pointers to NULL.
Definition at line 184 of file CudaDeviceBuffer.h.
Static factory method that return an instance of this buffer.
- Parameters
-
size | byte size of buffer to be initialized |
dummy | this argument is currently ignored but required to match the API of the HostBuffer |
host | If true buffer is initialized only on the host/CPU, else on the device/GPU |
stream | optional stream argument (defaults to stream NULL) |
- Returns
- An instance of this class using move semantics
Definition at line 143 of file CudaDeviceBuffer.h.
uint8_t* nanovdb::CudaDeviceBuffer::data |
( |
| ) |
const |
|
inline |
Retuns a raw pointer to the host/CPU buffer managed by this allocator.
- Warning
- Note that the pointer can be NULL!
Definition at line 101 of file CudaDeviceBuffer.h.
uint8_t* nanovdb::CudaDeviceBuffer::deviceData |
( |
| ) |
const |
|
inline |
Retuns a raw pointer to the device/GPU buffer managed by this allocator.
- Warning
- Note that the pointer can be NULL!
Definition at line 105 of file CudaDeviceBuffer.h.
void nanovdb::CudaDeviceBuffer::deviceDownload |
( |
void * |
stream = nullptr , |
|
|
bool |
sync = true |
|
) |
| const |
|
inline |
Upload this buffer from the device to the host, i.e. GPU -> CPU.
- Parameters
-
stream | optional CUDA stream (defaults to CUDA stream 0) |
sync | if false the memory copy is asynchronous |
- Note
- If the host/CPU buffer does not exist it is first allocated
- Warning
- Assumes that the device/GPU buffer already exists
Definition at line 173 of file CudaDeviceBuffer.h.
void nanovdb::CudaDeviceBuffer::deviceUpload |
( |
void * |
stream = nullptr , |
|
|
bool |
sync = true |
|
) |
| const |
|
inline |
Upload this buffer from the host to the device, i.e. CPU -> GPU.
- Parameters
-
stream | optional CUDA stream (defaults to CUDA stream 0) |
sync | if false the memory copy is asynchronous |
- Note
- If the device/GPU buffer does not exist it is first allocated
- Warning
- Assumes that the host/CPU buffer already exists
Definition at line 162 of file CudaDeviceBuffer.h.
bool nanovdb::CudaDeviceBuffer::empty |
( |
void |
| ) |
const |
|
inline |
Returns true if this allocator is empty, i.e. has no allocated memory.
Definition at line 126 of file CudaDeviceBuffer.h.
void nanovdb::CudaDeviceBuffer::init |
( |
uint64_t |
size, |
|
|
bool |
host = true , |
|
|
void * |
stream = nullptr |
|
) |
| |
|
inline |
Initialize buffer.
- Parameters
-
size | byte size of buffer to be initialized |
host | If true buffer is initialized only on the host/CPU, else on the device/GPU |
- Note
- All existing buffers are first cleared
- Warning
- size is expected to be non-zero. Use clear() clear buffer!
Definition at line 148 of file CudaDeviceBuffer.h.
bool nanovdb::CudaDeviceBuffer::isEmpty |
( |
| ) |
const |
|
inline |
Returns true if this allocator is empty, i.e. has no allocated memory.
Definition at line 127 of file CudaDeviceBuffer.h.
Disallow copy assignment operation.
uint64_t nanovdb::CudaDeviceBuffer::size |
( |
void |
| ) |
const |
|
inline |
Returns the size in bytes of the raw memory buffer managed by this allocator.
Definition at line 122 of file CudaDeviceBuffer.h.
The documentation for this class was generated from the following file: