Skip to content

Commit

Permalink
Change Sendrecv to Sendrecv! (#319)
Browse files Browse the repository at this point in the history
Since it is a mutating operation.
  • Loading branch information
simonbyrne authored Nov 19, 2019
1 parent ca95656 commit c8ae364
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/src/pointtopoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MPI.Get_count
```@docs
MPI.Send
MPI.Recv!
MPI.Sendrecv
MPI.Sendrecv!
```

### Non-blocking
Expand Down
12 changes: 6 additions & 6 deletions src/pointtopoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function irecv(src::Integer, tag::Integer, comm::Comm)
end

"""
Sendrecv(sendbuf, [sendcount::Integer, [sendtype::Union{Datatype, MPI_Datatype}]],
Sendrecv!(sendbuf, [sendcount::Integer, [sendtype::Union{Datatype, MPI_Datatype}]],
dest::Integer, sendtag::Integer,
recvbuf, [recvcount::Integer, [recvtype::Union{Datatype, MPI_Datatype}]],
source::Integer, recvtag::Integer,
Expand All @@ -350,7 +350,7 @@ element type and length of `sendbuf`/`recvbuf`, respectively.
# External links
$(_doc_external("MPI_Sendrecv"))
"""
function Sendrecv(sendbuf, sendcount::Integer, sendtype::Union{Datatype, MPI_Datatype}, dest::Integer, sendtag::Integer,
function Sendrecv!(sendbuf, sendcount::Integer, sendtype::Union{Datatype, MPI_Datatype}, dest::Integer, sendtag::Integer,
recvbuf, recvcount::Integer, recvtype::Union{Datatype, MPI_Datatype}, source::Integer, recvtag::Integer,
comm::Comm)
# int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag,
Expand All @@ -366,16 +366,16 @@ function Sendrecv(sendbuf, sendcount::Integer, sendtype::Union{Datatype, MPI_Dat
return stat_ref[]
end

function Sendrecv(sendbuf, sendcount::Integer, dest::Integer, sendtag::Integer,
function Sendrecv!(sendbuf, sendcount::Integer, dest::Integer, sendtag::Integer,
recvbuf, recvcount::Integer, source::Integer, recvtag::Integer,
comm::Comm)
return Sendrecv(sendbuf, sendcount, mpitype(eltype(sendbuf)), dest, sendtag,
return Sendrecv!(sendbuf, sendcount, mpitype(eltype(sendbuf)), dest, sendtag,
recvbuf, recvcount, mpitype(eltype(recvbuf)), source, recvtag, comm)
end
function Sendrecv(sendbuf::AbstractArray, dest::Integer, sendtag::Integer,
function Sendrecv!(sendbuf::AbstractArray, dest::Integer, sendtag::Integer,
recvbuf::AbstractArray, source::Integer, recvtag::Integer,
comm::Comm)
return Sendrecv(sendbuf, length(sendbuf), dest, sendtag,
return Sendrecv!(sendbuf, length(sendbuf), dest, sendtag,
recvbuf, length(recvbuf), source, recvtag, comm)
end

Expand Down
12 changes: 6 additions & 6 deletions test/test_sendrecv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,26 @@ comm_cart = MPI.Cart_create(comm, 1, Cint[comm_size], Cint[1], false)
src_rank, dest_rank = MPI.Cart_shift(comm_cart, 0, -1)

# execute left shift using subarrays
MPI.Sendrecv(a, 1, subarr_send, dest_rank, 0,
a, 1, subarr_recv, src_rank, 0, comm_cart)
MPI.Sendrecv!(a, 1, subarr_send, dest_rank, 0,
a, 1, subarr_recv, src_rank, 0, comm_cart)

@test a == [comm_rank, comm_rank, (comm_rank+1) % comm_size]

# send elements from a buffer
# ---------------------------
a = Float64[comm_rank, comm_rank, comm_rank]
b = Float64[ -1, -1, -1]
MPI.Sendrecv(a, 2, dest_rank, 1,
b, 2, src_rank, 1, comm_cart)
MPI.Sendrecv!(a, 2, dest_rank, 1,
b, 2, src_rank, 1, comm_cart)

@test b == [(comm_rank+1) % comm_size, (comm_rank+1) % comm_size, -1]

# send entire buffer
# ---------------------------
a = Float64[comm_rank, comm_rank, comm_rank]
b = Float64[ -1, -1, -1]
MPI.Sendrecv(a, dest_rank, 2,
b, src_rank, 2, comm_cart)
MPI.Sendrecv!(a, dest_rank, 2,
b, src_rank, 2, comm_cart)

@test b == [(comm_rank+1) % comm_size, (comm_rank+1) % comm_size, (comm_rank+1) % comm_size]

Expand Down

0 comments on commit c8ae364

Please sign in to comment.