lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Drp::Gpu::RingIndexHtoD Class Reference

Lock-free ring of buffer indices with one host producer (push()) and one device consumer (pop()). More...

#include <RingIndex_HtoD.hh>

Public Member Functions

__host__ RingIndexHtoD (const unsigned capacity, bool initEmpty=true)
 Allocate the pinned head and tail words.
 
__host__ ~RingIndexHtoD ()
 Free the pinned head and tail words.
 
__host__ bool push (unsigned index) const
 Move head forward when not full.
 
__device__ bool pop (unsigned *const __restrict__ index) const
 Return current tail when not empty.
 
__host__ __device__ unsigned head () const
 Return the head, the next position to be pushed.
 
__host__ __device__ unsigned tail () const
 Return the tail, the next position to be popped.
 
__host__ __device__ unsigned occupancy () const
 Return the number of entries (head minus tail, modulo the capacity).
 
__host__ __device__ size_t size () const
 Return the capacity.
 
__host__ void reset (bool initEmpty=true)
 Set the head to 0, or to capacity - 1 if initEmpty is false, and the tail to 0; not synchronized with the device.
 

Detailed Description

Lock-free ring of buffer indices with one host producer (push()) and one device consumer (pop()).

Only the head and tail counters are stored, in pinned host memory, so the popped value is the tail position itself; one slot always stays empty. Used by Reader for its pebble queue.

Constructor & Destructor Documentation

◆ RingIndexHtoD()

__host__ Drp::Gpu::RingIndexHtoD::RingIndexHtoD ( const unsigned  capacity,
bool  initEmpty = true 
)
inline

Allocate the pinned head and tail words.

The ring starts empty, or holding capacity - 1 entries if initEmpty is false; asserts that capacity is a power of 2.

◆ ~RingIndexHtoD()

__host__ Drp::Gpu::RingIndexHtoD::~RingIndexHtoD ( )
inline

Free the pinned head and tail words.

Member Function Documentation

◆ head()

__host__ __device__ unsigned Drp::Gpu::RingIndexHtoD::head ( ) const
inline

Return the head, the next position to be pushed.

◆ occupancy()

__host__ __device__ unsigned Drp::Gpu::RingIndexHtoD::occupancy ( ) const
inline

Return the number of entries (head minus tail, modulo the capacity).

◆ pop()

__device__ bool Drp::Gpu::RingIndexHtoD::pop ( unsigned *const __restrict__  index) const
inline

Return current tail when not empty.

◆ push()

__host__ bool Drp::Gpu::RingIndexHtoD::push ( unsigned  index) const
inline

Move head forward when not full.

◆ reset()

__host__ void Drp::Gpu::RingIndexHtoD::reset ( bool  initEmpty = true)
inline

Set the head to 0, or to capacity - 1 if initEmpty is false, and the tail to 0; not synchronized with the device.

◆ size()

__host__ __device__ size_t Drp::Gpu::RingIndexHtoD::size ( ) const
inline

Return the capacity.

◆ tail()

__host__ __device__ unsigned Drp::Gpu::RingIndexHtoD::tail ( ) const
inline

Return the tail, the next position to be popped.


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