From 3c1670feca2d6f241fb43f629b27813aa833e555 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Wed, 25 May 2022 16:07:48 +0200 Subject: [PATCH 01/10] Allow to specigy an MPI ABI file via MPIPreferences --- lib/MPIPreferences/src/MPIPreferences.jl | 16 +++++++++++++- src/consts/consts.jl | 27 ++++++++++++++---------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/lib/MPIPreferences/src/MPIPreferences.jl b/lib/MPIPreferences/src/MPIPreferences.jl index 190c2e6bb..86e7b297c 100644 --- a/lib/MPIPreferences/src/MPIPreferences.jl +++ b/lib/MPIPreferences/src/MPIPreferences.jl @@ -41,6 +41,10 @@ else error("Unknown binary: $binary") end +# Default is empty string, indicating that the information in `abi` should be used to load the +# correct ABI file +const abi_file = @load_preference("abi_file", "") + module System export libmpi, mpiexec using Preferences @@ -115,6 +119,10 @@ Options: - `abi`: the ABI of the MPI library. By default this is determined automatically using [`identify_abi`](@ref). See [`abi`](@ref) for currently supported values. +- `abi_file`: the ABI file for the MPI library. By default, for ABIs supported by MPI.jl, the + corresponding ABI file is loaded automatically. This argument allows one to override the + automatic selection, e.g., to provide an ABI file for an MPI ABI unknown to MPI.jl. + - `export_prefs`: if `true`, the preferences into the `Project.toml` instead of `LocalPreferences.toml`. - `force`: if `true`, the preferences are set even if they are already set. @@ -123,6 +131,7 @@ function use_system_binary(; library_names=["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpitrampoline"], mpiexec="mpiexec", abi=nothing, + abi_file=nothing, export_prefs=false, force=true, ) @@ -137,6 +146,11 @@ function use_system_binary(; if isnothing(abi) abi = identify_abi(libmpi) end + if isnothing(abi_file) + abi_file = "" + else + abi_file = abspath(abi_file) + end if mpiexec isa Cmd mpiexec = collect(mpiexec) end @@ -149,7 +163,7 @@ function use_system_binary(; force=force ) - @warn "The underlying MPI implementation has changed. You will need to restart Julia for this change to take effect" binary libmpi abi mpiexec + @warn "The underlying MPI implementation has changed. You will need to restart Julia for this change to take effect" binary libmpi abi abi_file mpiexec if VERSION <= v"1.6.5" || VERSION == v"1.7.0" @warn """ diff --git a/src/consts/consts.jl b/src/consts/consts.jl index e1a98b2b3..038c346d4 100644 --- a/src/consts/consts.jl +++ b/src/consts/consts.jl @@ -27,18 +27,23 @@ macro const_ref(name, T, expr) :(const $(esc(name)) = Ref{$T}()) end -@static if MPIPreferences.abi == "MPICH" - include("mpich.jl") -elseif MPIPreferences.abi == "OpenMPI" - include("openmpi.jl") -elseif MPIPreferences.abi == "MicrosoftMPI" - include("microsoftmpi.jl") -elseif MPIPreferences.abi == "MPItrampoline" - include("mpitrampoline.jl") -elseif MPIPreferences.abi == "HPE MPT" - include("mpt.jl") +# If `abi_file` is empty, choose ABI file based on ABI string, otherwise load the specified file +@static if MPIPreferences.abi_file == "" + @static if MPIPreferences.abi == "MPICH" + include("mpich.jl") + elseif MPIPreferences.abi == "OpenMPI" + include("openmpi.jl") + elseif MPIPreferences.abi == "MicrosoftMPI" + include("microsoftmpi.jl") + elseif MPIPreferences.abi == "MPItrampoline" + include("mpitrampoline.jl") + elseif MPIPreferences.abi == "HPE MPT" + include("mpt.jl") + else + error("Unknown MPI ABI $(MPIPreferences.abi)") + end else - error("Unknown MPI ABI $(MPIPreferences.abi)") + include(MPIPreferences.abi_file) end # Initialize the ref constants from the library. From 9b7091e8689099990248626482156eb6ac277961 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Wed, 25 May 2022 16:18:08 +0200 Subject: [PATCH 02/10] Amend docstring --- lib/MPIPreferences/src/MPIPreferences.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/MPIPreferences/src/MPIPreferences.jl b/lib/MPIPreferences/src/MPIPreferences.jl index 86e7b297c..da2bd2c59 100644 --- a/lib/MPIPreferences/src/MPIPreferences.jl +++ b/lib/MPIPreferences/src/MPIPreferences.jl @@ -98,6 +98,7 @@ end library_names = ["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpitrampoline"], mpiexec = "mpiexec", abi = nothing, + abi_file = nothing, export_prefs = false, force = true) From edaf03b747613ea00a4ef088924d98673f1331a5 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Wed, 25 May 2022 16:32:05 +0200 Subject: [PATCH 03/10] Add section to docs --- docs/src/configuration.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/src/configuration.md b/docs/src/configuration.md index 2d4a62818..0a9bb4df5 100644 --- a/docs/src/configuration.md +++ b/docs/src/configuration.md @@ -35,6 +35,9 @@ standard or later. The following MPI implementations should work out-of-the-box - [Fujitsu MPI](https://www.fujitsu.com/global/about/resources/publications/technicalreview/2020-03/article07.html#cap-03) - [HPE MPT/HMPT](https://support.hpe.com/hpesc/public/docDisplay?docLocale=en_US&docId=a00105727en_us) +If you are using an MPI implementation that is not ABI-compatible with any one +of these, please read the section on how to use a [Custom ABI file](@ref) below. + ### Configuration Run `MPIPreferences.use_system_binary()`. This will attempt to locate and to identify any available MPI implementation, and create a file called `LocalPreferences.toml` adjacent to the current `Project.toml`. @@ -100,6 +103,24 @@ Preferences are merged across the Julia load path, such that it is feasible to p that will take precedent by modifying the local `Project.toml` or by providing a `LocalPreferences.toml` file. + +### Custom ABI file +If you want to use an MPI implementation not officially supported by MPI.jl, you +need to create your own ABI file with all relevant MPI constants. The files for supported +ABIs are stored in the `src/consts/` folder, e.g., +[`mpich.jl`](https://github.com/JuliaParallel/MPI.jl/blob/master/src/consts/mpich.jl) +for MPICH-compatible implementations. To create your own ABI file, it is +advisable to start with an existing constants file (e.g., for MPICH) and then +adapt each entry to the contents of your MPI implementations's `mpi.h` C header +file. You can use [`MPIPreferences.use_system_binary`](@ref) to configure MPI.jl +to use your custom file by providing the path via the `abi_file` keyword +argument, e.g., +```shell +julia --project -e 'using MPIPreferences; MPIPreferences.use_system_binary(; abi_file="path/to/abifile.jl)' +``` +You need to restart Julia for the change to take effect. + + ## Using an alternative JLL-provided MPI library The following MPI implementations are provided as JLL packages and automatically obtained when installing MPI.jl: From 904d2520e38aacc9d8bd6e2ab44dc09ad8f3b605 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Wed, 25 May 2022 16:43:54 +0200 Subject: [PATCH 04/10] Give example in docs --- docs/src/configuration.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/src/configuration.md b/docs/src/configuration.md index 0a9bb4df5..c87a4a2a9 100644 --- a/docs/src/configuration.md +++ b/docs/src/configuration.md @@ -36,7 +36,7 @@ standard or later. The following MPI implementations should work out-of-the-box - [HPE MPT/HMPT](https://support.hpe.com/hpesc/public/docDisplay?docLocale=en_US&docId=a00105727en_us) If you are using an MPI implementation that is not ABI-compatible with any one -of these, please read the section on how to use a [Custom ABI file](@ref) below. +of these, please read the section on [Supporting an unknown ABI](@ref) below. ### Configuration @@ -104,7 +104,7 @@ Preferences are merged across the Julia load path, such that it is feasible to p `LocalPreferences.toml` file. -### Custom ABI file +### Supporting an unknown ABI If you want to use an MPI implementation not officially supported by MPI.jl, you need to create your own ABI file with all relevant MPI constants. The files for supported ABIs are stored in the `src/consts/` folder, e.g., @@ -112,7 +112,30 @@ ABIs are stored in the `src/consts/` folder, e.g., for MPICH-compatible implementations. To create your own ABI file, it is advisable to start with an existing constants file (e.g., for MPICH) and then adapt each entry to the contents of your MPI implementations's `mpi.h` C header -file. You can use [`MPIPreferences.use_system_binary`](@ref) to configure MPI.jl +file. + +For example, if your `mpi.h` header file contains something like +```c +typedef unsigned int MPI_Request; +enum { + MPI_REQUEST_NULL = 0 +}; + +#define MPI_ARGV_NULL ((char**) NULL) +``` +you need to put the corresponding entries in your ABI file `abi_file.jl`: +```julia +const MPI_Request = Cuint +@const_ref MPI_REQUEST_NULL MPI_Request 0 + +@const_ref MPI_ARGV_NULL Ptr{Cvoid} C_NULL +``` +As you can see, the syntax of such a Julia ABI file is non-trivial, thus the +recommendation to start with an existing ABI file. +Please note that sometimes information is also stored in ancillary header files (e.g., +`mpi_types.h` or `mpi_ext.h`). + +You can then use [`MPIPreferences.use_system_binary`](@ref) to configure MPI.jl to use your custom file by providing the path via the `abi_file` keyword argument, e.g., ```shell From ff29239bb47109e3865d71fac40fca24f405cdd8 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Sun, 29 May 2022 19:45:28 +0200 Subject: [PATCH 05/10] Add sentence on using standard Julia alises for C types in ABI file --- docs/src/configuration.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/src/configuration.md b/docs/src/configuration.md index c87a4a2a9..1a84eb320 100644 --- a/docs/src/configuration.md +++ b/docs/src/configuration.md @@ -132,6 +132,9 @@ const MPI_Request = Cuint ``` As you can see, the syntax of such a Julia ABI file is non-trivial, thus the recommendation to start with an existing ABI file. +It is further advisable to always use the corresponding Julia alias for +standard C types, e.g., `Cuint` for `unsigned int` or `Clonglong` for `long +long`. Please note that sometimes information is also stored in ancillary header files (e.g., `mpi_types.h` or `mpi_ext.h`). From 13af812f9930e1e06074749b391f79809235dd69 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Mon, 30 May 2022 09:15:53 +0200 Subject: [PATCH 06/10] Add `abi_file` to `set_preferences!` --- lib/MPIPreferences/src/MPIPreferences.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/MPIPreferences/src/MPIPreferences.jl b/lib/MPIPreferences/src/MPIPreferences.jl index da2bd2c59..e3808b63e 100644 --- a/lib/MPIPreferences/src/MPIPreferences.jl +++ b/lib/MPIPreferences/src/MPIPreferences.jl @@ -159,6 +159,7 @@ function use_system_binary(; "binary" => "system", "libmpi" => libmpi, "abi" => abi, + "abi_file" => abi_file, "mpiexec" => mpiexec, export_prefs=export_prefs, force=force From 162653aff6f073148a1eeca5fcf47ee857e894b8 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Mon, 30 May 2022 09:50:19 +0200 Subject: [PATCH 07/10] Rename `abi_file` --> `abi_source_file` --- docs/src/configuration.md | 6 +++--- lib/MPIPreferences/src/MPIPreferences.jl | 18 +++++++++--------- src/consts/consts.jl | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/src/configuration.md b/docs/src/configuration.md index d16296321..bfdd8dc7e 100644 --- a/docs/src/configuration.md +++ b/docs/src/configuration.md @@ -123,7 +123,7 @@ enum { #define MPI_ARGV_NULL ((char**) NULL) ``` -you need to put the corresponding entries in your ABI file `abi_file.jl`: +you need to put the corresponding entries in your ABI file `abi_source_file.jl`: ```julia const MPI_Request = Cuint @const_ref MPI_REQUEST_NULL MPI_Request 0 @@ -139,10 +139,10 @@ Please note that sometimes information is also stored in ancillary header files `mpi_types.h` or `mpi_ext.h`). You can then use [`MPIPreferences.use_system_binary`](@ref) to configure MPI.jl -to use your custom file by providing the path via the `abi_file` keyword +to use your custom file by providing the path via the `abi_source_file` keyword argument, e.g., ```shell -julia --project -e 'using MPIPreferences; MPIPreferences.use_system_binary(; abi_file="path/to/abifile.jl)' +julia --project -e 'using MPIPreferences; MPIPreferences.use_system_binary(; abi_source_file="path/to/file.jl)' ``` You need to restart Julia for the change to take effect. diff --git a/lib/MPIPreferences/src/MPIPreferences.jl b/lib/MPIPreferences/src/MPIPreferences.jl index 5d26755a7..e4815e89d 100644 --- a/lib/MPIPreferences/src/MPIPreferences.jl +++ b/lib/MPIPreferences/src/MPIPreferences.jl @@ -47,7 +47,7 @@ end # Default is empty string, indicating that the information in `abi` should be used to load the # correct ABI file -const abi_file = @load_preference("abi_file", "") +const abi_source_file = @load_preference("abi_source_file", "") """ MPIPreferences.use_jll_binary(binary; export_prefs=false, force=true) @@ -93,7 +93,7 @@ end library_names = ["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpitrampoline"], mpiexec = "mpiexec", abi = nothing, - abi_file = nothing, + abi_source_file = nothing, export_prefs = false, force = true) @@ -115,7 +115,7 @@ Options: - `abi`: the ABI of the MPI library. By default this is determined automatically using [`identify_abi`](@ref). See [`abi`](@ref) for currently supported values. -- `abi_file`: the ABI file for the MPI library. By default, for ABIs supported by MPI.jl, the +- `abi_source_file`: the ABI file for the MPI library. By default, for ABIs supported by MPI.jl, the corresponding ABI file is loaded automatically. This argument allows one to override the automatic selection, e.g., to provide an ABI file for an MPI ABI unknown to MPI.jl. @@ -127,7 +127,7 @@ function use_system_binary(; library_names=["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpitrampoline"], mpiexec="mpiexec", abi=nothing, - abi_file=nothing, + abi_source_file=nothing, export_prefs=false, force=true, ) @@ -142,10 +142,10 @@ function use_system_binary(; if isnothing(abi) abi = identify_abi(libmpi) end - if isnothing(abi_file) - abi_file = "" + if isnothing(abi_source_file) + abi_source_file = "" else - abi_file = abspath(abi_file) + abi_source_file = abspath(abi_source_file) end if mpiexec isa Cmd mpiexec = collect(mpiexec) @@ -154,13 +154,13 @@ function use_system_binary(; "binary" => binary, "libmpi" => libmpi, "abi" => abi, - "abi_file" => abi_file, + "abi_source_file" => abi_source_file, "mpiexec" => mpiexec, export_prefs=export_prefs, force=force ) - @warn "The underlying MPI implementation has changed. You will need to restart Julia for this change to take effect" binary libmpi abi abi_file mpiexec + @warn "The underlying MPI implementation has changed. You will need to restart Julia for this change to take effect" binary libmpi abi abi_source_file mpiexec if VERSION <= v"1.6.5" || VERSION == v"1.7.0" @warn """ diff --git a/src/consts/consts.jl b/src/consts/consts.jl index 038c346d4..b66cff3f0 100644 --- a/src/consts/consts.jl +++ b/src/consts/consts.jl @@ -27,8 +27,8 @@ macro const_ref(name, T, expr) :(const $(esc(name)) = Ref{$T}()) end -# If `abi_file` is empty, choose ABI file based on ABI string, otherwise load the specified file -@static if MPIPreferences.abi_file == "" +# If `abi_source_file` is empty, choose ABI file based on ABI string, otherwise load the specified file +@static if MPIPreferences.abi_source_file == "" @static if MPIPreferences.abi == "MPICH" include("mpich.jl") elseif MPIPreferences.abi == "OpenMPI" @@ -43,7 +43,7 @@ end error("Unknown MPI ABI $(MPIPreferences.abi)") end else - include(MPIPreferences.abi_file) + include(MPIPreferences.abi_source_file) end # Initialize the ref constants from the library. From 9a5d0a9db663839d2a1b2c54c85bf9ba6467b115 Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Tue, 31 May 2022 09:25:56 +0200 Subject: [PATCH 08/10] Use `nothing` instead of "custom" as sentinel for using a custom ABI source file --- lib/MPIPreferences/src/MPIPreferences.jl | 21 ++++++++++------- src/consts/consts.jl | 29 +++++++++++------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/MPIPreferences/src/MPIPreferences.jl b/lib/MPIPreferences/src/MPIPreferences.jl index e4815e89d..512b63df6 100644 --- a/lib/MPIPreferences/src/MPIPreferences.jl +++ b/lib/MPIPreferences/src/MPIPreferences.jl @@ -69,6 +69,7 @@ function use_jll_binary(binary = Sys.iswindows() ? "MicrosoftMPI_jll" : "MPICH_j "binary" => binary, "libmpi" => nothing, "abi" => nothing, + "abi_source_file" => nothing, "mpiexec" => nothing; export_prefs=export_prefs, force=force @@ -116,8 +117,9 @@ Options: using [`identify_abi`](@ref). See [`abi`](@ref) for currently supported values. - `abi_source_file`: the ABI file for the MPI library. By default, for ABIs supported by MPI.jl, the - corresponding ABI file is loaded automatically. This argument allows one to override the - automatic selection, e.g., to provide an ABI file for an MPI ABI unknown to MPI.jl. + corresponding ABI file is loaded automatically based on the value of `abi`. This argument allows + one to override the automatic selection, e.g., to provide an ABI file for an MPI ABI unknown to + MPI.jl. If specifying an ABI file, `abi` must be `nothing`. - `export_prefs`: if `true`, the preferences into the `Project.toml` instead of `LocalPreferences.toml`. @@ -140,12 +142,15 @@ function use_system_binary(; error("MPI library could not be found") end if isnothing(abi) - abi = identify_abi(libmpi) - end - if isnothing(abi_source_file) - abi_source_file = "" - else - abi_source_file = abspath(abi_source_file) + if isnothing(abi_source_file) + # If ABI is `nothing` and ABI source file is `nothing`, auto-detect ABI + abi = identify_abi(libmpi) + else !isnothing(abi_source_file) + # If ABI is `nothing` and ABI source file is not `nothing`, use custom ABI source file + abi_source_file = abspath(abi_source_file) + end + elseif !isnothing(abi) && !isnothing(abi_source_file) + error("cannot set ABI and ABI source file simultaneously") end if mpiexec isa Cmd mpiexec = collect(mpiexec) diff --git a/src/consts/consts.jl b/src/consts/consts.jl index b66cff3f0..e08431f31 100644 --- a/src/consts/consts.jl +++ b/src/consts/consts.jl @@ -27,23 +27,20 @@ macro const_ref(name, T, expr) :(const $(esc(name)) = Ref{$T}()) end -# If `abi_source_file` is empty, choose ABI file based on ABI string, otherwise load the specified file -@static if MPIPreferences.abi_source_file == "" - @static if MPIPreferences.abi == "MPICH" - include("mpich.jl") - elseif MPIPreferences.abi == "OpenMPI" - include("openmpi.jl") - elseif MPIPreferences.abi == "MicrosoftMPI" - include("microsoftmpi.jl") - elseif MPIPreferences.abi == "MPItrampoline" - include("mpitrampoline.jl") - elseif MPIPreferences.abi == "HPE MPT" - include("mpt.jl") - else - error("Unknown MPI ABI $(MPIPreferences.abi)") - end -else +@static if MPIPreferences.abi == "MPICH" + include("mpich.jl") +elseif MPIPreferences.abi == "OpenMPI" + include("openmpi.jl") +elseif MPIPreferences.abi == "MicrosoftMPI" + include("microsoftmpi.jl") +elseif MPIPreferences.abi == "MPItrampoline" + include("mpitrampoline.jl") +elseif MPIPreferences.abi == "HPE MPT" + include("mpt.jl") +elseif isnothing(MPIPreferences.abi) include(MPIPreferences.abi_source_file) +else + error("Unknown MPI ABI $(MPIPreferences.abi)") end # Initialize the ref constants from the library. From b4de3bded1ef03eefe5e83f2197264bc987c870b Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Tue, 31 May 2022 11:10:00 +0200 Subject: [PATCH 09/10] Add comment --- src/consts/consts.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/consts/consts.jl b/src/consts/consts.jl index e08431f31..f7859b88a 100644 --- a/src/consts/consts.jl +++ b/src/consts/consts.jl @@ -27,6 +27,8 @@ macro const_ref(name, T, expr) :(const $(esc(name)) = Ref{$T}()) end +# Select packaged-provided ABI source file based on the value of the MPI ABI. If ABI is `nothing`, +# use custom ABI source file provided by user @static if MPIPreferences.abi == "MPICH" include("mpich.jl") elseif MPIPreferences.abi == "OpenMPI" From ff798c31b1fc7942591db58bd10bb00a5e95e5bd Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Sun, 5 Jun 2022 11:18:37 +0200 Subject: [PATCH 10/10] Indicate custom ABI file using `abi="custom"` --- lib/MPIPreferences/src/MPIPreferences.jl | 30 ++++++++++++++---------- src/consts/consts.jl | 4 ++-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/MPIPreferences/src/MPIPreferences.jl b/lib/MPIPreferences/src/MPIPreferences.jl index 512b63df6..24acbb5ab 100644 --- a/lib/MPIPreferences/src/MPIPreferences.jl +++ b/lib/MPIPreferences/src/MPIPreferences.jl @@ -26,6 +26,7 @@ The ABI of the currently selected binary. Supported values are: - `"MicrosoftMPI"`: Microsoft MPI - `"MPItrampoline"`: MPItrampoline - `"HPE MPT"`: HPE MPT +- `"custom"`: ABI is defined via custom ABI source file """ const abi = if binary == "system" @load_preference("abi") @@ -45,9 +46,14 @@ end include("system.jl") end -# Default is empty string, indicating that the information in `abi` should be used to load the -# correct ABI file -const abi_source_file = @load_preference("abi_source_file", "") +""" + MPIPreferences.abi_source_file :: Union{String, Nothing} + +Path to a custom ABI source file holding constants for an MPI implementation not supported +out-of-the-box by MPI.jl. Will only be used if MPI binary is set to `"system"` and the ABI is set to +`"custom"` in [`use_system_binary`](@ref). +""" +const abi_source_file = @load_preference("abi_source_file") """ MPIPreferences.use_jll_binary(binary; export_prefs=false, force=true) @@ -119,7 +125,7 @@ Options: - `abi_source_file`: the ABI file for the MPI library. By default, for ABIs supported by MPI.jl, the corresponding ABI file is loaded automatically based on the value of `abi`. This argument allows one to override the automatic selection, e.g., to provide an ABI file for an MPI ABI unknown to - MPI.jl. If specifying an ABI file, `abi` must be `nothing`. + MPI.jl. If specifying an ABI file, `abi` must not be set simultaneously. - `export_prefs`: if `true`, the preferences into the `Project.toml` instead of `LocalPreferences.toml`. @@ -128,8 +134,8 @@ Options: function use_system_binary(; library_names=["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpitrampoline"], mpiexec="mpiexec", - abi=nothing, abi_source_file=nothing, + abi=isnothing(abi_source_file) ? nothing : "custom", export_prefs=false, force=true, ) @@ -142,15 +148,13 @@ function use_system_binary(; error("MPI library could not be found") end if isnothing(abi) - if isnothing(abi_source_file) - # If ABI is `nothing` and ABI source file is `nothing`, auto-detect ABI - abi = identify_abi(libmpi) - else !isnothing(abi_source_file) - # If ABI is `nothing` and ABI source file is not `nothing`, use custom ABI source file - abi_source_file = abspath(abi_source_file) + abi = identify_abi(libmpi) + end + if !isnothing(abi_source_file) + if abi != "custom" + error("`abi` must be set to `\"custom\"` when using ABI source file") end - elseif !isnothing(abi) && !isnothing(abi_source_file) - error("cannot set ABI and ABI source file simultaneously") + abi_source_file = abspath(abi_source_file) end if mpiexec isa Cmd mpiexec = collect(mpiexec) diff --git a/src/consts/consts.jl b/src/consts/consts.jl index f7859b88a..485a4878c 100644 --- a/src/consts/consts.jl +++ b/src/consts/consts.jl @@ -27,7 +27,7 @@ macro const_ref(name, T, expr) :(const $(esc(name)) = Ref{$T}()) end -# Select packaged-provided ABI source file based on the value of the MPI ABI. If ABI is `nothing`, +# Select package-provided ABI source file based on the value of the MPI ABI. If ABI is "custom", # use custom ABI source file provided by user @static if MPIPreferences.abi == "MPICH" include("mpich.jl") @@ -39,7 +39,7 @@ elseif MPIPreferences.abi == "MPItrampoline" include("mpitrampoline.jl") elseif MPIPreferences.abi == "HPE MPT" include("mpt.jl") -elseif isnothing(MPIPreferences.abi) +elseif MPIPreferences.abi == "custom" include(MPIPreferences.abi_source_file) else error("Unknown MPI ABI $(MPIPreferences.abi)")