Skip to content

psana.psexp.mpi_ds

MPIDataSource is returned by DataSource(exp=..., run=...) on the smd0, event-builder and big-data ranks of an MPI job with more than one rank (the roles are assigned by Communicators in psana/psana/psexp/node.py). Its runs() yields RunParallel objects, whose events() and steps() deliver events on the big-data ranks. RunParallel also implements random access (build_table(), event(ts)) and shares calibration constants between ranks.

See MPI parallel analysis.

psana.psexp.mpi_ds

Define MPIDataSource and RunParallel, the data source and run used when psana runs on several MPI ranks.

InvalidEventBuilderCores

Bases: Exception

Exception class; nothing in this module raises it.

RunParallel

RunParallel(expt, runnum, timestamp, dsparms, dm, smdr_man, configs, begingrun_dgrams, comms=None)

Bases: Run

Yields list of events from multiple smd/bigdata files using > 3 cores.

build_xtc_buffer

build_xtc_buffer(det_info)

Convert the run's calibration constants into an xtc2 buffer stored in _calib_xtc_buffer.

Uses CalibXtcConverter(det_info).convert_to_buffer; det_info None means {}. If there are no constants, _calib_xtc_buffer is set to None; a conversion error is logged as a warning and leaves _calib_xtc_buffer unchanged.

Returns:

Type Description
None

events

events()

Yield the L1Accept events received by this rank as Event objects.

Only bd ranks yield events; on smd0 and eb ranks start() runs their loop to the end and yields nothing. Transitions update the env store and are not yielded, and every PS_BD_ANA_INTERVAL (default 1000) iterations the analysis rate and memory use are logged at debug level and the rate is set on the "psana_bd_ana_rate" gauge.

steps

steps()

Yield a Step for each BeginStep transition received by this rank.

As in events(), only bd ranks receive data; on smd0 and eb ranks start() runs their loop. Every non-L1Accept transition updates the env store, and each Step reads from the same iterator.

close_shared_memory

close_shared_memory()

Release the shared calibration buffer and shared-memory helpers of this run.

Calls the private _close_shared_memory, which acts only once: it frees the MPI window holding the calibration xtc buffer and closes the Jungfrau and geometry MPISharedMemory helpers (errors are logged at debug level).

start

start()

Request data for this run

build_table

build_table()

Context manager for building timestamp-offset table. Returns True only on BigDataNode if the table was successfully built.

Requires PS_EB_NODES=1 for broadcast mode.

event

event(ts)

Read and return the event with timestamp ts, using the table built by build_table on bd ranks.

Each stream's dgram is read with os.pread at the recorded offset and size and wrapped in dgram.Dgram; streams without an entry are None. The Event gets run=self (this run object, not its RunCtx).

Raises:

Type Description
ValueError

If ts is not in the table (AttributeError if no table was built on this rank).

terminate

terminate()

Ask smd0 to stop, then set this run's terminate flag.

Calls comms.terminate(), a non-blocking send of this rank's number to world rank 0, then Run.terminate().

MPIDataSource

MPIDataSource(comms, *args, **kwargs)

Bases: DataSourceBase

Data source that reads an experiment in parallel on several MPI ranks.

The constructor takes a Communicators object and passes the keyword arguments to DataSourceBase.__init__; it creates a SmallData object if PS_SRV_NODES > 0, aborts all ranks with safe_mpi_abort unless the psana communicator has more than PS_EB_NODES + 1 ranks, broadcasts the run-number list and xtc path from smd0, starts the Prometheus client and sets up the first run. Run setup (finding files, detector selection, reading configs with a SmdReaderManager) happens on smd0, whose file lists, smd flags and configs are broadcast to the other psana ranks, and every rank opens the bigdata files with a DgramManager; when timestamps is a file name only eb ranks load it.

runs

runs()

Yield a RunParallel for each BeginRun.

smd0 reads the next dgrams from the smalldata files and broadcasts them to all psana ranks until a BeginRun is found; when the current files have none left, the next run number is set up. Each run gets the experiment, run number and timestamp from the BeginRun dgram, plus dsparms, the DgramManager, the SmdReaderManager (None except on smd0), the configs, the BeginRun dgrams and comms.

is_mpi

is_mpi()

Return True.

safe_mpi_abort

safe_mpi_abort(msg)

Print msg, flush stdout and call MPI.COMM_WORLD.Abort().