Template Class DataBuffer

Class Documentation

template<class GPUDataT, class DevTagT = int>
class DataBuffer

Data storage class for CUDA memory. Maintains an associated stream and device ID taken during time of allocation.

Template Parameters
  • GPUDataT – GPU data type.

  • DevTagT – Device tag index type.

Public Types

using type = GPUDataT

Construct a new DataBuffer object.

Param length

Number of elements in data buffer.

Param device_id

Associated device ID. Must be cudaSetDevice compatible.

Param stream_id

Associated stream ID. Must be cudaSetStream compatible.

Param alloc_memory

Indicate whether to allocate the memory for the buffer. Defaults to true

Public Functions

inline DataBuffer(std::size_t length, int device_id = 0, cudaStream_t stream_id = 0, bool alloc_memory = true)
inline DataBuffer(std::size_t length, const DevTag<DevTagT> &dev, bool alloc_memory = true)
inline DataBuffer(std::size_t length, DevTag<DevTagT> &&dev, bool alloc_memory = true)
DataBuffer() = delete
inline DataBuffer &operator=(const DataBuffer &other)
inline DataBuffer &operator=(DataBuffer &&other)
inline virtual ~DataBuffer()
inline void zeroInit()

Zero-initialize the GPU buffer.

inline auto getData() -> GPUDataT*
inline auto getData() const -> const GPUDataT*
inline auto getLength() const
inline auto getStream() const -> cudaStream_t

Get the CUDA stream for the given object.

Returns

const cudaStream_t&

inline auto getDevice() const -> int
inline auto getDevTag() const -> const DevTag<DevTagT>&
inline void CopyGpuDataToGpu(const GPUDataT *gpu_in, std::size_t length, bool async = false)

Copy data from another GPU memory block to here.

inline void CopyGpuDataToGpu(const DataBuffer &buffer, bool async = false)

Copy data from another GPU memory block to here.

template<class HostDataT = GPUDataT>
inline void CopyHostDataToGpu(const HostDataT *host_in, std::size_t length, bool async = false)

Explicitly copy data from host memory to GPU device.

template<class HostDataT = GPUDataT>
inline void CopyGpuDataToHost(HostDataT *host_out, std::size_t length, bool async = false) const

Explicitly copy data from GPU device to host memory.