Skip to content

Commit

Permalink
Workaround for current CI issues with clang14 on MacOS (#1565)
Browse files Browse the repository at this point in the history
* Use mpirun wrapper to circumvent parser bug in mpirun

The bug sounds similar to this one
open-mpi/ompi#6372, though that is supposedly
fixed in Open MPI 5..

This creates a tmp script to call the launched application instead of
calling it directly on the command line. This way, mpirun does not see
the command line arguments and cannot try to wrongly parse them.

* Add mechanism to get rid of the workaround again in future
  • Loading branch information
franzpoeschel authored Dec 7, 2023
1 parent d44f981 commit 6b963ba
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ jobs:
-DopenPMD_USE_MPI=ON \
-DopenPMD_USE_HDF5=ON \
-DopenPMD_USE_ADIOS2=ON \
-DopenPMD_USE_INVASIVE_TESTS=ON
-DopenPMD_USE_INVASIVE_TESTS=ON \
-DMPIEXEC_EXECUTABLE=".github/workflows/mpirun_workaround.sh"
cmake --build build --parallel 3
ctest --test-dir build --verbose
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/mpirun_workaround.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

# mpiexec currently seems to have a bug where it tries to parse parameters
# of the launched application when they start with a dash, e.g.
# `mpiexec python ./openpmd-pipe --infile in.bp --outfile out.bp`
# leads to:
# > An unrecognized option was included on the mpiexec command line:
# >
# > Option: --infile
# >
# > Please use the "mpiexec --help" command to obtain a list of all
# > supported options.
#
# This script provides a workaround by putting the called sub-command into
# a script in a temporary file.

mpiexec -n 1 ls --all \
&& echo "MPIRUN WORKING AGAIN, PLEASE REMOVE WORKAROUND" >&2 \
&& exit 1 \
|| true

mpirun_args=()

script_file="$(mktemp)"

cleanup() {
rm "$script_file"
}
trap cleanup EXIT

while true; do
case "$1" in
-c | -np | --np | -n | --n )
mpirun_args+=("$1" "$2")
shift
shift
;;
*)
break
;;
esac
done

echo -e '#!/usr/bin/env bash\n' > "$script_file"
for item in "$@"; do
echo -n "'$item' " >> "$script_file"
done

chmod +x "$script_file"

mpirun "${mpirun_args[@]}" "$script_file"

0 comments on commit 6b963ba

Please sign in to comment.