Skip to content

Commit 0fdaaed

Browse files
committed
add msmpi support
1 parent deff290 commit 0fdaaed

File tree

9 files changed

+762
-18
lines changed

9 files changed

+762
-18
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
88
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
99
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1010
MPICH_jll = "7cb0a576-ebde-5e09-9194-50597f1243b4"
11+
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
1112
MPItrampoline_jll = "f1f71cc9-e9ae-5b93-9b94-4fe0e1ad3748"
1213
MicrosoftMPI_jll = "9237b28f-5490-5468-be7b-bb81f5f5e6cf"
1314
OpenMPI_jll = "fe0851c0-eecd-5654-98d4-656369965a5c"

lib/MPIPreferences/src/MPIPreferences.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ function use_system_binary(;
6363
)
6464
end
6565

66+
"""
67+
Get_library_version(libmpi)
6668
69+
Get the version string of the MPI library.
70+
"""
6771
function Get_library_version(libmpi)
6872
# There is no way to query at runtime what the length of the buffer should be.
6973
# https://github.com/mpi-forum/mpi-issues/issues/159

src/MPI.jl

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,36 @@ function _doc_external(fname)
3333
"""
3434
end
3535

36-
try
37-
include(joinpath(dirname(@__DIR__), "deps", "deps.jl"))
38-
include(joinpath(dirname(@__DIR__), "deps", "compile_time_mpi_constants.jl"))
39-
catch e
40-
error("MPI.jl not properly configured, please run `Pkg.build(\"MPI\")`.")
36+
37+
import MPIPreferences
38+
39+
@static if MPIPreferences.binary == "MPICH_jll"
40+
import MPICH_jll: libmpi, mpiexec
41+
else
42+
error("Unknown MPI binarys")
43+
end
44+
45+
include("consts/consts.jl")
46+
using .Consts
47+
48+
# These functions are run after reading the values of the constants above)
49+
const _mpi_load_time_hooks = Any[]
50+
const _finished_loading = Ref(false)
51+
function add_load_time_hook!(f)
52+
@assert !_finished_loading[]
53+
push!(_mpi_load_time_hooks, f)
4154
end
42-
include("define_load_time_mpi_constants.jl")
43-
include("read_load_time_mpi_constants.jl")
55+
function run_load_time_hooks()
56+
@assert !_finished_loading[]
57+
_finished_loading[] = true
58+
for hook in _mpi_load_time_hooks
59+
hook()
60+
end
61+
empty!(_mpi_load_time_hooks)
62+
nothing
63+
end
64+
65+
4466
include("implementations.jl")
4567
include("error.jl")
4668
include("info.jl")
@@ -75,10 +97,6 @@ function __init__()
7597
Libdl.dlopen(libmpi, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL)
7698
end
7799

78-
__init__deps()
79-
80-
read_load_time_mpi_constants()
81-
82100
# disable UCX memory cache, since it doesn't work correctly
83101
# https://github.com/openucx/ucx/issues/5061
84102
if !haskey(ENV, "UCX_MEMTYPE_CACHE")

src/consts/consts.jl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module Consts
2+
3+
export MPI_Aint, MPI_Count, MPI_Offset, MPI_Status,
4+
MPI_Comm, MPI_Datatype, MPI_Errhandler, MPI_File, MPI_Group,
5+
MPI_Info, MPI_Message, MPI_Op, MPI_Request, MPI_Win
6+
7+
import MPIPreferences
8+
import ..libmpi
9+
10+
const initexprs = Any[]
11+
12+
"""
13+
@const_ref name T expr
14+
15+
Defines an constant binding
16+
```julia
17+
const name = Ref{T}()
18+
```
19+
and adds a hook to execute
20+
```julia
21+
name[] = expr
22+
```
23+
at module initialization time.
24+
"""
25+
macro const_ref(name, T, expr)
26+
push!(initexprs, :($name[] = $expr))
27+
:(const $(esc(name)) = Ref{$T}())
28+
end
29+
30+
@static if MPIPreferences.abi == "MPICH"
31+
include("mpich.jl")
32+
elseif MPIPreferences.abi == "OpenMPI"
33+
include("openmpi.jl")
34+
elseif MPIPreferences.abi == "MicrosofMPI"
35+
include("microsoftmpi.jl")
36+
elseif MPIPreferences.abi == "MPItrampoline"
37+
include("mpitrampoline.jl")
38+
else
39+
error("Unknown MPI ABI")
40+
end
41+
42+
@eval function __init__()
43+
$(Expr(:block, initexprs...))
44+
end
45+
46+
end

0 commit comments

Comments
 (0)