Public Member Functions | Private Attributes | List of all members
kfusion::cuda::DeviceMemory Class Reference

DeviceMemory class More...

#include <device_memory.hpp>

Inheritance diagram for kfusion::cuda::DeviceMemory:
Inheritance graph
[legend]

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 (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...
 
 DeviceMemory (const DeviceMemory &other_arg)
 Copy constructor. Just increments reference counter. 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...
 
DeviceMemoryoperator= (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...
 

Detailed Description

DeviceMemory class

Note
This is a BLOB container class with reference counting for GPU memory.
Author
Anatoly Baksheev

Definition at line 21 of file device_memory.hpp.

Constructor & Destructor Documentation

◆ DeviceMemory() [1/4]

kfusion::cuda::DeviceMemory::DeviceMemory ( )

Empty constructor.

Definition at line 46 of file device_memory.cpp.

◆ ~DeviceMemory()

kfusion::cuda::DeviceMemory::~DeviceMemory ( )

Destructor.

Definition at line 49 of file device_memory.cpp.

◆ DeviceMemory() [2/4]

kfusion::cuda::DeviceMemory::DeviceMemory ( size_t  sizeBytes_arg)

Allocates internal buffer in GPU memory.

Parameters
sizeBytes_argamount of memory to allocate

Definition at line 48 of file device_memory.cpp.

◆ DeviceMemory() [3/4]

kfusion::cuda::DeviceMemory::DeviceMemory ( void *  ptr_arg,
size_t  sizeBytes_arg 
)

Initializes with user allocated buffer. Reference counting is disabled in this case.

Parameters
ptr_argpointer to buffer
sizeBytes_argbuffer size

Definition at line 47 of file device_memory.cpp.

◆ DeviceMemory() [4/4]

kfusion::cuda::DeviceMemory::DeviceMemory ( const DeviceMemory other_arg)

Copy constructor. Just increments reference counter.

Definition at line 51 of file device_memory.cpp.

Member Function Documentation

◆ copyTo()

void kfusion::cuda::DeviceMemory::copyTo ( DeviceMemory other) const

Performs data copying. If destination size differs it will be reallocated.

Parameters
other_argdestination container

Definition at line 93 of file device_memory.cpp.

◆ create()

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.

Parameters
sizeBytes_argbuffer size

Definition at line 73 of file device_memory.cpp.

◆ download()

void kfusion::cuda::DeviceMemory::download ( void *  host_ptr_arg) const

Downloads data from internal buffer to CPU memory.

Parameters
host_ptr_argpointer to buffer to download

Definition at line 125 of file device_memory.cpp.

◆ empty()

bool kfusion::cuda::DeviceMemory::empty ( ) const

Returns true if unallocated otherwise false.

Definition at line 138 of file device_memory.cpp.

◆ operator PtrSz< U >()

template<class U >
kfusion::cuda::DeviceMemory::operator PtrSz< U > ( ) const

Conversion to PtrSz for passing to kernel functions.

◆ operator=()

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.

◆ ptr() [1/2]

template<class T >
T * kfusion::cuda::DeviceMemory::ptr ( )
inline

Returns pointer for internal buffer in GPU memory.

Definition at line 226 of file device_memory.hpp.

◆ ptr() [2/2]

template<class T >
const T * kfusion::cuda::DeviceMemory::ptr ( ) const
inline

Returns constant pointer for internal buffer in GPU memory.

Definition at line 227 of file device_memory.hpp.

◆ release()

void kfusion::cuda::DeviceMemory::release ( )

Decrements reference counter and releases internal buffer if needed.

Definition at line 105 of file device_memory.cpp.

◆ sizeBytes()

size_t kfusion::cuda::DeviceMemory::sizeBytes ( ) const

Definition at line 139 of file device_memory.cpp.

◆ swap()

void kfusion::cuda::DeviceMemory::swap ( DeviceMemory other_arg)

Performs swap of data pointed with another device memory.

Parameters
otherdevice memory to swap with

Definition at line 131 of file device_memory.cpp.

◆ upload()

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.

Parameters
host_ptr_argpointer to buffer to upload
sizeBytes_argbuffer size

Definition at line 118 of file device_memory.cpp.

Member Data Documentation

◆ data_

void* kfusion::cuda::DeviceMemory::data_
private

Device pointer.

Definition at line 92 of file device_memory.hpp.

◆ refcount_

int* kfusion::cuda::DeviceMemory::refcount_
private

Pointer to reference counter in CPU memory.

Definition at line 98 of file device_memory.hpp.

◆ sizeBytes_

size_t kfusion::cuda::DeviceMemory::sizeBytes_
private

Allocated size in bytes.

Definition at line 95 of file device_memory.hpp.


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


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:11