gtsam_points
Loading...
Searching...
No Matches
Public Member Functions | List of all members
gtsam_points::CUDABuffer Class Reference

Device buffer for asynchronous data transfer. More...

#include <cuda_buffer.hpp>

Public Member Functions

 CUDABuffer (bool use_pinned_buffer=true)
 
void resize (size_t size, CUstream_st *stream)
 Resize the buffer size. This method only expands the device/host buffers and doesn't shrink them when buffer_size < size.
 
void upload (CUstream_st *stream)
 Upload data from the host pinned buffer to the device buffer.
 
void upload (size_t size, CUstream_st *stream)
 Upload data from the host pinned buffer to the device buffer.
 
void upload (const void *buffer, size_t size, CUstream_st *stream)
 Upload data to the device buffer. If size > buffer_size, the buffers will be resized before uploading.
 
void download (CUstream_st *stream)
 Download data from the device buffer to the pinned host buffer.
 
void download (void *buffer, size_t size, CUstream_st *stream)
 Download data from the device buffer.
 
size_t size () const
 Buffer size.
 
void * host_buffer ()
 Pinned host buffer.
 
void * device_buffer ()
 Pinned device buffer.
 
template<typename T >
void upload (const T *buffer, size_t size, CUstream_st *stream)
 
template<typename T >
void download (T *buffer, size_t size, CUstream_st *stream)
 
template<typename T >
T * host_buffer ()
 
template<typename T >
T * device_buffer ()
 

Detailed Description

Device buffer for asynchronous data transfer.

Note
To enable asynchronous upload/download, use_pinned_buffer needs to be true.

Member Function Documentation

◆ download() [1/2]

void gtsam_points::CUDABuffer::download ( CUstream_st *  stream)

Download data from the device buffer to the pinned host buffer.

Parameters
streamCUDA stream

◆ download() [2/2]

void gtsam_points::CUDABuffer::download ( void *  buffer,
size_t  size,
CUstream_st *  stream 
)

Download data from the device buffer.

Parameters
bufferBuffer to write the downloaded data
sizeBuffer size
streamCUDA stream

◆ host_buffer()

void * gtsam_points::CUDABuffer::host_buffer ( )

Pinned host buffer.

Note
If use_pinned_buffer is false, the pinned host buffer will not be allocated, and this method returns nullptr.

◆ resize()

void gtsam_points::CUDABuffer::resize ( size_t  size,
CUstream_st *  stream 
)

Resize the buffer size. This method only expands the device/host buffers and doesn't shrink them when buffer_size < size.

Parameters
sizeBuffer size
streamCUDA stream

◆ upload() [1/3]

void gtsam_points::CUDABuffer::upload ( const void *  buffer,
size_t  size,
CUstream_st *  stream 
)

Upload data to the device buffer. If size > buffer_size, the buffers will be resized before uploading.

Parameters
bufferInput data
sizeBuffer size
streamCUDA stream

◆ upload() [2/3]

void gtsam_points::CUDABuffer::upload ( CUstream_st *  stream)

Upload data from the host pinned buffer to the device buffer.

Parameters
streamCUDA stream

◆ upload() [3/3]

void gtsam_points::CUDABuffer::upload ( size_t  size,
CUstream_st *  stream 
)

Upload data from the host pinned buffer to the device buffer.

Parameters
sizeData size (must be smaller than buffer_size)
streamCUDA stream

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