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

Receives the FPGA DMA buffers on the GPU. More...

#include <Reader.hh>

Public Member Functions

 Reader (const Parameters &, MemPoolGpu &, Detector &, size_t trgPrimitiveSize, const cudaExecutionContext_t &, const cuda::std::atomic< unsigned > &terminate_d)
 Read the nReaders kwarg (default 1; aborts unless it is a power of 2 that divides the DMA buffer count).
 
 ~Reader ()
 Destroy the reader graphs and free what the constructor allocated, including the host write buffers.
 
int setupMetrics (const std::shared_ptr< Pds::MetricExporter >, std::map< std::string, std::string > &labels)
 Add the per-reader DRP_readerState, DRP_pblWtCtr, DRP_dmaWtCtr, DRP_rdrFwd and DRP_rdrQueOcc metrics and DRP_pblQueOcc to exporter; returns 0.
 
bool setup ()
 Record, instantiate and upload one graph per reader.
 
bool startup ()
 Clear the handshake word of every DMA buffer and give it to the FPGA (with gpuSetWriteEn() first in HOST_REARMS_DMA builds), reset the DMA buffer index and launch the reader graphs.
 
void freeDma (PGPEvent *)
 Clear the event mask and advance the pebble queue head so that the readers can reuse a pebble buffer; RingIndexHtoD::push() ignores the buffer index passed to it.
 
void flush ()
 Free the DMA buffers of all events whose mask is still set, then flush the pebble pool.
 
auto & pool () const
 Return the memory pool.
 
auto & readerQueues () const
 Return the per-reader queues (host and device pointers).
 
auto nReaders () const
 Return the number of reader streams.
 

Detailed Description

Receives the FPGA DMA buffers on the GPU.

Each of nReaders streams runs a self-relaunching CUDA graph that, in turn with the other streams, waits for a DMA, takes the next pebble index, copies the DMA descriptor and TimingHeader to the pinned host write buffer and calibrates the payload into the calibration buffer. It then passes the buffer on through its reader queue and gives the DMA buffer back to the FPGA.

Constructor & Destructor Documentation

◆ Reader()

Drp::Gpu::Reader::Reader ( const Parameters &  ,
MemPoolGpu &  ,
Detector &  ,
size_t  trgPrimitiveSize,
const cudaExecutionContext_t &  ,
const cuda::std::atomic< unsigned > &  terminate_d 
)

Read the nReaders kwarg (default 1; aborts unless it is a power of 2 that divides the DMA buffer count).

Create the per-reader indices, queues, streams (in green_ctx, lowest priority), states and metric counters, the pebble queue (starting full) and the host write buffers (DMA descriptor, TimingHeader and trgPrimitiveSize bytes each).

◆ ~Reader()

Drp::Gpu::Reader::~Reader ( )

Destroy the reader graphs and free what the constructor allocated, including the host write buffers.

Member Function Documentation

◆ flush()

void Drp::Gpu::Reader::flush ( )

Free the DMA buffers of all events whose mask is still set, then flush the pebble pool.

◆ freeDma()

void Drp::Gpu::Reader::freeDma ( PGPEvent *  )

Clear the event mask and advance the pebble queue head so that the readers can reuse a pebble buffer; RingIndexHtoD::push() ignores the buffer index passed to it.

◆ nReaders()

auto Drp::Gpu::Reader::nReaders ( ) const
inline

Return the number of reader streams.

◆ pool()

auto & Drp::Gpu::Reader::pool ( ) const
inline

Return the memory pool.

◆ readerQueues()

auto & Drp::Gpu::Reader::readerQueues ( ) const
inline

Return the per-reader queues (host and device pointers).

◆ setup()

bool Drp::Gpu::Reader::setup ( )

Record, instantiate and upload one graph per reader.

Returns true on failure, else false.

◆ setupMetrics()

int Drp::Gpu::Reader::setupMetrics ( const std::shared_ptr< Pds::MetricExporter >  ,
std::map< std::string, std::string > &  labels 
)

Add the per-reader DRP_readerState, DRP_pblWtCtr, DRP_dmaWtCtr, DRP_rdrFwd and DRP_rdrQueOcc metrics and DRP_pblQueOcc to exporter; returns 0.

◆ startup()

bool Drp::Gpu::Reader::startup ( )

Clear the handshake word of every DMA buffer and give it to the FPGA (with gpuSetWriteEn() first in HOST_REARMS_DMA builds), reset the DMA buffer index and launch the reader graphs.

Returns true only if gpuSetWriteEn() fails, else false.


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