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

DeviceMemory2D class More...

#include <device_memory.hpp>

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

Public Member Functions

int colsBytes () const
 Returns number of bytes in each row. More...
 
void copyTo (DeviceMemory2D &other) const
 Performs data copying. If destination size differs it will be reallocated. More...
 
void create (int rows_arg, int colsBytes_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...
 
 DeviceMemory2D ()
 Empty constructor. More...
 
 DeviceMemory2D (int rows_arg, int colsBytes_arg)
 Allocates internal buffer in GPU memory. More...
 
 DeviceMemory2D (int rows_arg, int colsBytes_arg, void *data_arg, size_t step_arg)
 Initializes with user allocated buffer. Reference counting is disabled in this case. More...
 
 DeviceMemory2D (const DeviceMemory2D &other_arg)
 Copy constructor. Just increments reference counter. More...
 
void download (void *host_ptr_arg, size_t host_step_arg) const
 Downloads data from internal buffer to CPU memory. User is resposible for correct host buffer size. More...
 
bool empty () const
 Returns true if unallocated otherwise false. More...
 
template<class U >
 operator PtrStep< U > () const
 Conversion to PtrStep for passing to kernel functions. More...
 
template<class U >
 operator PtrStepSz< U > () const
 Conversion to PtrStepSz for passing to kernel functions. More...
 
DeviceMemory2Doperator= (const DeviceMemory2D &other_arg)
 Assigment operator. Just increments reference counter. More...
 
template<class T >
T * ptr (int y_arg=0)
 Returns pointer to given row in internal buffer. More...
 
template<class T >
const T * ptr (int y_arg=0) const
 Returns constant pointer to given row in internal buffer. More...
 
void release ()
 Decrements reference counter and releases internal buffer if needed. More...
 
int rows () const
 Returns number of rows. More...
 
size_t step () const
 Returns stride between two consecutive rows in bytes for internal buffer. Step is stored always and everywhere in bytes!!! More...
 
void swap (DeviceMemory2D &other_arg)
 Performs swap of data pointed with another device memory. More...
 
void upload (const void *host_ptr_arg, size_t host_step_arg, int rows_arg, int colsBytes_arg)
 Uploads data to internal buffer in GPU memory. It calls create() inside to ensure that intenal buffer size is enough. More...
 
 ~DeviceMemory2D ()
 Destructor. More...
 

Private Attributes

int colsBytes_
 Width of the buffer in bytes. More...
 
void * data_
 Device pointer. More...
 
int * refcount_
 Pointer to reference counter in CPU memory. More...
 
int rows_
 Number of rows. More...
 
size_t step_
 Stride between two consecutive rows in bytes for internal buffer. Step is stored always and everywhere in bytes!!! More...
 

Detailed Description

DeviceMemory2D class

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

Definition at line 109 of file device_memory.hpp.

Constructor & Destructor Documentation

◆ DeviceMemory2D() [1/4]

kfusion::cuda::DeviceMemory2D::DeviceMemory2D ( )

Empty constructor.

Definition at line 144 of file device_memory.cpp.

◆ ~DeviceMemory2D()

kfusion::cuda::DeviceMemory2D::~DeviceMemory2D ( )

Destructor.

Definition at line 155 of file device_memory.cpp.

◆ DeviceMemory2D() [2/4]

kfusion::cuda::DeviceMemory2D::DeviceMemory2D ( int  rows_arg,
int  colsBytes_arg 
)

Allocates internal buffer in GPU memory.

Parameters
rows_argnumber of rows to allocate
colsBytes_argwidth of the buffer in bytes

Definition at line 146 of file device_memory.cpp.

◆ DeviceMemory2D() [3/4]

kfusion::cuda::DeviceMemory2D::DeviceMemory2D ( int  rows_arg,
int  colsBytes_arg,
void *  data_arg,
size_t  step_arg 
)

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

Parameters
rows_argnumber of rows
colsBytes_argwidth of the buffer in bytes
data_argpointer to buffer
stepBytes_argstride between two consecutive rows in bytes

Definition at line 152 of file device_memory.cpp.

◆ DeviceMemory2D() [4/4]

kfusion::cuda::DeviceMemory2D::DeviceMemory2D ( const DeviceMemory2D other_arg)

Copy constructor. Just increments reference counter.

Definition at line 158 of file device_memory.cpp.

Member Function Documentation

◆ colsBytes()

int kfusion::cuda::DeviceMemory2D::colsBytes ( ) const

Returns number of bytes in each row.

Definition at line 256 of file device_memory.cpp.

◆ copyTo()

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

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

Parameters
other_argdestination container

Definition at line 220 of file device_memory.cpp.

◆ create()

void kfusion::cuda::DeviceMemory2D::create ( int  rows_arg,
int  colsBytes_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
ptr_argnumber of rows to allocate
sizeBytes_argwidth of the buffer in bytes

Definition at line 183 of file device_memory.cpp.

◆ download()

void kfusion::cuda::DeviceMemory2D::download ( void *  host_ptr_arg,
size_t  host_step_arg 
) const

Downloads data from internal buffer to CPU memory. User is resposible for correct host buffer size.

Parameters
host_ptr_argpointer to host buffer to download
host_step_argstride between two consecutive rows in bytes for host buffer

Definition at line 239 of file device_memory.cpp.

◆ empty()

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

Returns true if unallocated otherwise false.

Definition at line 255 of file device_memory.cpp.

◆ operator PtrStep< U >()

template<class U >
kfusion::cuda::DeviceMemory2D::operator PtrStep< U > ( ) const

Conversion to PtrStep for passing to kernel functions.

◆ operator PtrStepSz< U >()

template<class U >
kfusion::cuda::DeviceMemory2D::operator PtrStepSz< U > ( ) const

Conversion to PtrStepSz for passing to kernel functions.

◆ operator=()

kfusion::cuda::DeviceMemory2D & kfusion::cuda::DeviceMemory2D::operator= ( const DeviceMemory2D other_arg)

Assigment operator. Just increments reference counter.

Definition at line 165 of file device_memory.cpp.

◆ ptr() [1/2]

template<class T >
T * kfusion::cuda::DeviceMemory2D::ptr ( int  y_arg = 0)

Returns pointer to given row in internal buffer.

Parameters
y_argrow index

Definition at line 239 of file device_memory.hpp.

◆ ptr() [2/2]

template<class T >
const T * kfusion::cuda::DeviceMemory2D::ptr ( int  y_arg = 0) const

Returns constant pointer to given row in internal buffer.

Parameters
y_argrow index

Definition at line 240 of file device_memory.hpp.

◆ release()

void kfusion::cuda::DeviceMemory2D::release ( )

Decrements reference counter and releases internal buffer if needed.

Definition at line 204 of file device_memory.cpp.

◆ rows()

int kfusion::cuda::DeviceMemory2D::rows ( ) const

Returns number of rows.

Definition at line 257 of file device_memory.cpp.

◆ step()

size_t kfusion::cuda::DeviceMemory2D::step ( ) const

Returns stride between two consecutive rows in bytes for internal buffer. Step is stored always and everywhere in bytes!!!

Definition at line 258 of file device_memory.cpp.

◆ swap()

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

Performs swap of data pointed with another device memory.

Parameters
otherdevice memory to swap with

Definition at line 245 of file device_memory.cpp.

◆ upload()

void kfusion::cuda::DeviceMemory2D::upload ( const void *  host_ptr_arg,
size_t  host_step_arg,
int  rows_arg,
int  colsBytes_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 host buffer to upload
host_step_argstride between two consecutive rows in bytes for host buffer
rows_argnumber of rows to upload
sizeBytes_argwidth of host buffer in bytes

Definition at line 232 of file device_memory.cpp.

Member Data Documentation

◆ colsBytes_

int kfusion::cuda::DeviceMemory2D::colsBytes_
private

Width of the buffer in bytes.

Definition at line 207 of file device_memory.hpp.

◆ data_

void* kfusion::cuda::DeviceMemory2D::data_
private

Device pointer.

Definition at line 201 of file device_memory.hpp.

◆ refcount_

int* kfusion::cuda::DeviceMemory2D::refcount_
private

Pointer to reference counter in CPU memory.

Definition at line 213 of file device_memory.hpp.

◆ rows_

int kfusion::cuda::DeviceMemory2D::rows_
private

Number of rows.

Definition at line 210 of file device_memory.hpp.

◆ step_

size_t kfusion::cuda::DeviceMemory2D::step_
private

Stride between two consecutive rows in bytes for internal buffer. Step is stored always and everywhere in bytes!!!

Definition at line 204 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