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

Namespace of the psdaq event-builder (eb) code. More...

Classes

class  Batch
 One batch of fixed-size entries in an RDMA region: its start pulse ID, its buffer (chosen from the pulse ID) and its current extent. More...
 
class  BatchManager
 Owns the page-aligned region in which batches are built and decides when a batch has expired. More...
 
struct  CtrbBatch
 A batch of contiguous input datagrams being built by TebContributor. More...
 
class  CubeConfigDgram
 ResultDgram that stores a ResultType in the monitor buffer number word, a bin count in the auxdata field, and NUL-terminated JSON text appended to its payload. More...
 
class  CubeResultDgram
 ResultDgram whose auxdata field holds a record-event bit (bit 0), a record-bin bit (bit 1), a monitor-bin bit (bit 2), a flush bit (bit 3) and a 20-bit bin index (bits 23-4). More...
 
class  EbAppBase
 EventBuilder fed by inbound libfabric server links from the contributors (DRPs). More...
 
class  EbCtrbInBase
 Receives trigger result batches from the TEBs over libfabric server links, matches them with the contributor's pending input batches and calls process() for each matched event. More...
 
class  EbEpoch
 List element for one epoch of the event builder; holds the list of events pending in that epoch. More...
 
class  EbEvent
 One event being built by EventBuilder: its contributions (a variable-length array that follows the object), the bit list of contributors still missing, accumulated damage and payload size. More...
 
class  EbLfClient
 Creates and tears down client-side EbLfCltLink connections; all its links share one pending word and one posting word. More...
 
class  EbLfCltLink
 Client side of an EbLfLink; writes data into the server's registered memory with RDMA. More...
 
class  EbLfLink
 One libfabric connection between an event-builder client and server. More...
 
class  EbLfServer
 Accepts client connections on a passive endpoint and receives their notifications. More...
 
class  EbLfSvrLink
 Server side of an EbLfLink; synchronizes with the client before and after each exchange. More...
 
struct  EbParams
 Parameters used by both TEBs and MEBs, per the original comment. More...
 
class  EventBuilder
 Abstract event builder. More...
 
class  FiTransport
 Point-to-point libfabric transport for DGRAM, RDM or MSG endpoints, adapted from the libfabric pingpong example per the file comment. More...
 
class  ImmData
 Static helpers that pack and unpack the 32-bit immediate data word: a 2-bit flags field (bits 31-30), a 6-bit source field (bits 29-24) and a 24-bit index field (bits 23-0). More...
 
class  IndexPoolBase
 Fixed array of a power-of-2 number of equal-size objects, addressed by a key masked to the array size, with a per-slot allocated flag and allocation counters. More...
 
class  IndexPoolW
 Typed index pool over IndexPoolBaseW<L>, so allocate() waits for busy slots. More...
 
class  MebContributor
 Sends L1Accepts to one chosen MEB buffer and transitions to every MEB, over libfabric client links. More...
 
struct  MebCtrbParams
 Parameters of an MEB contributor (a DRP), per the original comment. More...
 
class  ResultDgram
 Trigger result datagram: an EbDgram followed by a 32-bit result word and a 32-bit monitor buffer number word. More...
 
class  TebContributor
 Builds batches of input datagrams in a BatchManager region and posts them over libfabric links to the TEBs. More...
 
struct  TebCtrbParams
 Parameters of a TEB contributor (a DRP), per the original comment. More...
 
class  WindowResultDgram
 ResultDgram whose auxdata field holds four 6-bit fields: add (bits 5-0), record (bits 11-6), monitor (bits 17-12) and flush (bits 23-18). More...
 

Typedefs

using LinkMap = std::unordered_map< fid_ep *, EbLfSvrLink * >
 Map from a raw libfabric endpoint to its server link.
 
using BatchQueue = SPSCQueue< const Pds::EbDgram * >
 Single-producer single-consumer queue of EbDgram pointers.
 
using time_point_t = std::chrono::time_point< fast_monotonic_clock >
 Time point of fast_monotonic_clock.
 

Enumerations

enum  {
  VL_NONE , VL_DEFAULT , VL_BATCH , VL_EVENT ,
  VL_DETAILED
}
 Verbosity levels, from none to most detailed. More...
 
enum  ResultType { Base =0 , Cube =1 , Window =2 }
 Result type codes, described in the original comment as ConfigDgram specializations; CubeConfigDgram::resultType(char*) maps the strings Cube and Window to these codes. More...
 

Functions

template<typename T >
int64_t latency (const XtcData::TimeStamp &)
 Return the time from timestamp time to now (std::chrono::system_clock) as a count of duration type T.
 
int linksConnect (EbLfClient &transport, std::vector< EbLfCltLink * > &links, const std::vector< std::string > &addrs, const std::vector< std::string > &ports, unsigned id, const char *name)
 Connect transport to every addrs[i]:ports[i] (14750 ms timeout each), then exchange IDs on each link and store it in links at the index of the remote ID.
 
int linksConfigure (std::vector< EbLfCltLink * > &links, void *region, size_t regSize, const char *name)
 Call linksConfigure(links, region, regSize, regSize, name).
 
int linksConfigure (std::vector< EbLfCltLink * > &links, void *region, size_t lclSize, size_t rmtSize, const char *name)
 Call EbLfCltLink::prepare(region, lclSize, rmtSize, name) on every link and log the configured region.
 
int setupMr (Fabrics::Fabric *fabric, void *region, size_t size, Fabrics::MemoryRegion **mr, const unsigned &verbose)
 Make *mr a memory region on fabric that covers size bytes at region.
 
int linksStart (EbLfServer &transport, const std::string &ifAddr, std::string &port, unsigned nLinks, const char *name)
 Call transport.listen(ifAddr, port, nLinks) and log an error naming name on failure; returns 0 or the error.
 
int linksConnect (EbLfServer &transport, std::vector< EbLfSvrLink * > &links, unsigned id, const char *name)
 Accept links.size() connections (14750 ms timeout each), then exchange IDs on each and store each link at the index of its remote ID.
 
size_t roundUpSize (size_t size)
 Return size rounded up to a whole number of system pages (sysconf(_SC_PAGESIZE)).
 
void * allocRegion (size_t size)
 Allocate a page-aligned block of roundUpSize(size) bytes with posix_memalign().
 
int pinThread (const pthread_t &th, int cpu)
 Pin thread th to the single CPU cpu with pthread_setaffinity_np() and return its result.
 

Variables

const unsigned MAX_DRPS = 64
 Maximum number of contributors (64; the original comment says these limits come from the bits of a uint64_t).
 
const unsigned MAX_TEBS = 4
 Maximum number of trigger event builders (4).
 
const unsigned MAX_MEBS = 4
 Maximum number of monitor event builders (4).
 
const unsigned MAX_MRQS = MAX_MEBS
 Maximum number of monitor requestors; equal to MAX_MEBS.
 
const unsigned NUM_READOUT_GROUPS = 8
 Number of readout groups supported (8).
 
const unsigned TICK_RATE = 1000000 * 13/14
 System clock rate in Hz according to the original comment; computed in integer arithmetic as 1000000 * 13 / 14.
 
const unsigned EB_TMO_MS = 12000
 Event-builder event timeout in milliseconds (12000).
 
const unsigned TEB_TR_BUFFERS = 128
 Number of TEB transition buffers (128); the original comment says it must exceed the timeout times the SlowUpdate rate.
 
const unsigned MEB_TR_BUFFERS = 24
 Number of MEB transition buffers (24); the original comment says it must exceed the timeout times the SlowUpdate rate.
 
const unsigned MAX_ENTRIES = 64
 Maximum number of entries (events) per batch (64).
 
const uint64_t BATCH_DURATION = MAX_ENTRIES
 Batch duration in pulse-ID ticks; equal to MAX_ENTRIES and checked by a static_assert to be a power of 2.
 
const unsigned MAX_LATENCY = 16 * 1024 * 1024
 Buffering range in pulse-ID ticks (16 * 1024 * 1024).
 
const unsigned MAX_BATCHES = MAX_LATENCY / MAX_ENTRIES
 Maximum number of batches in circulation, MAX_LATENCY / MAX_ENTRIES; checked by a static_assert to be a power of 2.
 

Detailed Description

Namespace of the psdaq event-builder (eb) code.

Typedef Documentation

◆ BatchQueue

using Pds::Eb::BatchQueue = typedef SPSCQueue<const Pds::EbDgram*>

Single-producer single-consumer queue of EbDgram pointers.

TebContributor::pending() holds the first datagram of each posted batch, or a single datagram that bypassed the TEBs.

◆ LinkMap

using Pds::Eb::LinkMap = typedef std::unordered_map<fid_ep*, EbLfSvrLink*>

Map from a raw libfabric endpoint to its server link.

◆ time_point_t

using Pds::Eb::time_point_t = typedef std::chrono::time_point<fast_monotonic_clock>

Time point of fast_monotonic_clock.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Verbosity levels, from none to most detailed.

Enumerator
VL_NONE 

Level 0.

VL_DEFAULT 

Level 1.

VL_BATCH 

Level 2.

VL_EVENT 

Level 3.

VL_DETAILED 

Level 4.

◆ ResultType

Result type codes, described in the original comment as ConfigDgram specializations; CubeConfigDgram::resultType(char*) maps the strings Cube and Window to these codes.

Enumerator
Base 

Default type (0); also used for unrecognized strings.

Cube 

Cube result type (1).

Window 

Window result type (2).

Function Documentation

◆ allocRegion()

void * Pds::Eb::allocRegion ( size_t  size)

Allocate a page-aligned block of roundUpSize(size) bytes with posix_memalign().

Returns nullptr (after printing the error to stderr) on failure; the memory is not zeroed unless built with VALGRIND defined.

◆ latency()

template<typename T >
int64_t Pds::Eb::latency ( const XtcData::TimeStamp &  time)

Return the time from timestamp time to now (std::chrono::system_clock) as a count of duration type T.

The timestamp is moved to the POSIX epoch by adding a function-static offset that starts at POSIX_TIME_AT_EPICS_EPOCH; if the difference still exceeds that many seconds, the offset is increased by the difference and the computation is repeated.

◆ linksConfigure() [1/2]

int Pds::Eb::linksConfigure ( std::vector< EbLfCltLink * > &  links,
void *  region,
size_t  lclSize,
size_t  rmtSize,
const char *  name 
)

Call EbLfCltLink::prepare(region, lclSize, rmtSize, name) on every link and log the configured region.

Returns 0 or the first error.

◆ linksConfigure() [2/2]

int Pds::Eb::linksConfigure ( std::vector< EbLfCltLink * > &  links,
void *  region,
size_t  regSize,
const char *  name 
)

Call linksConfigure(links, region, regSize, regSize, name).

◆ linksConnect() [1/2]

int Pds::Eb::linksConnect ( EbLfClient &  transport,
std::vector< EbLfCltLink * > &  links,
const std::vector< std::string > &  addrs,
const std::vector< std::string > &  ports,
unsigned  id,
const char *  name 
)

Connect transport to every addrs[i]:ports[i] (14750 ms timeout each), then exchange IDs on each link and store it in links at the index of the remote ID.

name labels the peers in messages. Returns 0 or the first error.

◆ linksConnect() [2/2]

int Pds::Eb::linksConnect ( EbLfServer &  transport,
std::vector< EbLfSvrLink * > &  links,
unsigned  id,
const char *  name 
)

Accept links.size() connections (14750 ms timeout each), then exchange IDs on each and store each link at the index of its remote ID.

name labels the peers in messages. Returns 0 or the first error.

◆ linksStart()

int Pds::Eb::linksStart ( EbLfServer &  transport,
const std::string &  ifAddr,
std::string &  port,
unsigned  nLinks,
const char *  name 
)

Call transport.listen(ifAddr, port, nLinks) and log an error naming name on failure; returns 0 or the error.

◆ pinThread()

int Pds::Eb::pinThread ( const pthread_t &  th,
int  cpu 
)

Pin thread th to the single CPU cpu with pthread_setaffinity_np() and return its result.

Does nothing and returns 0 when cpu is not greater than 0 (so CPU 0 cannot be selected).

◆ roundUpSize()

size_t Pds::Eb::roundUpSize ( size_t  size)

Return size rounded up to a whole number of system pages (sysconf(_SC_PAGESIZE)).

◆ setupMr()

int Pds::Eb::setupMr ( Fabrics::Fabric *  fabric,
void *  region,
size_t  size,
Fabrics::MemoryRegion **  mr,
const unsigned &  verbose 
)

Make *mr a memory region on fabric that covers size bytes at region.

An existing *mr that starts at region and is at least size bytes long is reused; otherwise it is deregistered and a new region is registered and stored in *mr (even on failure). Returns 0 or the fabric error number.

Variable Documentation

◆ BATCH_DURATION

const uint64_t Pds::Eb::BATCH_DURATION = MAX_ENTRIES

Batch duration in pulse-ID ticks; equal to MAX_ENTRIES and checked by a static_assert to be a power of 2.

◆ EB_TMO_MS

const unsigned Pds::Eb::EB_TMO_MS = 12000

Event-builder event timeout in milliseconds (12000).

A static_assert below requires it to be at most 1000 * MAX_LATENCY / TICK_RATE.

◆ MAX_BATCHES

const unsigned Pds::Eb::MAX_BATCHES = MAX_LATENCY / MAX_ENTRIES

Maximum number of batches in circulation, MAX_LATENCY / MAX_ENTRIES; checked by a static_assert to be a power of 2.

◆ MAX_DRPS

const unsigned Pds::Eb::MAX_DRPS = 64

Maximum number of contributors (64; the original comment says these limits come from the bits of a uint64_t).

◆ MAX_ENTRIES

const unsigned Pds::Eb::MAX_ENTRIES = 64

Maximum number of entries (events) per batch (64).

◆ MAX_LATENCY

const unsigned Pds::Eb::MAX_LATENCY = 16 * 1024 * 1024

Buffering range in pulse-ID ticks (16 * 1024 * 1024).

◆ MAX_MEBS

const unsigned Pds::Eb::MAX_MEBS = 4

Maximum number of monitor event builders (4).

◆ MAX_MRQS

const unsigned Pds::Eb::MAX_MRQS = MAX_MEBS

Maximum number of monitor requestors; equal to MAX_MEBS.

◆ MAX_TEBS

const unsigned Pds::Eb::MAX_TEBS = 4

Maximum number of trigger event builders (4).

◆ MEB_TR_BUFFERS

const unsigned Pds::Eb::MEB_TR_BUFFERS = 24

Number of MEB transition buffers (24); the original comment says it must exceed the timeout times the SlowUpdate rate.

◆ NUM_READOUT_GROUPS

const unsigned Pds::Eb::NUM_READOUT_GROUPS = 8

Number of readout groups supported (8).

◆ TEB_TR_BUFFERS

const unsigned Pds::Eb::TEB_TR_BUFFERS = 128

Number of TEB transition buffers (128); the original comment says it must exceed the timeout times the SlowUpdate rate.

◆ TICK_RATE

const unsigned Pds::Eb::TICK_RATE = 1000000 * 13/14

System clock rate in Hz according to the original comment; computed in integer arithmetic as 1000000 * 13 / 14.