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

Base of the GPU data reduction algorithms. More...

#include <ReducerAlgo.hh>

Inherited by Drp::Gpu::CuSZpReducer, Drp::Gpu::CuSzReducer, Drp::Gpu::EipReducer, Drp::Gpu::LcReducer, Drp::Gpu::NoOpReducer, Drp::Gpu::PfplReducer, and Drp::Gpu::SleekReducer.

Public Member Functions

 ReducerAlgo (const Parameters &para, const MemPoolGpu &pool, Detector &det)
 Keep references to the parameters, the memory pool and the detector.
 
virtual ~ReducerAlgo ()
 Does nothing; empty virtual destructor.
 
virtual bool hasGraph () const =0
 Pure virtual: return true if the algorithm is recorded into a CUDA graph with recordGraph().
 
virtual size_t payloadSize () const =0
 Pure virtual: return the largest reduced data size in bytes; Reducer sizes the reduce buffers from it, raising it to maxTrSize less the datagram header if that is larger.
 
virtual void recordGraph (cudaStream_t stream, unsigned *const state, unsigned *const index, float const *const calibBuffers, size_t const calibBufsCnt, uint8_t *const dataBuffers, size_t const dataBufsCnt)=0
 Pure virtual: record into stream, which is being captured, the kernels that reduce calibrated buffer *index (calibBufsCnt floats each) into data buffer *index (dataBufsCnt bytes each).
 
virtual void reduce (cudaGraphExec_t, cudaStream_t, unsigned index, size_t *dataSize, unsigned *retCode)=0
 Pure virtual: run the reduction of buffer index on stream (launching graph if the algorithm uses one) and return the reduced size and an error code through dataSize and retCode, possibly by asynchronous copies on stream.
 
virtual int configure (const nlohmann::json &configureMsg, const nlohmann::json &connectMsg, size_t collectionId)=0
 Pure virtual: configure the algorithm from the Configure and Connect messages (per the code comment, the configDb configuration); return non-zero on failure.
 
virtual unsigned configure (XtcData::Xtc &, const void *bufEnd)=0
 Pure virtual: add the names (descriptions) of the reduced data to xtc, without going past bufEnd (per the code comment); return non-zero on failure.
 
virtual void event (XtcData::Xtc &, const void *bufEnd, unsigned dataSize)
 Describe dataSize of reduced data in the event xtc (per the code comment, fill the xtc data description); does nothing in this base class.
 

Protected Attributes

const Parameters & m_para
 
const MemPoolGpu & m_pool
 
Detector & m_det
 

Detailed Description

Base of the GPU data reduction algorithms.

Each one is built as a shared library whose name is lib, the reducer kwarg and .so; Reducer loads it and calls createReducer() once per worker.

Constructor & Destructor Documentation

◆ ReducerAlgo()

Drp::Gpu::ReducerAlgo::ReducerAlgo ( const Parameters &  para,
const MemPoolGpu &  pool,
Detector &  det 
)
inline

Keep references to the parameters, the memory pool and the detector.

◆ ~ReducerAlgo()

virtual Drp::Gpu::ReducerAlgo::~ReducerAlgo ( )
inlinevirtual

Does nothing; empty virtual destructor.

Member Function Documentation

◆ configure() [1/2]

virtual int Drp::Gpu::ReducerAlgo::configure ( const nlohmann::json &  configureMsg,
const nlohmann::json &  connectMsg,
size_t  collectionId 
)
pure virtual

Pure virtual: configure the algorithm from the Configure and Connect messages (per the code comment, the configDb configuration); return non-zero on failure.

Implemented in Drp::Gpu::CuSZpReducer, Drp::Gpu::CuSzReducer, Drp::Gpu::EipReducer, Drp::Gpu::LcReducer, Drp::Gpu::NoOpReducer, Drp::Gpu::PfplReducer, and Drp::Gpu::SleekReducer.

◆ configure() [2/2]

virtual unsigned Drp::Gpu::ReducerAlgo::configure ( XtcData::Xtc &  ,
const void *  bufEnd 
)
pure virtual

Pure virtual: add the names (descriptions) of the reduced data to xtc, without going past bufEnd (per the code comment); return non-zero on failure.

Implemented in Drp::Gpu::CuSZpReducer, Drp::Gpu::CuSzReducer, Drp::Gpu::EipReducer, Drp::Gpu::LcReducer, Drp::Gpu::NoOpReducer, Drp::Gpu::PfplReducer, and Drp::Gpu::SleekReducer.

◆ event()

virtual void Drp::Gpu::ReducerAlgo::event ( XtcData::Xtc &  ,
const void *  bufEnd,
unsigned  dataSize 
)
inlinevirtual

Describe dataSize of reduced data in the event xtc (per the code comment, fill the xtc data description); does nothing in this base class.

Reimplemented in Drp::Gpu::CuSZpReducer, Drp::Gpu::CuSzReducer, Drp::Gpu::EipReducer, Drp::Gpu::LcReducer, Drp::Gpu::NoOpReducer, Drp::Gpu::PfplReducer, and Drp::Gpu::SleekReducer.

◆ hasGraph()

virtual bool Drp::Gpu::ReducerAlgo::hasGraph ( ) const
pure virtual

Pure virtual: return true if the algorithm is recorded into a CUDA graph with recordGraph().

Reducer checks the first instance to choose device ring queues and graphs (true) or host queues (false), and calls the configure() overloads only when it is true.

Implemented in Drp::Gpu::CuSZpReducer, Drp::Gpu::CuSzReducer, Drp::Gpu::EipReducer, Drp::Gpu::LcReducer, Drp::Gpu::NoOpReducer, Drp::Gpu::PfplReducer, and Drp::Gpu::SleekReducer.

◆ payloadSize()

virtual size_t Drp::Gpu::ReducerAlgo::payloadSize ( ) const
pure virtual

Pure virtual: return the largest reduced data size in bytes; Reducer sizes the reduce buffers from it, raising it to maxTrSize less the datagram header if that is larger.

Implemented in Drp::Gpu::CuSZpReducer, Drp::Gpu::CuSzReducer, Drp::Gpu::EipReducer, Drp::Gpu::LcReducer, Drp::Gpu::NoOpReducer, Drp::Gpu::PfplReducer, and Drp::Gpu::SleekReducer.

◆ recordGraph()

virtual void Drp::Gpu::ReducerAlgo::recordGraph ( cudaStream_t  stream,
unsigned *const  state,
unsigned *const  index,
float const *const  calibBuffers,
size_t const  calibBufsCnt,
uint8_t *const  dataBuffers,
size_t const  dataBufsCnt 
)
pure virtual

Pure virtual: record into stream, which is being captured, the kernels that reduce calibrated buffer *index (calibBufsCnt floats each) into data buffer *index (dataBufsCnt bytes each).

As NoOpReducer and the Reducer kernels show, the kernels act when *state is 1, store the reduced size in the size_t just before the data, and set *state to 2.

Implemented in Drp::Gpu::CuSZpReducer, Drp::Gpu::CuSzReducer, Drp::Gpu::EipReducer, Drp::Gpu::NoOpReducer, Drp::Gpu::PfplReducer, Drp::Gpu::SleekReducer, and Drp::Gpu::LcReducer.

◆ reduce()

virtual void Drp::Gpu::ReducerAlgo::reduce ( cudaGraphExec_t  ,
cudaStream_t  ,
unsigned  index,
size_t *  dataSize,
unsigned *  retCode 
)
pure virtual

Pure virtual: run the reduction of buffer index on stream (launching graph if the algorithm uses one) and return the reduced size and an error code through dataSize and retCode, possibly by asynchronous copies on stream.

Called only by Reducer worker threads, which exist in builds with HOST_LAUNCHED_REDUCERS.

Implemented in Drp::Gpu::CuSZpReducer, Drp::Gpu::CuSzReducer, Drp::Gpu::EipReducer, Drp::Gpu::LcReducer, Drp::Gpu::NoOpReducer, Drp::Gpu::PfplReducer, and Drp::Gpu::SleekReducer.

Member Data Documentation

◆ m_det

Detector& Drp::Gpu::ReducerAlgo::m_det
protected

◆ m_para

const Parameters& Drp::Gpu::ReducerAlgo::m_para
protected

◆ m_pool

const MemPoolGpu& Drp::Gpu::ReducerAlgo::m_pool
protected

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