Public Types | Public Member Functions | List of all members
kfusion::cuda::DeviceArray< T > Class Template Reference

DeviceArray class More...

#include <device_array.hpp>

Inheritance diagram for kfusion::cuda::DeviceArray< T >:
Inheritance graph
[legend]

Public Types

enum  { elem_size = sizeof(T) }
 Element size. More...
 
typedef T type
 Element type. More...
 

Public Member Functions

void copyTo (DeviceArray &other) const
 Performs data copying. If destination size differs it will be reallocated. More...
 
void create (size_t size)
 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...
 
 DeviceArray ()
 Empty constructor. More...
 
 DeviceArray (size_t size)
 Allocates internal buffer in GPU memory. More...
 
 DeviceArray (T *ptr, size_t size)
 Initializes with user allocated buffer. Reference counting is disabled in this case. More...
 
 DeviceArray (const DeviceArray &other)
 Copy constructor. Just increments reference counter. More...
 
void download (T *host_ptr) const
 Downloads data from internal buffer to CPU memory. More...
 
template<typename A >
void download (std::vector< T, A > &data) const
 Downloads data from internal buffer to CPU memory. More...
 
 operator const T * () const
 Returns const pointer for internal buffer in GPU memory. More...
 
 operator T* ()
 Returns pointer for internal buffer in GPU memory. More...
 
DeviceArrayoperator= (const DeviceArray &other)
 Assigment operator. Just increments reference counter. More...
 
T * ptr ()
 Returns pointer for internal buffer in GPU memory. More...
 
const T * ptr () const
 Returns const pointer for internal buffer in GPU memory. More...
 
void release ()
 Decrements reference counter and releases internal buffer if needed. More...
 
size_t size () const
 Returns size in elements. More...
 
void swap (DeviceArray &other_arg)
 Performs swap of data pointed with another device array. More...
 
void upload (const T *host_ptr, size_t size)
 Uploads data to internal buffer in GPU memory. It calls create() inside to ensure that intenal buffer size is enough. More...
 
template<class A >
void upload (const std::vector< T, A > &data)
 Uploads data to internal buffer in GPU memory. It calls create() inside to ensure that intenal buffer size is enough. More...
 
- Public Member Functions inherited from kfusion::cuda::DeviceMemory
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...
 

Detailed Description

template<class T>
class kfusion::cuda::DeviceArray< T >

DeviceArray class

Note
Typed container for GPU memory with reference counting.
Author
Anatoly Baksheev

Definition at line 20 of file device_array.hpp.

Member Typedef Documentation

◆ type

template<class T>
typedef T kfusion::cuda::DeviceArray< T >::type

Element type.

Definition at line 24 of file device_array.hpp.

Member Enumeration Documentation

◆ anonymous enum

template<class T>
anonymous enum

Element size.

Enumerator
elem_size 

Definition at line 27 of file device_array.hpp.

Constructor & Destructor Documentation

◆ DeviceArray() [1/4]

template<class T >
kfusion::cuda::DeviceArray< T >::DeviceArray ( )
inline

Empty constructor.

Definition at line 234 of file device_array.hpp.

◆ DeviceArray() [2/4]

template<class T >
kfusion::cuda::DeviceArray< T >::DeviceArray ( size_t  size)
inline

Allocates internal buffer in GPU memory.

Parameters
size_tnumber of elements to allocate

Definition at line 235 of file device_array.hpp.

◆ DeviceArray() [3/4]

template<class T>
kfusion::cuda::DeviceArray< T >::DeviceArray ( T *  ptr,
size_t  size 
)
inline

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

Parameters
ptrpointer to buffer
sizeelemens number

Definition at line 236 of file device_array.hpp.

◆ DeviceArray() [4/4]

template<class T>
kfusion::cuda::DeviceArray< T >::DeviceArray ( const DeviceArray< T > &  other)
inline

Copy constructor. Just increments reference counter.

Definition at line 237 of file device_array.hpp.

Member Function Documentation

◆ copyTo()

template<class T >
void kfusion::cuda::DeviceArray< T >::copyTo ( DeviceArray< T > &  other) const
inline

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

Parameters
other_argdestination container

Definition at line 246 of file device_array.hpp.

◆ create()

template<class T >
void kfusion::cuda::DeviceArray< T >::create ( size_t  size)
inline

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
sizeelemens number

Definition at line 241 of file device_array.hpp.

◆ download() [1/2]

template<class T>
void kfusion::cuda::DeviceArray< T >::download ( T *  host_ptr) const
inline

Downloads data from internal buffer to CPU memory.

Parameters
host_ptr_argpointer to buffer to download

Definition at line 250 of file device_array.hpp.

◆ download() [2/2]

template<class T>
template<class A >
void kfusion::cuda::DeviceArray< T >::download ( std::vector< T, A > &  data) const
inline

Downloads data from internal buffer to CPU memory.

Parameters
datahost vector to download to

Definition at line 263 of file device_array.hpp.

◆ operator const T *()

template<class T >
kfusion::cuda::DeviceArray< T >::operator const T * ( ) const
inline

Returns const pointer for internal buffer in GPU memory.

Definition at line 256 of file device_array.hpp.

◆ operator T*()

template<class T >
kfusion::cuda::DeviceArray< T >::operator T* ( )
inline

Returns pointer for internal buffer in GPU memory.

Definition at line 255 of file device_array.hpp.

◆ operator=()

template<class T >
kfusion::cuda::DeviceArray< T > & kfusion::cuda::DeviceArray< T >::operator= ( const DeviceArray< T > &  other)
inline

Assigment operator. Just increments reference counter.

Definition at line 238 of file device_array.hpp.

◆ ptr() [1/2]

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

Returns pointer for internal buffer in GPU memory.

Definition at line 259 of file device_array.hpp.

◆ ptr() [2/2]

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

Returns const pointer for internal buffer in GPU memory.

Definition at line 260 of file device_array.hpp.

◆ release()

template<class T >
void kfusion::cuda::DeviceArray< T >::release ( )
inline

Decrements reference counter and releases internal buffer if needed.

Definition at line 243 of file device_array.hpp.

◆ size()

template<class T >
size_t kfusion::cuda::DeviceArray< T >::size ( ) const
inline

Returns size in elements.

Definition at line 257 of file device_array.hpp.

◆ swap()

template<class T >
void kfusion::cuda::DeviceArray< T >::swap ( DeviceArray< T > &  other_arg)

Performs swap of data pointed with another device array.

Parameters
otherdevice array to swap with

Definition at line 253 of file device_array.hpp.

◆ upload() [1/2]

template<class T>
void kfusion::cuda::DeviceArray< T >::upload ( const T *  host_ptr,
size_t  size 
)
inline

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
sizeelemens number

Definition at line 248 of file device_array.hpp.

◆ upload() [2/2]

template<class T>
template<class A >
void kfusion::cuda::DeviceArray< T >::upload ( const std::vector< T, A > &  data)
inline

Uploads data to internal buffer in GPU memory. It calls create() inside to ensure that intenal buffer size is enough.

Parameters
datahost vector to upload from

Definition at line 262 of file device_array.hpp.


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


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