Skip to content

Regtests for the coverage of src/mpiwrap and src/main - #1735

Merged
carlocamilloni merged 3 commits into
masterfrom
mpiwrap-main-coverage
Dec 3, 2026
Merged

carlocamilloni merged 3 commits into
masterfrom
mpiwrap-main-coverage

Conversation

@carlocamilloni

Copy link
Copy Markdown
Member

src/mpiwrap and src/main coverage (2026-12-02)

Branch status

  • Branch mpiwrap-main-coverage in Carlo's ~/Codes/plumed2, one commit 531903f on master 73a8726, fetched from Claude outputs/mpiwrap-main-coverage/mpiwrap-main-coverage.bundle. Not pushed.
  • Tests only: no source change, no CHANGES entry.

What the CI coverage page measures

  • The page comes from the -coverage-mpi- job only (native MPI build).
  • In that build only mpiwrap/launcher.cpp (native part, 50 lines) and mpiwrap.h (1 line) are compiled. mpiwrap.cpp, loader.cpp, fallbacks.cpp, tmpi.cpp and src/thread_mpi are under !__PLUMED_HAS_MPI and are never measured.
  • Before (coverage-master at 4c02d9e): launcher.cpp 26/50 (52%), main.cpp 25/35 (71%).

New regtests

  • basic/rt-mpiwrap-launcher-host (type=make, mpiprocs=2, includes <mpi.h>, so NOT_APPLICABLE in serial builds, also through the injection host):
    • before MPI_Init: zero ranks, null callback, null result (ExceptionTypeError), internal_thread_mpi in a native kernel, unknown policy, host_owned with MPI not initialized;
    • after MPI_Init: successful host_owned launch (per-rank result, MPI_SUCCESS), host_owned rank mismatch, host_owned callback exception rethrown, standalone_owned with MPI already initialized; MPI still active after all these;
    • after MPI_Finalize: host_owned and standalone_owned give "MPI is finalized";
    • ./exe standalone (plumed_regtest_after): standalone_owned rank mismatch, the launcher initializes and finalizes MPI before throwing; each process writes standalone-pid., all must be identical;
    • ./exe standalone-throw: callback exception with launcher-owned MPI aborts the job (non-zero exit, "callback failed; aborting MPI" on stderr). Not visible to gcov (MPI_Abort), checked for behaviour.
  • basic/rt-plumed-runtime-kernel (type=plumed, needs tools:dlopen; NOT_APPLICABLE without a plumed-runtime executable): plumed-runtime with the working kernel gives the same output as plumed; with PLUMED_KERNEL pointing to a missing library, --mpi --no-mpi exits with code 1, nothing on stdout, the path reported on stderr.

Result (cloud gcov MPI build, union with the CI lines)

  • launcher.cpp: 26/50 -> 42/50 (52% -> 84%).
  • main.cpp: 25/35 -> 28/35 (71% -> 80%).
  • Left: MPI calls that fail (MPI_Initialized/MPI_Init/MPI_Finalize errors), MPI_Abort paths, and main.cpp's failure: label, which ends with abort() on purpose (G. Bussi, 3111ca1: "terminate instead of entering collective finalization"); gcov writes nothing on abort.
  • Verified: both tests pass in the MPI build (OpenMPI 4) and the serial build (runtime test passes, launcher test NOT_APPLICABLE, also with the mkmpi injection host); astyle clean.

Serial-only code (not on the coverage page), measured in a cloud serial gcov build

Only the 86 basic tests with mpiprocs>0 plus rt-mpiwrap-*, run natively (internal thread-MPI) and through the plumed mkmpi --executable OpenMPI host, union of the two:

  • mpiwrap.cpp 1816/3236 (56%; 33% through the host only), fallbacks.cpp 69%, loader.cpp 16%, tmpi.cpp 82%, launcher.cpp tMPI part 62%, src/thread_mpi 1671/2191 (76%; 0% through the host).
  • Plumed.h host adapter: still not reached (main.cpp in the mkmpi host is not a src object).
  • To show this on the coverage page/Codecov a serial gcov job is needed: either --enable-gcov in serial-mpi-injection (host mode only) or a serial -coverage- matrix variant (internal tMPI), with the lcov report uploaded to Codecov (it merges uploads of the same commit). Proposed to Carlo, not done.

- basic/rt-mpiwrap-launcher-host (2 MPI processes, native-MPI builds only):
  mpiwrap::launchRanks with a host-owned MPI (successful launch, rank-count
  mismatch, callback exception rethrown to the host), the argument and
  lifecycle errors before MPI_Init and after MPI_Finalize, a rank-count
  mismatch with a launcher-owned MPI (MPI initialized and finalized again
  before the exception) and a callback exception with a launcher-owned MPI
  (the job is aborted).
- basic/rt-plumed-runtime-kernel: the plumed-runtime executable (main.cpp
  with the kernel loaded at runtime) with a working kernel, and with a
  PLUMED_KERNEL that cannot be loaded (exit code 1, no crash).

Lines covered in the -coverage-mpi- build: mpiwrap/launcher.cpp 26/50 -> 42/50,
main/main.cpp 25/35 -> 28/35.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vwxtV38tUZEERzzsopLk4
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.93%. Comparing base (73a8726) to head (b0311fe).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1735      +/-   ##
==========================================
- Coverage   92.08%   91.93%   -0.15%     
==========================================
  Files         655      661       +6     
  Lines       82410    86382    +3972     
==========================================
+ Hits        75884    79417    +3533     
- Misses       6526     6965     +439     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

carlocamilloni and others added 2 commits December 2, 2026 23:47
Most of src/mpiwrap (mpiwrap.cpp, loader.cpp, fallbacks.cpp, tmpi.cpp) is
compiled only in serial builds, so the -coverage-mpi- job cannot measure it.
The serial-mpi-injection job now instruments only src/mpiwrap (a Makefile.conf
snippet adds --coverage when compiling there, LDFLAGS=--coverage links the
gcov runtime), runs the MPI regtests of basic/ again with internal thread-MPI
after the suite through the MPI host and the focused checks, and uploads the
lcov report of src/mpiwrap to Codecov (merged with the -coverage-mpi- one)
and as an HTML artifact.

--coverage is kept out of LDSHARED: the providers that mkmpi builds at runtime
reuse those flags, and an instrumented provider leaves a .gcda file in its
temporary build directory, which check-mpi-provider-selection.sh reports.

Measured in a cloud replica of the job (basic/ MPI regtests through the host
and with thread-MPI, then the focused checks): src/mpiwrap 2451/4112 lines
(59.6%); loader.cpp goes from 16% to 70% with the focused checks. The extra
steps take about 4 minutes on 2 cores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vwxtV38tUZEERzzsopLk4
… constants

In a serial build rt-mpiwrap-api runs its body on the embedded thread-MPI
provider only, so the 62 mapped functions and the predefined values that
thread-MPI lacks were never dispatched through the kernel's provider bridges.

- check-mpi-api-provider.sh compiles the body of main.cpp with the installed
  kernel's serial frontend (PLUMED_MPIW_API_REGTEST_LIBRARY), links it into an
  MPI program that owns MPI_Init/MPI_Finalize, and runs it on 4 processes with
  a real-MPI provider selected through PLUMED_MPI_WRAPPER. Run by the
  serial-mpi-injection job with the Open MPI provider built by mkmpi.
- The body takes a Context: the thread-MPI capability contract is checked only
  on the thread-MPI provider (and provider_ranks_are_threads() must agree).
- New constants() scenario, run with native MPI and with a real-MPI provider:
  reductions with every basic datatype, MAXLOC/MINLOC with the value-index pair
  types, PROD/MAX/MIN and the logical and bitwise operations, MPI_PACKED,
  MPI_BOTTOM, MPI_COMM_WORLD, MPI_SIMILAR/MPI_UNEQUAL, MPI_GROUP_EMPTY,
  MPI_ERRORS_RETURN/ARE_FATAL, MPI_ERRHANDLER_NULL and the error classes.

Checked: rt-mpiwrap-api passes in a native Open MPI build (constants() included)
and in a serial build (thread-MPI); the new script passes with the Open MPI
provider. src/mpiwrap serial coverage in a replica of the CI job:
mpiwrap.cpp 56% -> 92%, src/mpiwrap 59.6% -> 87.6% of lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vwxtV38tUZEERzzsopLk4
@carlocamilloni
carlocamilloni merged commit 71906e2 into master Dec 3, 2026
70 checks passed
@carlocamilloni

Copy link
Copy Markdown
Member Author

@GiovanniBussi #1729 this add serial coverage

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.

1 participant