Skip to content

Commit 9565445

Browse files
authored
Merge pull request #276 from JuliaParallel/sb/winfix
Disable custom reduction operators on Windows, fix misc Windows and nightly issues.
2 parents a76657b + 4a8b5e8 commit 9565445

File tree

7 files changed

+42
-45
lines changed

7 files changed

+42
-45
lines changed

.appveyor.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ platform:
88
- x86 # 32-bit
99
- x64 # 64-bit
1010

11-
matrix:
12-
allow_failures:
13-
- platform: x86
14-
1511
branches:
1612
only:
1713
- master

src/cman.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Base: kill
22
export MPIManager, launch, manage, kill, procs, connect, mpiprocs, @mpi_do
33
export TransportMode, MPI_ON_WORKERS, TCP_TRANSPORT_ALL, MPI_TRANSPORT_ALL
44
using Distributed
5-
import Sockets: connect, listenany, accept, IPv4, getsockname, getaddrinfo
5+
import Sockets: connect, listenany, accept, IPv4, getsockname, getaddrinfo, wait_connected
66

77

88

@@ -200,7 +200,7 @@ function setup_worker(host, port, cookie)
200200
!MPI.Initialized() && MPI.Init()
201201
# Connect to the manager
202202
io = connect(IPv4(host), port)
203-
Base.wait_connected(io)
203+
wait_connected(io)
204204
redirect_stdout(io)
205205
redirect_stderr(io)
206206

src/info.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function Base.getindex(info::Info, key::Symbol)
8484
@assert isascii(skey) && length(skey) <= MPI_MAX_INFO_KEY
8585
valuelen = Ref{Cint}()
8686
flag = Ref{Cint}()
87+
# int MPI_Info_get_valuelen(MPI_Info info, const char *key, int *valuelen, int *flag)
8788
@mpichk ccall((:MPI_Info_get_valuelen, libmpi), Cint,
8889
(MPI_Info, Cstring, Ptr{Cint}, Ptr{Cint}),
8990
info, skey, valuelen, flag)
@@ -92,12 +93,18 @@ function Base.getindex(info::Info, key::Symbol)
9293
throw(KeyError(key))
9394
end
9495

96+
# According to the MPI standard:
97+
# "`valuelen` should be one less than the amount of allocated
98+
# space to allow for the null terminator."
99+
# But MS-MPI will insists on setting the `n`th character as NUL,
100+
# so we simply pad both to avoid problems.
95101
n = valuelen[]
96-
buffer = Vector{UInt8}(undef, n)
102+
buffer = Vector{UInt8}(undef, n+2)
103+
# int MPI_Info_get(MPI_Info info, const char *key, int valuelen, char *value, int *flag)
97104
@mpichk ccall((:MPI_Info_get, libmpi), Cint,
98105
(MPI_Info, Cstring, Cint, Ptr{UInt8}, Ptr{Cint}),
99-
info, skey, n, buffer, flag)
100-
return String(buffer)
106+
info, skey, n+1, buffer, flag)
107+
return String(resize!(buffer,n))
101108
end
102109

103110
function Base.delete!(info::Info,key::Symbol)
@@ -118,7 +125,7 @@ function Base.length(info::Info)
118125
end
119126

120127
function nthkey(info::Info, n::Integer)
121-
buffer = Vector{UInt8}(undef, MPI_MAX_INFO_KEY)
128+
buffer = Vector{UInt8}(undef, MPI_MAX_INFO_KEY+1)
122129
@mpichk ccall((:MPI_Info_get_nthkey, libmpi), Cint,
123130
(MPI_Info, Cint, Ptr{UInt8}), info, n, buffer)
124131
i = findfirst(isequal(UInt8(0)), buffer)

src/operators.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ function _mpi_user_function(_a::Ptr{Nothing}, _b::Ptr{Nothing}, _len::Ptr{Cint},
4444
end
4545

4646
function user_op(opfunc::Function)
47+
if Sys.iswindows() && Sys.WORD_SIZE == 32
48+
error("Custom reduction operators are not supported on 32-bit Windows.\nSee https://github.com/JuliaParallel/MPI.jl/issues/246 for more details.")
49+
end
50+
4751
# we must initialize these at runtime, but it can't be done in __init__
4852
# since MPI.Init is not called yet. So we do it lazily here:
4953
if _user_op.val == OP_NULL.val

test/runtests.jl

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ juliafiles = ["test_cman_julia.jl"]
1616
# Files to run with mpiexec -n 1
1717
singlefiles = ["test_spawn.jl"]
1818

19-
excludedfiles = String[]
20-
if Sys.iswindows()
21-
push!(excludedfiles, "test_info.jl")
22-
push!(excludedfiles, "test_onesided.jl")
23-
push!(excludedfiles, "test_finalize_atexit.jl")
24-
if Sys.WORD_SIZE == 32
25-
push!(excludedfiles, "test_spawn.jl")
26-
end
27-
end
28-
2919
function runtests()
3020
nprocs = clamp(Sys.CPU_THREADS, 2, 4)
3121
exename = joinpath(Sys.BINDIR, Base.julia_exename())
@@ -35,37 +25,25 @@ function runtests()
3525

3626
extra_args = []
3727
@static if !Sys.iswindows()
38-
if occursin( "OpenRTE", read(`mpiexec --version`, String))
28+
if occursin( "OpenRTE", read(`mpiexec --version`, String))
3929
push!(extra_args,"--oversubscribe")
4030
end
4131
end
4232

4333
nfail = 0
4434
printstyled("Running MPI.jl tests\n"; color=:white)
4535
for f in testfiles
46-
if f excludedfiles
47-
println("Skipping disabled test $f")
48-
continue
36+
coverage_opt = coverage_opts[Base.JLOptions().code_coverage]
37+
if f singlefiles
38+
run(`mpiexec $extra_args -n 1 $exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
39+
elseif f juliafiles
40+
run(`$exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
41+
else
42+
run(`mpiexec $extra_args -n $nprocs $exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
43+
end
44+
Base.with_output_color(:green,stdout) do io
45+
println(io,"\tSUCCESS: $f")
4946
end
50-
# try
51-
coverage_opt = coverage_opts[Base.JLOptions().code_coverage]
52-
if f singlefiles
53-
run(`mpiexec $extra_args -n 1 $exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
54-
elseif f juliafiles
55-
run(`$exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
56-
else
57-
run(`mpiexec $extra_args -n $nprocs $exename --code-coverage=$coverage_opt $(joinpath(testdir, f))`)
58-
end
59-
Base.with_output_color(:green,stdout) do io
60-
println(io,"\tSUCCESS: $f")
61-
end
62-
# catch ex
63-
# Base.with_output_color(:red,stderr) do io
64-
# println(io,"\tError: $(joinpath(testdir, f))")
65-
# showerror(io,ex,backtrace())
66-
# end
67-
# nfail += 1
68-
# end
6947
end
7048
return nfail
7149
end

test/test_allreduce.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ MPI.Init()
55

66
comm_size = MPI.Comm_size(MPI.COMM_WORLD)
77

8+
if Sys.iswindows() && Sys.WORD_SIZE == 32
9+
operators = [MPI.SUM, +]
10+
else
11+
operators = [MPI.SUM, +, (x,y) -> 2x+y-x]
12+
end
13+
814
for typ=[Int]
915
for dims = [1, 2, 3]
1016
send_arr = zeros(typ, Tuple(3 for i in 1:dims))
1117
send_arr[:] .= 1:length(send_arr)
1218

13-
for op in (MPI.SUM, +, (x,y) -> 2x+y-x)
19+
for op in operators
1420

1521
# Non allocating version
1622
recv_arr = zeros(typ, size(send_arr))

test/test_reduce.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ comm_size = MPI.Comm_size(MPI.COMM_WORLD)
3232

3333
send_arr = Int[1, 2, 3]
3434

35+
if Sys.iswindows() && Sys.WORD_SIZE == 32
36+
operators = [MPI.SUM, +]
37+
else
38+
operators = [MPI.SUM, +, (x,y) -> 2x+y-x]
39+
end
40+
3541
for typ=[Int]
3642
for dims = [1, 2, 3]
3743
send_arr = zeros(typ, Tuple(3 for i in 1:dims))
3844
send_arr[:] .= 1:length(send_arr)
3945

40-
for op in (MPI.SUM, +, (x,y) -> 2x+y-x)
46+
for op in operators
4147

4248
# Non allocating version
4349
recv_arr = zeros(typ, size(send_arr))

0 commit comments

Comments
 (0)