Skip to content

CI: run standalone tests with MPI rank 4 as well #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 27, 2025
Merged
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
28 changes: 25 additions & 3 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,26 @@ NC='\033[0m' # No Color

MPIEXEC=${CONDA_PREFIX}/bin/mpiexec

# detect MPI implementation
MPI_VERSION=$($MPIEXEC --version 2>&1)
if echo "$MPI_VERSION" | grep -q "Open MPI"; then
MPI_TYPE="openmpi"
elif echo "$MPI_VERSION" | grep -q "MPICH"; then
MPI_TYPE="mpich"
else
# we don't yet support other MPI implementations
# like intel MPI etc.0
echo -e "${RED}Unknown MPI implementation!${NC}"
exit 1
fi

if [[ "$(uname)" == "Linux" ]]; then
CC=gcc
else
CC=clang
fi

# Compile C and Fortran sources
# compile C and Fortran sources
$CC -I$CONDA_PREFIX/include -c ../src/mpi_wrapper.c
$FC -c ../src/mpi_c_bindings.f90
$FC -c ../src/mpi.f90
Expand All @@ -26,9 +39,18 @@ for file in *.f90; do
$FC -c $file
$FC mpi_wrapper.o mpi_c_bindings.o mpi.o $filename.o -o $filename -L$CONDA_PREFIX/lib -lmpi -Wl,-rpath,$CONDA_PREFIX/lib

for np in 1 2; do
for np in 1 2 4; do
# set MPIEXEC_ARGS based on MPI type and number of ranks
# `--oversubscribe` isn't needed with Open MPI when running
# with 1 or 2 ranks
if [[ "$MPI_TYPE" == "openmpi" && $np -gt 2 ]]; then
MPIEXEC_ARGS="--oversubscribe"
else
MPIEXEC_ARGS=""
fi

echo -e "${YELLOW}Running $filename with $np MPI ranks...${NC}"
if ${MPIEXEC} -np $np ./$filename; then
if ${MPIEXEC} -np $np $MPIEXEC_ARGS ./$filename; then
echo -e "${GREEN}Test $filename with $np MPI ranks PASSED!${NC}"
else
echo -e "${RED}Test $filename with $np MPI ranks FAILED!${NC}"
Expand Down