Function utils::mpiAgreeBatchStop
Defined in File MPIUtils.hpp
Function Documentation
-
inline auto utils::mpiAgreeBatchStop(const bool localSigterm, const bool localError) -> BatchStop
Reconcile every rank’s own end-of-batch stop conditions into one run-wide decision.
Every rank must reach the same decision at the same point, so that OutputManagerH5::checkpoint() and its destructor make their barrier-synchronized calls in lockstep across ranks. A rank that stops alone, while the others continue to their next collective call, deadlocks those others forever, since nothing is left to make the matching call on the stopped rank’s behalf.
Both conditions can arise on some ranks but not others. A signal like SIGTERM is caught independently per process (see utils::sigtermWasReceived()), and need not reach every rank, or reach them at the same moment. A trial that throws does so only on the rank running it. This is a single cheap collective (one MPI_Allreduce), called once per batch rather than per trial, so its cost is negligible next to the per-checkpoint collectives that already exist.
- Parameters:
localSigterm – Whether this rank caught a SIGTERM during the batch
localError – Whether a trial on this rank threw during the batch
- Returns:
{localSigterm, localError}, unchanged, when SLUG_MPI is not defined or mpiSize() == 1; otherwise each field is true if any rank passed true for it, and false only if every rank passed false