Skip to content

Commit 0257acc

Browse files
committed
Merge pull request #130 from JaredCrean2/waitany_fix
Waitany fix
2 parents a43553a + bd5abba commit 0257acc

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

src/mpi-base.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ function Waitany!(reqs::Array{Request,1})
369369
stat = Status()
370370
ccall(MPI_WAITANY, Void,
371371
(Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
372-
&count, reqvals, index, statvals, &0)
372+
&count, reqvals, ind, stat.val, &0)
373373
index = Int(ind[])
374374
reqs[index].val = reqvals[index]
375-
reqa[index].buffer = nothing
375+
reqs[index].buffer = nothing
376376
(index, stat)
377377
end
378378

test/test_wait.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# tests for the various kinds of waits
2+
using Base.Test
3+
using MPI
4+
5+
MPI.Init()
6+
myrank = MPI.Comm_rank(MPI.COMM_WORLD)
7+
commsize = MPI.Comm_rank(MPI.COMM_WORLD)
8+
9+
nsends = 2
10+
send_arr = Array(Array{Int, 1}, nsends)
11+
recv_arr = Array(Array{Int, 1}, nsends)
12+
13+
for i=1:nsends
14+
send_arr[i] = [i]
15+
recv_arr[i] = Array(Int, 1)
16+
end
17+
18+
send_reqs = Array(MPI.Request, nsends)
19+
recv_reqs = Array(MPI.Request, nsends)
20+
21+
# send to self
22+
for i=1:nsends
23+
send_reqs[i] = MPI.Isend(send_arr[i], myrank, i, MPI.COMM_WORLD)
24+
recv_reqs[i] = MPI.Irecv!(recv_arr[i], myrank, i, MPI.COMM_WORLD)
25+
end
26+
27+
send_check = zeros(Int, nsends)
28+
recv_check = zeros(Int, nsends)
29+
for i=1:nsends
30+
idx, stat = MPI.Waitany!(send_reqs)
31+
send_check[idx] += 1
32+
send_reqs[idx] = MPI.REQUEST_NULL
33+
end
34+
35+
for i=1:nsends
36+
@test send_check[i] == 1
37+
end
38+
39+
for i=1:nsends
40+
idx, stat = MPI.Waitany!(recv_reqs)
41+
recv_check[idx] += 1
42+
recv_reqs[idx] = MPI.REQUEST_NULL
43+
end
44+
45+
for i=1:nsends
46+
@test recv_check[i] == 1
47+
end
48+
49+
MPI.Barrier(MPI.COMM_WORLD)
50+
MPI.Finalize()

0 commit comments

Comments
 (0)