Skip to content

Commit 51657da

Browse files
authored
Merge pull request #558 from JuliaParallel/vc/mpiprefs_docs
Add docs for MPIPreferences
2 parents 2080aed + 1e20309 commit 51657da

File tree

5 files changed

+113
-2
lines changed

5 files changed

+113
-2
lines changed

.github/workflows/PreviewCleanup.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Doc Preview Cleanup
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
doc-preview-cleanup:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout gh-pages branch
12+
uses: actions/checkout@v2
13+
with:
14+
ref: gh-pages
15+
- name: Delete preview and history + push changes
16+
run: |
17+
if [ -d "previews/PR$PRNUM" ]; then
18+
git config user.name "Documenter.jl"
19+
git config user.email "[email protected]"
20+
git rm -rf "previews/PR$PRNUM"
21+
git commit -m "delete preview"
22+
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
23+
git push --force origin gh-pages-new:gh-pages
24+
fi
25+
env:
26+
PRNUM: ${{ github.event.number }}

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
4+
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"

docs/make.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Documenter
22
using MPI
3+
using MPIPreferences
34

45
# generate example markdown
56
EXAMPLES = [
@@ -50,14 +51,15 @@ makedocs(
5051
format = Documenter.HTML(
5152
prettyurls = get(ENV, "CI", nothing) == "true"
5253
),
53-
modules = [MPI],
54+
modules = [MPI, MPIPreferences],
5455
pages = Any[
5556
"index.md",
5657
"configuration.md",
5758
"usage.md",
5859
"knownissues.md",
5960
"Examples" => EXAMPLES,
6061
"Reference" => [
62+
"mpipreferences.md",
6163
"library.md",
6264
"environment.md",
6365
"comm.md",

docs/src/mpipreferences.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MPIPreferences.jl
2+
3+
## Consts
4+
5+
```@docs
6+
MPIPreferences.binary
7+
MPIPreferences.abi
8+
```
9+
10+
## Changing implementations
11+
12+
```@docs
13+
MPIPreferences.use_system_binary
14+
MPIPreferences.use_jll_binary
15+
```
16+
17+
## Utils
18+
19+
```@docs
20+
MPIPreferences.identify_abi
21+
```

lib/MPIPreferences/src/MPIPreferences.jl

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@ module MPIPreferences
22

33
using Preferences, Libdl
44

5+
"""
6+
binary :: String
7+
8+
The currently selected binary.
9+
"""
510
const binary = @load_preference("binary", Sys.iswindows() ? "MicrosoftMPI_jll" : "MPICH_jll")
611

12+
"""
13+
abi :: String
14+
15+
The ABI of the currently selected binary.
16+
"""
717
const abi = if binary == "system"
818
@load_preference("abi")
919
elseif binary == "MicrosoftMPI_jll"
@@ -27,7 +37,20 @@ module System
2737
mpiexec(f;adjust_PATH=true, adjust_LIBPATH=true) = f(`$mpiexec_path`)
2838
end
2939

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)
3154
binary in ["MicrosoftMPI_jll", "MPICH_jll", "OpenMPI_jll", "MPItrampoline_jll"] ||
3255
error("Unknown jll: $binary")
3356
set_preferences!(MPIPreferences,
@@ -38,8 +61,34 @@ function use_jll_binary(binary = Sys.iswindows() ? "MicrosoftMPI_jll" : "MPICH_j
3861
export_prefs=export_prefs,
3962
force=force
4063
)
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
4176
end
4277

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+
"""
4392
function use_system_binary(;
4493
library_names=["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpitrampoline"],
4594
mpiexec="mpiexec",
@@ -66,6 +115,18 @@ function use_system_binary(;
66115
export_prefs=export_prefs,
67116
force=force
68117
)
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
69130
end
70131

71132

0 commit comments

Comments
 (0)