Skip to content

Commit baa0fda

Browse files
committed
add tests
1 parent f57444c commit baa0fda

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/test_wait.jl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
@test sum(send_check) == nsends
36+
37+
for i=1:nsends
38+
idx, stat = MPI.Waitany!(recv_reqs)
39+
recv_check[idx] += 1
40+
recv_reqs[idx] = MPI.REQUEST_NULL
41+
end
42+
43+
@test sum(recv_check) == nsends
44+
45+
MPI.Barrier(MPI.COMM_WORLD)
46+
MPI.Finalize()

0 commit comments

Comments
 (0)