lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Pds::Eb::TebContributor Class Reference

Builds batches of input datagrams in a BatchManager region and posts them over libfabric links to the TEBs. More...

#include <TebContributor.hh>

Public Types

using listU32_t = std::list< uint32_t >
 List of free transition buffer indices (one list per TEB link).
 

Public Member Functions

 TebContributor (const TebCtrbParams &, unsigned numBuffers)
 Keep a reference to prms, create the libfabric client and size the pending queue for numBuffers entries.
 
 ~TebContributor ()
 Call shutdown().
 
int resetCounters ()
 Reset the event and batch counters; returns 0.
 
int connect (const std::shared_ptr< MetricExporter > exporter)
 Register metrics with exporter (if non-null), size the link list from prms.addrs, count the builders in prms.builders and connect to all TEBs with linksConnect().
 
int configure ()
 Drain and restart the pending queue, reinitialize the BatchManager for maxInputSize and maxEntries (aborts if maxEntries does not divide the pending queue size evenly), exchange memory-region information with the TEBs via linksConfigure() and refill each link's list of TEB_TR_BUFFERS transition buffer indices.
 
void unconfigure ()
 If running, clear the running flag, join the receiver thread, and dump and shut down the BatchManager and the pending queue; otherwise does nothing.
 
void disconnect ()
 Call unconfigure(), disconnect and drop all links, and set the ID to -1.
 
void startup (EbCtrbInBase &)
 Clear the current batch, reset the counters of this object and of in, set the running flag and start a thread that runs in.receiver(*this, running flag).
 
void shutdown ()
 Call disconnect() (harmless if already done).
 
void process (const Pds::EbDgram *datagram)
 Handle one input datagram.
 
unsigned index (const Pds::EbDgram *datagram) const
 Return the buffer index of dgram: its byte offset from the start of the batch region divided by prms.maxInputSize.
 
void * fetch (unsigned index) const
 Return the buffer address for index, from BatchManager::fetch().
 
void process (unsigned index)
 Call process() on the datagram at buffer index (found with fetch()).
 
bool timeout ()
 If at least BATCH_TIMEOUT (1 ms) has passed since the start time of the current batch, post the batch if one is open and return true; otherwise return false.
 
BatchQueue & pending ()
 Return the time-ordered queue of posted batches and bypassed datagrams.
 

Detailed Description

Builds batches of input datagrams in a BatchManager region and posts them over libfabric links to the TEBs.

A receiver thread runs EbCtrbInBase::receiver() for the results.

Member Typedef Documentation

◆ listU32_t

using Pds::Eb::TebContributor::listU32_t = std::list<uint32_t>

List of free transition buffer indices (one list per TEB link).

Constructor & Destructor Documentation

◆ TebContributor()

Pds::Eb::TebContributor::TebContributor ( const TebCtrbParams &  ,
unsigned  numBuffers 
)

Keep a reference to prms, create the libfabric client and size the pending queue for numBuffers entries.

◆ ~TebContributor()

Pds::Eb::TebContributor::~TebContributor ( )

Call shutdown().

Member Function Documentation

◆ configure()

int Pds::Eb::TebContributor::configure ( )

Drain and restart the pending queue, reinitialize the BatchManager for maxInputSize and maxEntries (aborts if maxEntries does not divide the pending queue size evenly), exchange memory-region information with the TEBs via linksConfigure() and refill each link's list of TEB_TR_BUFFERS transition buffer indices.

Returns 0 or the linksConfigure() error.

◆ connect()

int Pds::Eb::TebContributor::connect ( const std::shared_ptr< MetricExporter >  exporter)

Register metrics with exporter (if non-null), size the link list from prms.addrs, count the builders in prms.builders and connect to all TEBs with linksConnect().

Returns 0 or the first non-zero error code.

◆ disconnect()

void Pds::Eb::TebContributor::disconnect ( )

Call unconfigure(), disconnect and drop all links, and set the ID to -1.

◆ fetch()

void * Pds::Eb::TebContributor::fetch ( unsigned  index) const
inline

Return the buffer address for index, from BatchManager::fetch().

◆ index()

unsigned Pds::Eb::TebContributor::index ( const Pds::EbDgram *  datagram) const
inline

Return the buffer index of dgram: its byte offset from the start of the batch region divided by prms.maxInputSize.

◆ pending()

BatchQueue & Pds::Eb::TebContributor::pending ( )
inline

Return the time-ordered queue of posted batches and bypassed datagrams.

◆ process() [1/2]

void Pds::Eb::TebContributor::process ( const Pds::EbDgram *  datagram)

Handle one input datagram.

If its readout groups include bit prms.partition (the common group, per the code comment), it is appended to the open batch; the batch is posted when it has expired or the datagram is a transition other than SlowUpdate, and non-event datagrams of contractor groups are also sent to the TEBs that did not get the batch. Otherwise the open batch is posted and the datagram is marked EOL and pushed straight onto the pending queue. Aborts if the pending queue overflows. Must not be called concurrently with timeout().

◆ process() [2/2]

void Pds::Eb::TebContributor::process ( unsigned  index)
inline

Call process() on the datagram at buffer index (found with fetch()).

◆ resetCounters()

int Pds::Eb::TebContributor::resetCounters ( )

Reset the event and batch counters; returns 0.

◆ shutdown()

void Pds::Eb::TebContributor::shutdown ( )

Call disconnect() (harmless if already done).

◆ startup()

void Pds::Eb::TebContributor::startup ( EbCtrbInBase &  )

Clear the current batch, reset the counters of this object and of in, set the running flag and start a thread that runs in.receiver(*this, running flag).

◆ timeout()

bool Pds::Eb::TebContributor::timeout ( )

If at least BATCH_TIMEOUT (1 ms) has passed since the start time of the current batch, post the batch if one is open and return true; otherwise return false.

Must not be called concurrently with process().

◆ unconfigure()

void Pds::Eb::TebContributor::unconfigure ( )

If running, clear the running flag, join the receiver thread, and dump and shut down the BatchManager and the pending queue; otherwise does nothing.


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