diff options
author | markuskowa <markus.kowalewski@gmail.com> | 2023-08-26 11:54:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-26 11:54:56 +0200 |
commit | 212d454c2ab227e1e9530597f12045776fcf1a35 (patch) | |
tree | 01f2d1097955ea4c091287d730e8d431b6aad719 /pkgs/build-support/setup-hooks | |
parent | e0f0ecbc4c36e4276ba0531782c4478648dd9c5e (diff) | |
parent | cfc44b5d41f3b6af18c4af5e65ec4fd19e9b79cf (diff) |
Merge pull request #246867 from markuskowa/add-mpi-hook
add mpiCheckPhaseHook
Diffstat (limited to 'pkgs/build-support/setup-hooks')
-rw-r--r-- | pkgs/build-support/setup-hooks/mpi-check-hook/default.nix | 5 | ||||
-rw-r--r-- | pkgs/build-support/setup-hooks/mpi-check-hook/mpi-check-hook.sh | 54 |
2 files changed, 59 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/mpi-check-hook/default.nix b/pkgs/build-support/setup-hooks/mpi-check-hook/default.nix new file mode 100644 index 0000000000000..2834cfcc44ff1 --- /dev/null +++ b/pkgs/build-support/setup-hooks/mpi-check-hook/default.nix @@ -0,0 +1,5 @@ +{ callPackage, makeSetupHook }: + +makeSetupHook { + name = "mpi-checkPhase-hook"; +} ./mpi-check-hook.sh diff --git a/pkgs/build-support/setup-hooks/mpi-check-hook/mpi-check-hook.sh b/pkgs/build-support/setup-hooks/mpi-check-hook/mpi-check-hook.sh new file mode 100644 index 0000000000000..fca1f7b7f9327 --- /dev/null +++ b/pkgs/build-support/setup-hooks/mpi-check-hook/mpi-check-hook.sh @@ -0,0 +1,54 @@ +preCheckHooks+=('setupMpiCheck') +preInstallCheckHooks+=('setupMpiCheck') + + +setupMpiCheck() { + # Find out which MPI implementation we are using + # and set safe defaults that are guaranteed to run + # on any build machine + + mpiType="NONE" + + # OpenMPI signature + if command ompi_info &> /dev/null; then + mpiType="openmpi" + fi + + # MPICH based implementations + if command mpichversion &> /dev/null; then + if [ "$mpiType" != "NONE" ]; then + echo "WARNING: found OpenMPI and MPICH/MVAPICH executables" + fi + + version=$(mpichversion) + if [[ "$version" == *"MPICH"* ]]; then + mpiType="MPICH" + fi + if [[ "$version" == *"MVAPICH"* ]]; then + mpiType="MVAPICH" + fi + fi + + echo "Found MPI implementation: $mpiType" + + case $mpiType in + openmpi) + # make sure the test starts even if we have less than the requested amount of cores + export OMPI_MCA_rmaps_base_oversubscribe=1 + # Disable CPU pinning + export OMPI_MCA_hwloc_base_binding_policy=none + ;; + MPICH) + # Fix to make mpich run in a sandbox + export HYDRA_IFACE=lo + ;; + MVAPICH) + # Disable CPU pinning + export MV2_ENABLE_AFFINITY=0 + ;; + esac + + # Limit number of OpenMP threads. Default is "all cores". + export OMP_NUM_THREADS=1 +} + |