lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Drp::Gpu::RingQueueDtoD< T > Class Template Reference

Lock-free ring of values of type T with one producer on the GPU (push()) and one consumer on the GPU (pop()). More...

#include <RingQueue_DtoD.hh>

Public Member Functions

__host__ RingQueueDtoD (const unsigned capacity)
 Allocate the pinned head and tail words and a pinned ring of capacity values, starting empty; asserts that capacity is a power of 2.
 
__host__ ~RingQueueDtoD ()
 Free the pinned ring, tail and head.
 
__device__ bool push (const T &value) const
 Store value at head and advance when not full.
 
__device__ bool pop (T *const __restrict__ value) const
 Fetch value at tail and advance when not empty.
 
__host__ __device__ unsigned head () const
 Return the head, the next slot to be pushed.
 
__host__ __device__ unsigned tail () const
 Return the tail, the next slot to be popped.
 
__host__ __device__ unsigned occupancy () const
 Return the number of values queued (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 other side.
 

Detailed Description

template<typename T>
class Drp::Gpu::RingQueueDtoD< T >

Lock-free ring of values of type T with one producer on the GPU (push()) and one consumer on the GPU (pop()).

The values and the head and tail counters are in pinned host memory; one slot always stays empty. Not used elsewhere in drpGpu.

Constructor & Destructor Documentation

◆ RingQueueDtoD()

template<typename T >
__host__ Drp::Gpu::RingQueueDtoD< T >::RingQueueDtoD ( const unsigned  capacity)
inline

Allocate the pinned head and tail words and a pinned ring of capacity values, starting empty; asserts that capacity is a power of 2.

◆ ~RingQueueDtoD()

template<typename T >
__host__ Drp::Gpu::RingQueueDtoD< T >::~RingQueueDtoD ( )
inline

Free the pinned ring, tail and head.

Member Function Documentation

◆ head()

template<typename T >
__host__ __device__ unsigned Drp::Gpu::RingQueueDtoD< T >::head ( ) const
inline

Return the head, the next slot to be pushed.

◆ occupancy()

template<typename T >
__host__ __device__ unsigned Drp::Gpu::RingQueueDtoD< T >::occupancy ( ) const
inline

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

◆ pop()

template<typename T >
__device__ bool Drp::Gpu::RingQueueDtoD< T >::pop ( T *const __restrict__  value) const
inline

Fetch value at tail and advance when not empty.

◆ push()

template<typename T >
__device__ bool Drp::Gpu::RingQueueDtoD< T >::push ( const T &  value) const
inline

Store value at head and advance when not full.

◆ reset()

template<typename T >
__host__ void Drp::Gpu::RingQueueDtoD< T >::reset ( )
inline

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

◆ size()

template<typename T >
__host__ __device__ size_t Drp::Gpu::RingQueueDtoD< T >::size ( ) const
inline

Return the capacity.

◆ tail()

template<typename T >
__host__ __device__ unsigned Drp::Gpu::RingQueueDtoD< T >::tail ( ) const
inline

Return the tail, the next slot to be popped.


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