Tachyon (current)  Current Main Branch
Public Member Functions | Data Fields
CUMemBuf Struct Reference

Several OptiX APIs make use of CUDA driver API pointer types (CUdevicepointer) so it becomes worthwhile to manage these in a templated class supporting easy memory management for vectors of special template types, and simple copies to and from the associated CUDA device. More...

#include <TachyonOptiX.h>

Public Member Functions

void * dptr () const
 
CUdeviceptr cu_dptr () const
 
size_t get_size (void)
 query current buffer size in bytes More...
 
void set_size (size_t newsize)
 (re)allocate buffer of requested size More...
 
void set_size (size_t newsize, cudaStream_t stream)
 (re)allocate buffer of requested size, asynchronously More...
 
void clear_persist_allocation (void)
 clear "used" size to zero, but keep existing device allocation More...
 
void free ()
 free allocated memory More...
 
void free (cudaStream_t stream)
 free allocated memory asynchronously More...
 
template<typename T >
void resize_upload (const std::vector< T > &vecT)
 Combination of a buffer resize with synchronous upload to GPU device memory. More...
 
template<typename T >
void resize_upload (const T *t, size_t cnt)
 Combination of a buffer resize with synchronous upload to GPU device memory. More...
 
template<typename T >
void resize_upload (const std::vector< T > &vecT, cudaStream_t stream)
 Combination of a buffer resize with asynchronous upload to GPU device memory using the caller-provided CUDA stream to enforce ordering requirements. More...
 
template<typename T >
void resize_upload (const T *t, size_t cnt, cudaStream_t stream)
 Combination of a buffer resize with asynchronous upload to GPU device memory using the caller-provided CUDA stream to enforce ordering requirements. More...
 
template<typename T >
void upload (const T *t, size_t cnt)
 Synchronous upload to GPU device memory. More...
 
template<typename T >
void download (T *t, size_t cnt)
 Synchronous download from GPU device memory. More...
 
template<typename T >
void upload (const T *t, size_t cnt, cudaStream_t stream)
 Asynchronous upload to GPU device memory, using the caller-provided CUDA stream to enforce ordering requirements. More...
 
template<typename T >
void download_async (T *t, size_t cnt, cudaStream_t stream)
 Asynchronous download from GPU device memory, using the caller-provided CUDA stream to enforce ordering requirements. More...
 

Data Fields

size_t sz { 0 }
 device memory buffer usage size in bytes More...
 
size_t dmemsz { 0 }
 device memory buffer allocated size in bytes More...
 
void * d_ptr { nullptr }
 pointer to device memory buffer More...
 

Detailed Description

Several OptiX APIs make use of CUDA driver API pointer types (CUdevicepointer) so it becomes worthwhile to manage these in a templated class supporting easy memory management for vectors of special template types, and simple copies to and from the associated CUDA device.

Definition at line 328 of file TachyonOptiX.h.

Member Function Documentation

◆ clear_persist_allocation()

void CUMemBuf::clear_persist_allocation ( void  )
inline

clear "used" size to zero, but keep existing device allocation

Definition at line 424 of file TachyonOptiX.h.

References free(), and sz.

Referenced by TachyonOptiX::destroy_scene().

◆ cu_dptr()

CUdeviceptr CUMemBuf::cu_dptr ( ) const
inline

Definition at line 341 of file TachyonOptiX.h.

References d_ptr, and sz.

Referenced by TachyonOptiX::render().

◆ download()

template<typename T >
void CUMemBuf::download ( T *  t,
size_t  cnt 
)
inline

Synchronous download from GPU device memory.

Definition at line 560 of file TachyonOptiX.h.

References d_ptr.

Referenced by TachyonOptiX::framebuffer_download_rgb4u().

◆ download_async()

template<typename T >
void CUMemBuf::download_async ( T *  t,
size_t  cnt,
cudaStream_t  stream 
)
inline

Asynchronous download from GPU device memory, using the caller-provided CUDA stream to enforce ordering requirements.

Definition at line 583 of file TachyonOptiX.h.

References d_ptr.

◆ dptr()

void* CUMemBuf::dptr ( ) const
inline

Definition at line 333 of file TachyonOptiX.h.

References d_ptr, and sz.

Referenced by TachyonOptiX::framebuffer_clear().

◆ free() [1/2]

void CUMemBuf::free ( )
inline

free allocated memory

Definition at line 433 of file TachyonOptiX.h.

References d_ptr, dmemsz, and sz.

Referenced by clear_persist_allocation(), TachyonOptiX::framebuffer_destroy(), TachyonOptiX::minimize_memory_use(), and set_size().

◆ free() [2/2]

void CUMemBuf::free ( cudaStream_t  stream)
inline

free allocated memory asynchronously

Definition at line 442 of file TachyonOptiX.h.

References d_ptr, dmemsz, and sz.

◆ get_size()

size_t CUMemBuf::get_size ( void  )
inline

query current buffer size in bytes

Definition at line 350 of file TachyonOptiX.h.

References sz.

Referenced by TachyonOptiX::framebuffer_clear(), and TachyonOptiX::render().

◆ resize_upload() [1/4]

template<typename T >
void CUMemBuf::resize_upload ( const std::vector< T > &  vecT)
inline

Combination of a buffer resize with synchronous upload to GPU device memory.

Definition at line 471 of file TachyonOptiX.h.

References set_size(), and upload().

◆ resize_upload() [2/4]

template<typename T >
void CUMemBuf::resize_upload ( const T *  t,
size_t  cnt 
)
inline

Combination of a buffer resize with synchronous upload to GPU device memory.

Definition at line 479 of file TachyonOptiX.h.

References d_ptr, and set_size().

◆ resize_upload() [3/4]

template<typename T >
void CUMemBuf::resize_upload ( const std::vector< T > &  vecT,
cudaStream_t  stream 
)
inline

Combination of a buffer resize with asynchronous upload to GPU device memory using the caller-provided CUDA stream to enforce ordering requirements.

Definition at line 493 of file TachyonOptiX.h.

References set_size(), and upload().

◆ resize_upload() [4/4]

template<typename T >
void CUMemBuf::resize_upload ( const T *  t,
size_t  cnt,
cudaStream_t  stream 
)
inline

Combination of a buffer resize with asynchronous upload to GPU device memory using the caller-provided CUDA stream to enforce ordering requirements.

Definition at line 502 of file TachyonOptiX.h.

References d_ptr, and set_size().

◆ set_size() [1/2]

void CUMemBuf::set_size ( size_t  newsize)
inline

(re)allocate buffer of requested size

Definition at line 355 of file TachyonOptiX.h.

References d_ptr, dmemsz, free(), and sz.

Referenced by TachyonOptiX::framebuffer_resize(), and resize_upload().

◆ set_size() [2/2]

void CUMemBuf::set_size ( size_t  newsize,
cudaStream_t  stream 
)
inline

(re)allocate buffer of requested size, asynchronously

Definition at line 372 of file TachyonOptiX.h.

References d_ptr, dmemsz, free(), and sz.

◆ upload() [1/2]

template<typename T >
void CUMemBuf::upload ( const T *  t,
size_t  cnt 
)
inline

Synchronous upload to GPU device memory.

Definition at line 554 of file TachyonOptiX.h.

References d_ptr.

Referenced by TachyonOptiX::render(), and resize_upload().

◆ upload() [2/2]

template<typename T >
void CUMemBuf::upload ( const T *  t,
size_t  cnt,
cudaStream_t  stream 
)
inline

Asynchronous upload to GPU device memory, using the caller-provided CUDA stream to enforce ordering requirements.

Definition at line 572 of file TachyonOptiX.h.

References d_ptr.

Field Documentation

◆ d_ptr

void* CUMemBuf::d_ptr { nullptr }

pointer to device memory buffer

Definition at line 331 of file TachyonOptiX.h.

Referenced by cu_dptr(), download(), download_async(), dptr(), free(), resize_upload(), set_size(), and upload().

◆ dmemsz

size_t CUMemBuf::dmemsz { 0 }

device memory buffer allocated size in bytes

Definition at line 330 of file TachyonOptiX.h.

Referenced by free(), and set_size().

◆ sz

size_t CUMemBuf::sz { 0 }

device memory buffer usage size in bytes

Definition at line 329 of file TachyonOptiX.h.

Referenced by clear_persist_allocation(), cu_dptr(), dptr(), free(), get_size(), and set_size().


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