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

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

#include <RingIndex_DtoH.hh>

Public Member Functions

__host__ RingIndexDtoH (const unsigned capacity)
 Allocate the pinned head and tail words and start empty; asserts that capacity is a power of 2.
 
__host__ ~RingIndexDtoH ()
 Free the pinned head and tail words.
 
__device__ bool push (unsigned index) const
 Move head forward when not full.
 
__host__ bool pop (unsigned *index) const
 Return current head 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 ()
 Set the head and tail to 0 (empty); not synchronized with the device.
 

Detailed Description

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

Head and tail are stored in pinned host memory; one slot always stays empty. Used for the TrgInpGen queue.

Constructor & Destructor Documentation

◆ RingIndexDtoH()

__host__ Drp::Gpu::RingIndexDtoH::RingIndexDtoH ( const unsigned  capacity)
inline

Allocate the pinned head and tail words and start empty; asserts that capacity is a power of 2.

◆ ~RingIndexDtoH()

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

Free the pinned head and tail words.

Member Function Documentation

◆ head()

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

Return the head, the next position to be pushed.

◆ occupancy()

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

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

◆ pop()

__host__ bool Drp::Gpu::RingIndexDtoH::pop ( unsigned *  index) const
inline

Return current head when not empty.

◆ push()

__device__ bool Drp::Gpu::RingIndexDtoH::push ( unsigned  index) const
inline

Move head forward when not full.

◆ reset()

__host__ void Drp::Gpu::RingIndexDtoH::reset ( )
inline

Set the head and tail to 0 (empty); not synchronized with the device.

◆ size()

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

Return the capacity.

◆ tail()

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

Return the tail, the next position to be popped.


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