Speclib  0.1.2
The library for writing better CUDA libraries
sp::LazyGpuBuffer< T, Zero > Class Template Reference

A buffer that is lazily-allocated using double-checked locking. More...

#include <LazyGpuBuffer.hpp>

Public Member Functions

 LazyGpuBuffer (Stream &s, int bufferSize)
 Initialise a LazyGpuBuffer that will be the given size when eventually allocated, associated with a stream. More...
 
int size ()
 
__device T * get ()
 Get the buffer. More...
 

Detailed Description

template<typename T, bool Zero>
class sp::LazyGpuBuffer< T, Zero >

A buffer that is lazily-allocated using double-checked locking.

Template Parameters
ZeroZero-fill the buffer when it is allocated.

Constructor & Destructor Documentation

◆ LazyGpuBuffer()

template<typename T , bool Zero>
sp::LazyGpuBuffer< T, Zero >::LazyGpuBuffer ( Stream s,
int  bufferSize 
)

Initialise a LazyGpuBuffer that will be the given size when eventually allocated, associated with a stream.

Member Function Documentation

◆ get()

template<typename T , bool Zero>
__device T * sp::LazyGpuBuffer< T, Zero >::get ( )

Get the buffer.

If the buffer hasn't been allocated yet, it is allocated and possibly zero-initialised. It's very cheap after the first time (which is quite slow).