Skip to content

Raise an error in debug builds when multi_sim_comm is used where it is a stand-in (#1443) - #1484

Merged
carlocamilloni merged 1 commit into
plumed:masterfrom
aalhossary:issue1443-standin
Oct 10, 2026
Merged

carlocamilloni merged 1 commit into
plumed:masterfrom
aalhossary:issue1443-standin

Conversation

@aalhossary

@aalhossary aalhossary commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor
Description

Closes #1487.

Option 1 of #1443 (see the table there): in debug builds, using multi_sim_comm on a process that was not given it now raises an error instead of silently acting on a single replica.

  • Communicator gets a stand-in mark (setStandIn() / isStandIn()). In debug builds, asking a stand-in for its rank or size, or communicating over it, raises an error. In release builds the check compiles away. Set_comm() clears the mark, and copies keep it.
  • PlumedMain::updateReplicaIdentity() (from Replica count and index on every rank of a replica (#1443, part C) #1481) marks multi_sim_comm as a stand-in on every process where it has size 1 although there is more than one replica, i.e. on all processes of a replica except the one the MD code gave the inter-replica communicator to.
  • The error is also printed to stderr right away. Typically only some processes raise it, and the log is written collectively, so otherwise the message can be lost behind a hang.

This adds a member to Communicator, which changes its layout; that is why it targets master only.

Target release

I would like my code to appear in release master (v2.11)

Type of contribution
  • changes to code or doc authored by PLUMED developers, or additions of code in the core or within the default modules
  • changes to a module not authored by you
  • new module contribution or edit of a module authored by you
Copyright
  • I agree to transfer the copyright of the code I have written to the PLUMED developers or to the author of the code I am modifying.
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

New regtest basic/rt-multi-sim-comm-stand-in runs 2 replicas × 2 MPI ranks and LOADs a small action that checks, on every rank, that multi_sim_comm is a stand-in exactly on the second rank of each replica, and that using it there raises an error in debug builds and does not in release builds. With the marking removed, the test fails.

Locally, with --enable-debug, the full suite gives 813 performed and 1 error, basic/rt-make-fortran08, the same libc++/libstdc++ mismatch in my build as on #1481. The new check fired only in the new regtest, so no existing regtest uses multi_sim_comm where it is a stand-in (21 of them run with more than one rank per replica).

…s a stand-in

multi_sim_comm is given only to one process per replica; on the other
processes it stays MPI_COMM_SELF, so using it there silently acts on a
single replica (plumed#1443).

Communicator gets a stand-in mark. updateReplicaIdentity() sets it on
multi_sim_comm wherever it has size 1 although there is more than one
replica. In debug builds, asking a stand-in for its rank or size, or
communicating over it, raises an error; the message is also printed to
stderr at once, because typically only some processes raise it and the
log is written collectively.

The regtest LOADs a small action that checks the mark and the error on
every rank of 2 replicas with 2 ranks each.

See plumed#1443.
@carlocamilloni
carlocamilloni merged commit e26ec6a into plumed:master Oct 10, 2026
24 of 26 checks passed
@aalhossary
aalhossary deleted the issue1443-standin branch October 11, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug builds: raise an error when multi_sim_comm is used where it is a stand-in

2 participants