Skip to content

Commit d5468ac

Browse files
committed
Merge pull request #52 from davidanthoff/windows_support
Add support for Microsoft MPI
2 parents 4e3386a + 12075c3 commit d5468ac

File tree

4 files changed

+114
-12
lines changed

4 files changed

+114
-12
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ mpi4py, although we generally follow the C and not the C++ MPI API.
1010

1111
## Installing
1212

13+
### Unix systems (OSX and Linux)
14+
1315
[CMake] is used to piece together the MPI wrapper. Currently a shared
1416
library MPI installation for C and Fortran is required (tested with
1517
[Open MPI] and [MPICH]). To install MPI.jl using the Julia packaging
@@ -28,7 +30,7 @@ which will build and install the wrapper into `$HOME/.julia/vX.Y/MPI`.
2830
#### Platform specific notes:
2931
* If you are trying to build on OSX with Homebrew, the necessary Fortran headers are not included in the OpenMPI bottle. To workaround this you can build OpenMPI from source: `brew install --build-from-source openmpi`
3032

31-
### Overriding the auto-detected MPI version
33+
#### Overriding the auto-detected MPI version
3234

3335
It may be that CMake selects the wrong MPI version, or that CMake
3436
fails to correctly detect and configure your MPI implementation. You
@@ -65,6 +67,15 @@ MPI_INCLUDE_PATH
6567
MPI_LIBRARIES
6668
```
6769

70+
### Windows
71+
72+
You need to install the [Microsoft MPI](https://www.microsoft.com/en-us/download/details.aspx?id=49926) runtime on your system (the SDK is not required). Then simply add the MPI.jl package with
73+
74+
```julia
75+
Pkg.update()
76+
Pkg.add("MPI")
77+
```
78+
6879
## Usage : MPI-Only mode
6980

7081
To run a Julia script with MPI, first make sure that `using MPI` or

deps/build.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using BinDeps
22

33
@BinDeps.setup
44

5-
mpi = library_dependency("juliampi", aliases=["libjuliampi", "libjuliampi.so", "libjuliampi.dylib"])
5+
mpi = library_dependency("juliampi", aliases=["libjuliampi", "libjuliampi.so", "libjuliampi.dylib"], os = :Unix)
66
builddir = joinpath(BinDeps.depsdir(mpi), "build")
77
prefix = joinpath(BinDeps.depsdir(mpi), "usr")
88
src = joinpath(BinDeps.depsdir(mpi), "src")

src/MPI.jl

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,31 @@ module MPI
44

55
using Compat
66

7-
const depfile = joinpath(dirname(@__FILE__), "..", "deps", "src", "compile-time.jl")
8-
isfile(depfile) || error("MPI not properly installed. Please run Pkg.build(\"MPI\")")
7+
@windows_only begin
8+
const depfile = "win_mpiconstants.jl"
9+
end
10+
11+
@unix_only begin
12+
const depfile = joinpath(dirname(@__FILE__), "..", "deps", "src", "compile-time.jl")
13+
isfile(depfile) || error("MPI not properly installed. Please run Pkg.build(\"MPI\")")
14+
end
15+
916
include(depfile)
17+
1018
include("mpi-base.jl")
1119
include("cman.jl")
1220

1321
function __init__()
14-
# need to open libmpi with RTLD_GLOBAL flag for Linux, before any ccall
15-
# cannot use RTLD_DEEPBIND; this leads to segfaults at least on Ubuntu 15.10
16-
@eval const libmpi_handle =
17-
Libdl.dlopen(libmpi, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL)
18-
19-
# look up all symbols ahead of time
20-
for (jname, fname) in _mpi_functions
21-
eval(:(const $jname = Libdl.dlsym(libmpi_handle, $fname)))
22+
@unix_only begin
23+
# need to open libmpi with RTLD_GLOBAL flag for Linux, before any ccall
24+
# cannot use RTLD_DEEPBIND; this leads to segfaults at least on Ubuntu 15.10
25+
@eval const libmpi_handle =
26+
Libdl.dlopen(libmpi, Libdl.RTLD_LAZY | Libdl.RTLD_GLOBAL)
27+
28+
# look up all symbols ahead of time
29+
for (jname, fname) in _mpi_functions
30+
eval(:(const $jname = Libdl.dlsym(libmpi_handle, $fname)))
31+
end
2232
end
2333
end
2434

src/win_mpiconstants.jl

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# These constants were manually copied from the file mpi.h in the Microsoft
2+
# MPI SDK v7
3+
4+
const MPI_BYTE = Int32(0x4c00010d)
5+
const MPI_WCHAR = Int32(0x4c00020e)
6+
const MPI_INT8_T = Int32(0x4c000133)
7+
const MPI_UINT8_T = Int32(0x4c000137)
8+
const MPI_INT16_T = Int32(0x4c000234)
9+
const MPI_UINT16_T = Int32(0x4c000238)
10+
const MPI_INT32_T = Int32(0x4c000435)
11+
const MPI_UINT32_T = Int32(0x4c000439)
12+
const MPI_INT64_T = Int32(0x4c000836)
13+
const MPI_UINT64_T = Int32(0x4c00083a)
14+
const MPI_REAL4 = Int32(0x4c000427)
15+
const MPI_REAL8 = Int32(0x4c000829)
16+
const MPI_COMPLEX8 = Int32(0x4c000828)
17+
const MPI_COMPLEX16 = Int32(0x4c00102a)
18+
const MPI_INTEGER1 = Int32(0x4c00012d)
19+
const MPI_INTEGER2 = Int32(0x4c00022f)
20+
const MPI_INTEGER4 = Int32(0x4c000430)
21+
const MPI_INTEGER8 = Int32(0x4c000831)
22+
const MPI_COMM_NULL = Int32(67108864)
23+
const MPI_COMM_SELF = Int32(1140850689)
24+
const MPI_COMM_WORLD = Int32(1140850688)
25+
const MPI_OP_NULL = Int32(402653184)
26+
const MPI_BAND = Int32(1476395014)
27+
const MPI_BOR = Int32(1476395016)
28+
const MPI_BXOR = Int32(1476395018)
29+
const MPI_LAND = Int32(1476395013)
30+
const MPI_LOR = Int32(1476395015)
31+
const MPI_LXOR = Int32(1476395017)
32+
const MPI_MAX = Int32(1476395009)
33+
const MPI_MAXLOC = Int32(1476395020)
34+
const MPI_MIN = Int32(1476395010)
35+
const MPI_MINLOC = Int32(1476395019)
36+
const MPI_PROD = Int32(1476395012)
37+
const MPI_REPLACE = Int32(1476395021)
38+
const MPI_SUM = Int32(1476395011)
39+
const MPI_REQUEST_NULL = Int32(738197504)
40+
const MPI_STATUS_SIZE = Int32(5)
41+
const MPI_ERROR = Int32(5)
42+
const MPI_SOURCE = Int32(3)
43+
const MPI_TAG = Int32(4)
44+
const MPI_ANY_SOURCE = Int32(-2)
45+
const MPI_ANY_TAG = Int32(-1)
46+
const MPI_TAG_UB = Int32(1681915906)
47+
const MPI_UNDEFINED = Int32(-32766)
48+
const HAVE_MPI_COMM_C2F = false
49+
50+
const MPI_INIT = (:MPI_INIT, "msmpi.dll")
51+
const MPI_COMM_RANK = (:MPI_COMM_RANK, "msmpi.dll")
52+
const MPI_COMM_SIZE = (:MPI_COMM_SIZE, "msmpi.dll")
53+
const MPI_BARRIER = (:MPI_BARRIER, "msmpi.dll")
54+
const MPI_FINALIZE = (:MPI_FINALIZE, "msmpi.dll")
55+
const MPI_BCAST = (:MPI_BCAST, "msmpi.dll")
56+
const MPI_REDUCE = (:MPI_REDUCE, "msmpi.dll")
57+
const MPI_IRECV = (:MPI_IRECV, "msmpi.dll")
58+
const MPI_RECV = (:MPI_RECV, "msmpi.dll")
59+
const MPI_ISEND = (:MPI_ISEND, "msmpi.dll")
60+
const MPI_WAITALL = (:MPI_WAITALL, "msmpi.dll")
61+
const MPI_ALLGATHER = (:MPI_ALLGATHER, "msmpi.dll")
62+
const MPI_ALLGATHERV = (:MPI_ALLGATHERV, "msmpi.dll")
63+
const MPI_ALLTOALL = (:MPI_ALLTOALL, "msmpi.dll")
64+
const MPI_ALLTOALLV = (:MPI_ALLTOALLV, "msmpi.dll")
65+
const MPI_INITIALIZED = (:MPI_INITIALIZED, "msmpi.dll")
66+
const MPI_FINALIZED = (:MPI_FINALIZED, "msmpi.dll")
67+
const MPI_SCATTER = (:MPI_SCATTER, "msmpi.dll")
68+
const MPI_SCATTERV = (:MPI_SCATTERV, "msmpi.dll")
69+
const MPI_SEND = (:MPI_SEND, "msmpi.dll")
70+
const MPI_SCAN = (:MPI_SCAN, "msmpi.dll")
71+
const MPI_EXSCAN = (:MPI_EXSCAN, "msmpi.dll")
72+
const MPI_GATHER = (:MPI_GATHER, "msmpi.dll")
73+
const MPI_GATHERV = (:MPI_GATHERV, "msmpi.dll")
74+
const MPI_COMM_DUP = (:MPI_COMM_DUP, "msmpi.dll")
75+
const MPI_IPROBE = (:MPI_IPROBE, "msmpi.dll")
76+
const MPI_PROBE = (:MPI_PROBE, "msmpi.dll")
77+
const MPI_COMM_FREE = (:MPI_COMM_FREE, "msmpi.dll")
78+
const MPI_GET_COUNT = (:MPI_GET_COUNT, "msmpi.dll")
79+
const MPI_TESTSOME = (:MPI_TESTSOME, "msmpi.dll")
80+
81+
bitstype 32 CComm

0 commit comments

Comments
 (0)