From 7b97da711b90f2c0769ffe513a946958b4ec8ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Mon, 29 Apr 2024 23:36:54 +0100 Subject: [PATCH] [MPIPreferences] Allow passing extra dirs to `use_system_binary` (#832) --- .github/workflows/UnitTests.yml | 9 ++++----- lib/MPIPreferences/Project.toml | 2 +- lib/MPIPreferences/src/MPIPreferences.jl | 9 ++++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/UnitTests.yml b/.github/workflows/UnitTests.yml index 29139c53d..914f0d0d8 100644 --- a/.github/workflows/UnitTests.yml +++ b/.github/workflows/UnitTests.yml @@ -165,10 +165,7 @@ jobs: - name: Install MPI via homebrew run: | - brew install "${MPI}" - echo "DYLD_FALLBACK_LIBRARY_PATH=$(brew --prefix ${MPI})/lib" >> "${GITHUB_ENV}" - env: - MPI: ${{ matrix.mpi }} + brew install "${{ matrix.mpi }}" - uses: julia-actions/setup-julia@v1 with: @@ -186,7 +183,9 @@ jobs: shell: julia --color=yes --project=. {0} run: | using MPIPreferences - MPIPreferences.use_system_binary() + mpi_prefix = readchomp(`brew --prefix ${{ matrix.mpi }}`) + libdir = joinpath(mpi_prefix, "lib") + MPIPreferences.use_system_binary(; extra_paths=[libdir]) - uses: julia-actions/julia-runtest@v1 env: diff --git a/lib/MPIPreferences/Project.toml b/lib/MPIPreferences/Project.toml index 5a178bca6..23cd2f778 100644 --- a/lib/MPIPreferences/Project.toml +++ b/lib/MPIPreferences/Project.toml @@ -1,7 +1,7 @@ name = "MPIPreferences" uuid = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267" authors = [] -version = "0.1.10" +version = "0.1.11" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" diff --git a/lib/MPIPreferences/src/MPIPreferences.jl b/lib/MPIPreferences/src/MPIPreferences.jl index b6a0b220e..e12e6ffee 100644 --- a/lib/MPIPreferences/src/MPIPreferences.jl +++ b/lib/MPIPreferences/src/MPIPreferences.jl @@ -119,6 +119,7 @@ end """ use_system_binary(; library_names = ["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpi_cray", "libmpitrampoline"], + extra_paths = String[], mpiexec = "mpiexec", abi = nothing, vendor = nothing, @@ -135,6 +136,9 @@ Options: If the library isn't in the library search path, you can specify the full path to the library. +- `extra_paths`: indicate extra directories where to search for the MPI library, + besides the default ones of the dynamic linker. + - `mpiexec`: the MPI launcher executable. The default is `mpiexec`, but some clusters require using the scheduler launcher interface (e.g. `srun` on Slurm, `aprun` on PBS). It is also possible to pass a [`Cmd` @@ -159,6 +163,7 @@ Options: """ function use_system_binary(; library_names=["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpi_cray", "libmpitrampoline"], + extra_paths=String[], mpiexec="mpiexec", abi=nothing, vendor=nothing, @@ -186,12 +191,14 @@ function use_system_binary(; # Set `ZES_ENABLE_SYSMAN` to work around https://github.com/open-mpi/ompi/issues/10142 libmpi = withenv("ZES_ENABLE_SYSMAN" => "1") do - find_library(library_names) + find_library(library_names, extra_paths) end if libmpi == "" error(""" MPI library could not be found with the following name(s): $(library_names) + in the following extra directories (in addition to the default ones): + $(extra_paths) If you want to try different name(s) for the MPI library, use MPIPreferences.use_system_binary(; library_names=[...])""") end