@@ -2,8 +2,18 @@ module MPIPreferences
2
2
3
3
using Preferences, Libdl
4
4
5
+ """
6
+ binary :: String
7
+
8
+ The currently selected binary.
9
+ """
5
10
const binary = @load_preference (" binary" , Sys. iswindows () ? " MicrosoftMPI_jll" : " MPICH_jll" )
6
11
12
+ """
13
+ abi :: String
14
+
15
+ The ABI of the currently selected binary.
16
+ """
7
17
const abi = if binary == " system"
8
18
@load_preference (" abi" )
9
19
elseif binary == " MicrosoftMPI_jll"
@@ -27,7 +37,20 @@ module System
27
37
mpiexec (f;adjust_PATH= true , adjust_LIBPATH= true ) = f (` $mpiexec_path ` )
28
38
end
29
39
30
- function use_jll_binary (binary = Sys. iswindows () ? " MicrosoftMPI_jll" : " MPICH_jll" ;export_prefs= false , force= true )
40
+ """
41
+ use_jll_binary(binary; export_prefs=false, force=true)
42
+
43
+ Switches the underlying MPI implementation to one provided by JLL packages.
44
+ Available options are:
45
+ - `MicrosoftMPI_jll` (Only option and default on Winddows)
46
+ - `MPICH_jll` (Default on every other platform)
47
+ - `OpenMPI_jll`
48
+ - `MPItrampoline_jll`
49
+
50
+ The `export_prefs` option determines whether the preferences being set should be stored
51
+ within `LocalPreferences.toml` or `Project.toml`.
52
+ """
53
+ function use_jll_binary (binary = Sys. iswindows () ? " MicrosoftMPI_jll" : " MPICH_jll" ; export_prefs= false , force= true )
31
54
binary in [" MicrosoftMPI_jll" , " MPICH_jll" , " OpenMPI_jll" , " MPItrampoline_jll" ] ||
32
55
error (" Unknown jll: $binary " )
33
56
set_preferences! (MPIPreferences,
@@ -38,8 +61,34 @@ function use_jll_binary(binary = Sys.iswindows() ? "MicrosoftMPI_jll" : "MPICH_j
38
61
export_prefs= export_prefs,
39
62
force= force
40
63
)
64
+
65
+ @warn " The underlying MPI implementation has changed. You will need to restart Julia for this change to take effect" binary
66
+
67
+ if VERSION <= v " 1.6.5" || VERSION == v " 1.7.0"
68
+ @warn """
69
+ Due to a bug in Julia (until 1.6.5 and 1.7.1), setting preferences in transitive dependencies
70
+ is broken (https://github.com/JuliaPackaging/Preferences.jl/issues/24). To fix this either update
71
+ your version of Julia, or add MPIPreferences as a direct dependency to your project.
72
+ """
73
+ end
74
+
75
+ return nothing
41
76
end
42
77
78
+
79
+ """
80
+ use_system_binary(;library_names, mpiexec="mpiexec", abi=nothing, export_prefs=false, force=true)
81
+
82
+ Switches the underlying MPI implementation to a system provided one. We will
83
+ search for a matching library with the given `library_names`. You can provide
84
+ a path to `mpiexec` if the system provides a different one, or if it is not in
85
+ the system path.
86
+
87
+ The `abi` of the found library is determined automatically using [`identify_abi`](@ref).
88
+
89
+ The `export_prefs` option determines whether the preferences being set should be stored
90
+ within `LocalPreferences.toml` or `Project.toml`.
91
+ """
43
92
function use_system_binary (;
44
93
library_names= [" libmpi" , " libmpi_ibm" , " msmpi" , " libmpich" , " libmpitrampoline" ],
45
94
mpiexec= " mpiexec" ,
@@ -66,6 +115,18 @@ function use_system_binary(;
66
115
export_prefs= export_prefs,
67
116
force= force
68
117
)
118
+
119
+ @warn " The underlying MPI implementation has changed. You will need to restart Julia for this change to take effect" libmpi abi mpiexec
120
+
121
+ if VERSION <= v " 1.6.5" || VERSION == v " 1.7.0"
122
+ @warn """
123
+ Due to a bug in Julia (until 1.6.5 and 1.7.1), setting preferences in transitive dependencies
124
+ is broken (https://github.com/JuliaPackaging/Preferences.jl/issues/24). To fix this either update
125
+ your version of Julia, or add MPIPreferences as a direct dependency to your project.
126
+ """
127
+ end
128
+
129
+ return nothing
69
130
end
70
131
71
132
0 commit comments