Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion .github/workflows/linuxWF.yml
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ jobs:

# A serial PLUMED build can use real MPI supplied by its host at runtime. Keep
# this separate from the matrix so the full suite runs once through injection.
# Only src/mpiwrap is instrumented with gcov here: most of it is compiled only in
# serial builds, so the -coverage-mpi- job cannot measure it. Its report is
# uploaded to Codecov, which merges it with the one of the -coverage-mpi- job.
serial-mpi-injection:
runs-on: ubuntu-24.04
timeout-minutes: 180
Expand All @@ -598,7 +601,16 @@ jobs:
- name: Build and install PLUMED without MPI
run: |
./configure --enable-boost_serialization --disable-dependency-tracking \
--enable-modules=all --disable-mpi --prefix="$HOME/opt"
--enable-modules=all --disable-mpi --prefix="$HOME/opt" LDFLAGS=--coverage
# Instrument only src/mpiwrap. LDFLAGS=--coverage links the gcov runtime into the
# kernel (configure moves it to DYNAMIC_LIBS). Do not add it to LDSHARED: that would
# also instrument the providers built at runtime by mkmpi, which then leave .gcda
# files in their temporary build directories (check-mpi-provider-selection.sh fails).
cat >> Makefile.conf << 'EOF'
ifeq ($(notdir $(CURDIR)),mpiwrap)
CXX := $(CXX) --coverage
endif
EOF
make -j 4
make install
- name: Install Open MPI and build the injecting host
Expand Down Expand Up @@ -643,6 +655,9 @@ jobs:
"$RUNNER_TEMP/provider-openmpi.so"
bash regtest/basic/rt-mpiwrap-api/check-mpi-provider-selection.sh \
plumed "$RUNNER_TEMP/provider-openmpi.so" /usr/bin/mpicc.openmpi
bash regtest/basic/rt-mpiwrap-api/check-mpi-api-provider.sh \
/usr/bin/mpic++.openmpi /usr/bin/mpiexec.openmpi "$PLUMED_KERNEL" \
"$RUNNER_TEMP/provider-openmpi.so"
PLUMED_MPI_WRAPPER="$RUNNER_TEMP/provider-openmpi.so" \
bash regtest/basic/rt-mpiwrap-api/check-mpi-provider-chdir.sh \
"$RUNNER_TEMP/plumed-openmpi-host"
Expand All @@ -652,6 +667,44 @@ jobs:
cmake -S regtest/basic/rt-mpiwrap-launcher -B "$RUNNER_TEMP/thread-mpi-tests"
cmake --build "$RUNNER_TEMP/thread-mpi-tests" -j 4
ctest --test-dir "$RUNNER_TEMP/thread-mpi-tests" --output-on-failure
# The suite above runs MPI through the host. Run the MPI regtests of basic/ (and the
# rt-mpiwrap-* ones) again with internal thread-MPI, for the coverage of that path.
# The MPI regtests of the other directories add no mpiwrap lines.
- name: Run the MPI regtests of basic with internal thread-MPI
if: ${{ !cancelled() }}
run: |
unset PLUMED_MPI_WRAPPER PLUMED_MPI_WRAPPER_FORCE
tests=$( (grep -l '^mpiprocs=[1-9]' regtest/basic/*/config | xargs -n 1 dirname ; ls -d regtest/basic/rt-mpiwrap-*) | sort -u)
echo "$tests" | xargs -P "$PLUMED_REGTEST_JOBS" -I{} make --no-print-directory -C {} testclean
failed=0
for t in $tests ; do
if grep -q FAILURE "$t/report.txt" ; then
echo "FAILURE in $t" ; cat "$t/report.txt" ; failed=1
fi
done
exit $failed
- name: Coverage of src/mpiwrap
if: ${{ !cancelled() }}
run: |
.ci/install.lcov v1.16
lcov -c -d src/mpiwrap --no-external -o mpiwrap-serial.info
genhtml -o mpiwrap-serial -t "src/mpiwrap, serial build" mpiwrap-serial.info
- name: Upload the coverage of src/mpiwrap as an artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v6
with:
name: mpiwrap-serial-coverage
path: mpiwrap-serial
- name: Upload the coverage of src/mpiwrap to Codecov
# the nightly run publishes nothing: pushes to master already do
if: ${{ !cancelled() && github.event_name != 'schedule' }}
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./mpiwrap-serial.info
disable_search: true
plugins: noop
fail_ci_if_error: false

# Regtests (no MPI, no optional libraries) on configurations that the jobs above do not cover:
# - clang-noopenmp: the configuration built in the gate (build job of checksWF.yml, where its warnings
Expand Down
18 changes: 18 additions & 0 deletions regtest/basic/rt-mpiwrap-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ python3 check-isolated.py ./exe
python3 check-isolated.py mpiexec -n 4 ./exe
```

In a serial build the regtest runs the body on the embedded thread-MPI
provider only, so the functions and predefined values that thread-MPI lacks are
never dispatched there. `check-mpi-api-provider.sh` runs the same body, compiled
with the installed kernel's serial frontend, in an MPI program that owns the
MPI lifecycle, with a real-MPI provider selected through `PLUMED_MPI_WRAPPER`
(the serial-mpi-injection CI job uses the Open MPI provider built by `mkmpi`):

```
bash check-mpi-api-provider.sh mpicxx mpiexec SERIAL_KERNEL PROVIDER_LIBRARY
```

Without the thread-MPI contract, the body also checks the predefined values
that the other scenarios do not use (`constants()`): reductions with every
basic datatype, the value-index pair types with `MPI_MAXLOC`/`MPI_MINLOC`, the
remaining operations, `MPI_PACKED`, `MPI_BOTTOM`, `MPI_SIMILAR`/`MPI_UNEQUAL`,
`MPI_GROUP_EMPTY`, the error handlers and the error classes. Native builds run
this part too.

Native builds require MPI-2.2 or later for `MPI_C_BOOL` and `MPI_INT64_T`, as do
these particular datatype scenarios. They do not change the MPI version
requirements of the provider itself.
Expand Down
79 changes: 79 additions & 0 deletions regtest/basic/rt-mpiwrap-api/check-mpi-api-provider.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# Variables are used inside eval strings; compile and link_libs_installed
# come from compile_options.sh.
# shellcheck disable=SC2034,SC2154
# Run the mapped-API body of main.cpp on a serial kernel with a real-MPI provider.
# The regtest itself runs the body on the embedded thread-MPI provider only, so
# the functions that thread-MPI does not provide are otherwise never dispatched.
# An MPI program owns the lifecycle (MPI_Init/MPI_Finalize) and calls the body,
# which is compiled with the kernel's serial frontend; the provider is selected
# with PLUMED_MPI_WRAPPER.
set -euo pipefail
if (($# != 4)); then
echo 'usage: check-mpi-api-provider.sh MPI_CXX_COMPILER MPIEXEC SERIAL_KERNEL PROVIDER_LIBRARY' >&2
exit 2
fi
mpicxx=$1
mpiexec=$2
kernel=$3
provider=$4
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
TASK_DIR=$(mktemp -d "${TMPDIR:-/tmp}/plumed-api-provider.XXXXXX")
trap 'rm -rf "$TASK_DIR"' EXIT
kernel_dir=$(cd "$(dirname "$kernel")" && pwd)
program_name=$(basename "$kernel")
program_name=${program_name#lib}
program_name=${program_name%Kernel.*}
for candidate in "$kernel_dir/$program_name" "$kernel_dir/../.."; do
if [[ -r "$candidate/src/config/compile_options.sh" ]]; then
mpi_root=$(cd "$candidate" && pwd)
break
fi
done
if [[ -z ${mpi_root:-} ]]; then
echo 'cannot find the configured build options beside the requested kernel' >&2
exit 1
fi
include_dir="$mpi_root/src/include"
if [[ ! -d "$include_dir" ]]; then include_dir="$mpi_root/../../include"; fi
# shellcheck disable=SC1091
source "$mpi_root/src/config/compile_options.sh"
# compile contains the quoted include directory of the installed headers
export PLUMED_INCLUDEDIR="$include_dir" PLUMED_PROGRAM_NAME="$program_name"
test_dir="$ROOT/regtest/basic/rt-mpiwrap-api"
eval "$compile" -I'"$include_dir"' -DPLUMED_MPIW_API_REGTEST_LIBRARY \
'"$test_dir/main.cpp"' -o '"$TASK_DIR/body.o"'
cat > "$TASK_DIR/host.cpp" <<'SOURCE'
#include <mpi.h>
#include <cstddef>
#include <cstdio>

extern "C" int plumed_mpiw_api_regtest_body(int rank, const void *native_world, std::size_t native_size);

int main(int argc, char **argv) {
MPI_Init(&argc,&argv);
int rank=0, size=0;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Comm_size(MPI_COMM_WORLD,&size);
int result=1;
if(size==4) {
MPI_Comm world=MPI_COMM_WORLD;
result=plumed_mpiw_api_regtest_body(rank,&world,sizeof(world));
} else {
std::fprintf(stderr,"four processes are required\n");
}
int combined=1;
MPI_Allreduce(&result,&combined,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
MPI_Finalize();
return combined;
}
SOURCE
# link_libs_installed: the installed kernel and the libraries it needs (OpenMP, zlib, ...)
eval '"$mpicxx"' '"$TASK_DIR/host.cpp"' '"$TASK_DIR/body.o"' \
"$link_libs_installed" '"-Wl,-rpath,$kernel_dir"' -o '"$TASK_DIR/host"'
(
cd "$TASK_DIR"
env -u PLUMED_MPI_WRAPPER_FORCE PLUMED_MPI_WRAPPER="$provider" "$mpiexec" -np 4 ./host
)
grep -qx 'mapped MPI API semantic checks passed' "$TASK_DIR/output"
echo 'mapped MPI API semantic checks passed with a real-MPI provider'
Loading
Loading