Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Aug 30, 2014
1 parent 4930f2a commit f78aff1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
11 changes: 5 additions & 6 deletions test/test_bcast.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Base.Test
import MPI

MPI.init()
MPI.Init()

function bcast_array(A, root)
comm = MPI.COMM_WORLD

if MPI.rank(comm) == root
if MPI.Comm_rank(comm) == root
B = copy(A)
else
B = similar(A)
Expand Down Expand Up @@ -77,7 +77,7 @@ A = uint64(rand(1:8000, 128))
comm = MPI.COMM_WORLD

g = x -> x^2 + 2x - 1
if MPI.rank(comm) == root
if MPI.Comm_rank(comm) == root
f = copy(g)
else
f = nothing
Expand All @@ -89,13 +89,12 @@ f = MPI.bcast(f, root, comm)


A = {"foo" => "bar"}
if MPI.rank(comm) == root
if MPI.Comm_rank(comm) == root
B = A
else
B = nothing
end
B = MPI.bcast(B, root, comm)
@test B["foo"] == "bar"

MPI.finalize()

MPI.Finalize()
8 changes: 4 additions & 4 deletions test/test_reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ using Base.Test

import MPI

MPI.init()
MPI.Init()

comm = MPI.COMM_WORLD
size = MPI.size(comm)
rank = MPI.rank(comm)
size = MPI.Comm_size(comm)
rank = MPI.Comm_rank(comm)

root = size-1
val = rank == root ? sum([0:size-1]) : nothing
Expand All @@ -23,4 +23,4 @@ sum_mesg = MPI.Reduce(mesg, MPI.SUM, root, comm)
sum_mesg = rank == root ? sum_mesg : size*mesg
@test isapprox(norm(sum_mesg-size*mesg), 0.0)

MPI.finalize()
MPI.Finalize()
20 changes: 10 additions & 10 deletions test/test_sendrecv.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Base.Test
import MPI

MPI.init()
MPI.Init()

comm = MPI.COMM_WORLD
size = MPI.size(comm)
rank = MPI.rank(comm)
size = MPI.Comm_size(comm)
rank = MPI.Comm_rank(comm)

dst = mod(rank+1, size)
src = mod(rank-1, size)
Expand All @@ -20,14 +20,14 @@ fill!(send_mesg, float64(rank))
fill!(recv_mesg_expected, float64(src))

rreq = MPI.Irecv!(recv_mesg, src, src+32, comm)
sreq = MPI.Isend!(send_mesg, dst, rank+32, comm)
sreq = MPI.Isend(send_mesg, dst, rank+32, comm)

stats = MPI.waitall!([sreq, rreq])
stats = MPI.Waitall!([sreq, rreq])
@test isequal(typeof(rreq), typeof(MPI.REQUEST_NULL))
@test isequal(typeof(sreq), typeof(MPI.REQUEST_NULL))

@test stats[MPI.SOURCE,2] == src
@test stats[MPI.TAG,2] == src+32
@test MPI.Get_source(stats[2]) == src
@test MPI.Get_tag(stats[2]) == src+32
@test isapprox(norm(recv_mesg-recv_mesg_expected), 0.0)

rreq = nothing
Expand All @@ -38,12 +38,12 @@ if rank == 0
MPI.send(send_mesg, dst, rank+32, comm)
recv_mesg = recv_mesg_expected
elseif rank == size-1
recv_mesg = MPI.recv(src, src+32, comm)
(recv_mesg, _) = MPI.recv(src, src+32, comm)
else
recv_mesg = MPI.recv(src, src+32, comm)
(recv_mesg, _) = MPI.recv(src, src+32, comm)
MPI.send(send_mesg, dst, rank+32, comm)
end

@test isapprox(norm(recv_mesg-recv_mesg_expected), 0.0)

MPI.finalize()
MPI.Finalize()

0 comments on commit f78aff1

Please sign in to comment.