|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
Runs the data reduction on the GPU for PGPDrp: loads the reducer library named by the reducer kwarg, creates one ReducerAlgo per worker, and passes buffer indices in and ReducerTuple results out through per-worker queues. More...
#include <Reducer.hh>
Public Member Functions | |
| Reducer (const Parameters &, MemPoolGpu &, Detector &, cudaExecutionContext_t green_ctx, const std::atomic< bool > &terminate_h, const cuda::std::atomic< unsigned > &terminate_d) | |
| Create one stream per worker in green_ctx and load the algorithms (aborting on failure). | |
| ~Reducer () | |
| Free the per-worker device and pinned memory, stop the host queues and threads, destroy the graphs and algorithms, close the library, and destroy the reduce buffers and streams. | |
| int | setupMetrics (const std::shared_ptr< Pds::MetricExporter >, std::map< std::string, std::string > &labels) |
| Add the per-worker DRP_redState, DRP_inpWtCtr, DRP_outWtCtr, DRP_inputQueue and DRP_outputQueue metrics and DRP_reduceTime to exporter; returns 0. | |
| int | configure (const nlohmann::json &configureMsg, const nlohmann::json &connectMsg, size_t collectionId) |
| If the algorithms use graphs, call ReducerAlgo::configure() with the Configure and Connect messages on every instance. | |
| bool | setup (XtcData::Xtc &xtc, const void *be) |
| If the algorithms use graphs, call ReducerAlgo::configure(xtc, be) on every instance and record, instantiate and upload one graph per worker. | |
| bool | startup () |
| Launch the worker graphs if the algorithms use them; in builds with HOST_LAUNCHED_REDUCERS, start one host worker thread per worker instead. | |
| void | shutdown () |
| Shut down the host input and output queues if the algorithms do not use graphs; otherwise does nothing. | |
| void | dump () const |
| Print the head and tail of each worker's input and output ring queues if the algorithms use graphs. | |
| bool | start (unsigned worker, unsigned index) |
| Queue buffer index for worker. | |
| bool | receive (unsigned worker, ReducerTuple *items) |
| Pop the next result of worker into items. | |
| void | event (XtcData::Xtc &xtc, const void *bufEnd, size_t dataSize) |
| Let the first algorithm instance describe dataSize of reduced data in xtc (ReducerAlgo::event()); does nothing if no algorithm is loaded. | |
Runs the data reduction on the GPU for PGPDrp: loads the reducer library named by the reducer kwarg, creates one ReducerAlgo per worker, and passes buffer indices in and ReducerTuple results out through per-worker queues.
With graph algorithms, and without HOST_LAUNCHED_REDUCERS, each worker is a self-relaunching CUDA graph fed by device ring queues.
| Drp::Gpu::Reducer::Reducer | ( | const Parameters & | , |
| MemPoolGpu & | , | ||
| Detector & | , | ||
| cudaExecutionContext_t | green_ctx, | ||
| const std::atomic< bool > & | terminate_h, | ||
| const cuda::std::atomic< unsigned > & | terminate_d | ||
| ) |
Create one stream per worker in green_ctx and load the algorithms (aborting on failure).
Then create the reduce buffers (header space plus the larger of payloadSize() and maxTrSize less the header) and the per-worker queues, state and return-code words and metric counters.
| Drp::Gpu::Reducer::~Reducer | ( | ) |
Free the per-worker device and pinned memory, stop the host queues and threads, destroy the graphs and algorithms, close the library, and destroy the reduce buffers and streams.
| int Drp::Gpu::Reducer::configure | ( | const nlohmann::json & | configureMsg, |
| const nlohmann::json & | connectMsg, | ||
| size_t | collectionId | ||
| ) |
If the algorithms use graphs, call ReducerAlgo::configure() with the Configure and Connect messages on every instance.
Returns -1 if one fails, else 0.
| void Drp::Gpu::Reducer::dump | ( | ) | const |
Print the head and tail of each worker's input and output ring queues if the algorithms use graphs.
|
inline |
Let the first algorithm instance describe dataSize of reduced data in xtc (ReducerAlgo::event()); does nothing if no algorithm is loaded.
|
inline |
Pop the next result of worker into items.
With the device ring queue, returns false if none is ready; with a host queue, blocks until one arrives and returns false after shutdown.
| bool Drp::Gpu::Reducer::setup | ( | XtcData::Xtc & | xtc, |
| const void * | be | ||
| ) |
If the algorithms use graphs, call ReducerAlgo::configure(xtc, be) on every instance and record, instantiate and upload one graph per worker.
Returns true on failure, else false.
| int Drp::Gpu::Reducer::setupMetrics | ( | const std::shared_ptr< Pds::MetricExporter > | , |
| std::map< std::string, std::string > & | labels | ||
| ) |
Add the per-worker DRP_redState, DRP_inpWtCtr, DRP_outWtCtr, DRP_inputQueue and DRP_outputQueue metrics and DRP_reduceTime to exporter; returns 0.
| void Drp::Gpu::Reducer::shutdown | ( | ) |
Shut down the host input and output queues if the algorithms do not use graphs; otherwise does nothing.
|
inline |
Queue buffer index for worker.
Returns false only when the device input ring queue is full (graph algorithms without HOST_LAUNCHED_REDUCERS); host queue pushes return true.
| bool Drp::Gpu::Reducer::startup | ( | ) |
Launch the worker graphs if the algorithms use them; in builds with HOST_LAUNCHED_REDUCERS, start one host worker thread per worker instead.
Returns false.