DeviceMemory class More...
#include <device_memory.hpp>

Public Member Functions | |
| void | copyTo (DeviceMemory &other) const |
| Performs data copying. If destination size differs it will be reallocated. More... | |
| void | create (size_t sizeBytes_arg) |
| Allocates internal buffer in GPU memory. If internal buffer was created before the function recreates it with new size. If new and old sizes are equal it does nothing. More... | |
| DeviceMemory () | |
| Empty constructor. More... | |
| DeviceMemory (const DeviceMemory &other_arg) | |
| Copy constructor. Just increments reference counter. More... | |
| DeviceMemory (size_t sizeBytes_arg) | |
| Allocates internal buffer in GPU memory. More... | |
| DeviceMemory (void *ptr_arg, size_t sizeBytes_arg) | |
| Initializes with user allocated buffer. Reference counting is disabled in this case. More... | |
| void | download (void *host_ptr_arg) const |
| Downloads data from internal buffer to CPU memory. More... | |
| bool | empty () const |
| Returns true if unallocated otherwise false. More... | |
| template<class U > | |
| operator PtrSz< U > () const | |
| Conversion to PtrSz for passing to kernel functions. More... | |
| DeviceMemory & | operator= (const DeviceMemory &other_arg) |
| Assigment operator. Just increments reference counter. More... | |
| template<class T > | |
| T * | ptr () |
| Returns pointer for internal buffer in GPU memory. More... | |
| template<class T > | |
| const T * | ptr () const |
| Returns constant pointer for internal buffer in GPU memory. More... | |
| void | release () |
| Decrements reference counter and releases internal buffer if needed. More... | |
| size_t | sizeBytes () const |
| void | swap (DeviceMemory &other_arg) |
| Performs swap of data pointed with another device memory. More... | |
| void | upload (const void *host_ptr_arg, size_t sizeBytes_arg) |
| Uploads data to internal buffer in GPU memory. It calls create() inside to ensure that intenal buffer size is enough. More... | |
| ~DeviceMemory () | |
| Destructor. More... | |
Private Attributes | |
| void * | data_ |
| Device pointer. More... | |
| int * | refcount_ |
| Pointer to reference counter in CPU memory. More... | |
| size_t | sizeBytes_ |
| Allocated size in bytes. More... | |
DeviceMemory class
Definition at line 21 of file device_memory.hpp.
| kfusion::cuda::DeviceMemory::DeviceMemory | ( | ) |
Empty constructor.
Definition at line 46 of file device_memory.cpp.
| kfusion::cuda::DeviceMemory::~DeviceMemory | ( | ) |
Destructor.
Definition at line 49 of file device_memory.cpp.
| kfusion::cuda::DeviceMemory::DeviceMemory | ( | size_t | sizeBytes_arg | ) |
Allocates internal buffer in GPU memory.
| sizeBytes_arg | amount of memory to allocate |
Definition at line 48 of file device_memory.cpp.
| kfusion::cuda::DeviceMemory::DeviceMemory | ( | void * | ptr_arg, |
| size_t | sizeBytes_arg | ||
| ) |
Initializes with user allocated buffer. Reference counting is disabled in this case.
| ptr_arg | pointer to buffer |
| sizeBytes_arg | buffer size |
Definition at line 47 of file device_memory.cpp.
| kfusion::cuda::DeviceMemory::DeviceMemory | ( | const DeviceMemory & | other_arg | ) |
Copy constructor. Just increments reference counter.
Definition at line 51 of file device_memory.cpp.
| void kfusion::cuda::DeviceMemory::copyTo | ( | DeviceMemory & | other | ) | const |
Performs data copying. If destination size differs it will be reallocated.
| other_arg | destination container |
Definition at line 93 of file device_memory.cpp.
| void kfusion::cuda::DeviceMemory::create | ( | size_t | sizeBytes_arg | ) |
Allocates internal buffer in GPU memory. If internal buffer was created before the function recreates it with new size. If new and old sizes are equal it does nothing.
| sizeBytes_arg | buffer size |
Definition at line 73 of file device_memory.cpp.
| void kfusion::cuda::DeviceMemory::download | ( | void * | host_ptr_arg | ) | const |
Downloads data from internal buffer to CPU memory.
| host_ptr_arg | pointer to buffer to download |
Definition at line 125 of file device_memory.cpp.
| bool kfusion::cuda::DeviceMemory::empty | ( | ) | const |
Returns true if unallocated otherwise false.
Definition at line 138 of file device_memory.cpp.
| kfusion::cuda::DeviceMemory::operator PtrSz< U > | ( | ) | const |
Conversion to PtrSz for passing to kernel functions.
| kfusion::cuda::DeviceMemory & kfusion::cuda::DeviceMemory::operator= | ( | const DeviceMemory & | other_arg | ) |
Assigment operator. Just increments reference counter.
Definition at line 58 of file device_memory.cpp.
|
inline |
Returns pointer for internal buffer in GPU memory.
Definition at line 226 of file device_memory.hpp.
|
inline |
Returns constant pointer for internal buffer in GPU memory.
Definition at line 227 of file device_memory.hpp.
| void kfusion::cuda::DeviceMemory::release | ( | ) |
Decrements reference counter and releases internal buffer if needed.
Definition at line 105 of file device_memory.cpp.
| size_t kfusion::cuda::DeviceMemory::sizeBytes | ( | ) | const |
Definition at line 139 of file device_memory.cpp.
| void kfusion::cuda::DeviceMemory::swap | ( | DeviceMemory & | other_arg | ) |
Performs swap of data pointed with another device memory.
| other | device memory to swap with |
Definition at line 131 of file device_memory.cpp.
| void kfusion::cuda::DeviceMemory::upload | ( | const void * | host_ptr_arg, |
| size_t | sizeBytes_arg | ||
| ) |
Uploads data to internal buffer in GPU memory. It calls create() inside to ensure that intenal buffer size is enough.
| host_ptr_arg | pointer to buffer to upload |
| sizeBytes_arg | buffer size |
Definition at line 118 of file device_memory.cpp.
|
private |
Device pointer.
Definition at line 92 of file device_memory.hpp.
|
private |
Pointer to reference counter in CPU memory.
Definition at line 98 of file device_memory.hpp.
|
private |
Allocated size in bytes.
Definition at line 95 of file device_memory.hpp.