Skip to content

Commit 81fe0f7

Browse files
authored
Merge pull request #302 from JuliaParallel/sb/cuda
CUDA-aware MPI with tests
2 parents 14adebf + 5be8042 commit 81fe0f7

28 files changed

+713
-684
lines changed

.gitlab-ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ include:
2020
- popd
2121
script:
2222
- export JULIA_MPI_PATH="${HOME}/mpi"
23+
- export JULIA_PROJECT="test/cudaenv"
2324
- ${JULIA_MPI_PATH}/bin/ompi_info
2425
- julia -e 'using InteractiveUtils;
2526
versioninfo()'
26-
- julia --project -e 'using Pkg;
27-
Pkg.build();
28-
Pkg.test(coverage=true)'
27+
- julia --color=yes -e 'using Pkg;
28+
Pkg.develop(PackageSpec(path=pwd()));
29+
Pkg.instantiate();
30+
Pkg.build()'
31+
- julia --color=yes test/runtests.jl
32+
2933
.gputest:
3034
extends: .projecttest
3135
variables:

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.9.0"
77
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
88
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
99
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
10+
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1011
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1112
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
1213

@@ -15,9 +16,8 @@ julia = "1"
1516

1617
[extras]
1718
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"
18-
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1919
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2020
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2121

2222
[targets]
23-
test = ["DoubleFloats", "LinearAlgebra", "Pkg", "Test"]
23+
test = ["DoubleFloats", "Pkg", "Test"]

docs/src/usage.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ Hello world, I am rank 2 of 3
2222
Hello world, I am rank 1 of 3
2323
```
2424

25+
## CUDA-aware MPI support
26+
27+
If your MPI implementation has been compiled with CUDA support, then `CuArray`s (from the
28+
[CuArrays.jl](https://github.com/JuliaGPU/CuArrays.jl) package) can be passed directly as
29+
send and receive buffers for point-to-point and collective operations (they may also work
30+
with one-sided operations, but these are not often supported).
31+
2532
## Finalizers
2633

2734
In order to ensure MPI routines are called in the correct order at finalization time,

src/MPI.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module MPI
22

33
using Libdl, Serialization
4+
using Requires
45

56
macro mpichk(expr)
67
@assert expr isa Expr && expr.head == :call && expr.args[1] == :ccall
@@ -21,10 +22,14 @@ function deserialize(x)
2122
Serialization.deserialize(s)
2223
end
2324

24-
primitive type SentinelPtr
25-
Sys.WORD_SIZE
25+
primitive type SentinelPtr Sys.WORD_SIZE
2626
end
27-
Base.cconvert(::Type{Ptr{T}}, sptr::SentinelPtr) where {T} = reinterpret(Ptr{T}, sptr)
27+
28+
primitive type MPIPtr Sys.WORD_SIZE
29+
end
30+
Base.cconvert(::Type{MPIPtr}, x::SentinelPtr) = x
31+
Base.unsafe_convert(::Type{MPIPtr}, x::SentinelPtr) = reinterpret(MPIPtr, x)
32+
2833

2934
function _doc_external(fname)
3035
"""
@@ -65,6 +70,8 @@ function __init__()
6570
if filesize(dlpath(libmpi)) != libmpi_size
6671
error("MPI library has changed, re-run Pkg.build(\"MPI\")")
6772
end
73+
74+
@require CuArrays="3a865a2d-5b23-5a0f-bc46-62713ec82fae" include("cuda.jl")
6875
end
6976

7077
end

0 commit comments

Comments
 (0)