Skip to content

Commit 01b4c16

Browse files
committed
Change Sendrecv to Sendrecv! (#319)
Since it is a mutating operation.
1 parent ca95656 commit 01b4c16

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

docs/src/pointtopoint.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ MPI.Get_count
2020
```@docs
2121
MPI.Send
2222
MPI.Recv!
23-
MPI.Sendrecv
23+
MPI.Sendrecv!
2424
```
2525

2626
### Non-blocking

src/pointtopoint.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ number of entries received.
6363
"""
6464
Status
6565

66+
Base.:(==)(a::Status, b::Status) = a.source == b.source && a.tag == b.tag && a.error == b.error
67+
6668
Get_source(status::Status) = Int(status.source)
6769
Get_tag(status::Status) = Int(status.tag)
6870
Get_error(status::Status) = Int(status.error)
@@ -333,15 +335,15 @@ function irecv(src::Integer, tag::Integer, comm::Comm)
333335
end
334336

335337
"""
336-
Sendrecv(sendbuf, [sendcount::Integer, [sendtype::Union{Datatype, MPI_Datatype}]],
338+
Sendrecv!(sendbuf, [sendcount::Integer, [sendtype::Union{Datatype, MPI_Datatype}]],
337339
dest::Integer, sendtag::Integer,
338-
recvbuf, [recvcount::Integer, [recvtype::Union{Datatype, MPI_Datatype}]],
340+
recvbuf, [recvcount::Integer, [recvtype::Union{Datatype, MPI_Datatype}]],
339341
source::Integer, recvtag::Integer,
340342
comm::Comm)
341343
342-
Complete a blocking send-receive operation over the MPI communicator `comm`. Send
343-
`sendcount` elements of type `sendtype` from `sendbuf` to the MPI rank `dest` using message
344-
tag `tag`, and receive `recvcount` elements of type `recvtype` from MPI rank `source` into
344+
Complete a blocking send-receive operation over the MPI communicator `comm`. Send
345+
`sendcount` elements of type `sendtype` from `sendbuf` to the MPI rank `dest` using message
346+
tag `tag`, and receive `recvcount` elements of type `recvtype` from MPI rank `source` into
345347
the buffer `recvbuf` using message tag `tag`. Return a [`Status`](@ref) object.
346348
347349
If not provided, `sendtype`/`recvtype` and `sendcount`/`recvcount` are derived from the
@@ -350,7 +352,7 @@ element type and length of `sendbuf`/`recvbuf`, respectively.
350352
# External links
351353
$(_doc_external("MPI_Sendrecv"))
352354
"""
353-
function Sendrecv(sendbuf, sendcount::Integer, sendtype::Union{Datatype, MPI_Datatype}, dest::Integer, sendtag::Integer,
355+
function Sendrecv!(sendbuf, sendcount::Integer, sendtype::Union{Datatype, MPI_Datatype}, dest::Integer, sendtag::Integer,
354356
recvbuf, recvcount::Integer, recvtype::Union{Datatype, MPI_Datatype}, source::Integer, recvtag::Integer,
355357
comm::Comm)
356358
# int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag,
@@ -366,16 +368,16 @@ function Sendrecv(sendbuf, sendcount::Integer, sendtype::Union{Datatype, MPI_Dat
366368
return stat_ref[]
367369
end
368370

369-
function Sendrecv(sendbuf, sendcount::Integer, dest::Integer, sendtag::Integer,
371+
function Sendrecv!(sendbuf, sendcount::Integer, dest::Integer, sendtag::Integer,
370372
recvbuf, recvcount::Integer, source::Integer, recvtag::Integer,
371373
comm::Comm)
372-
return Sendrecv(sendbuf, sendcount, mpitype(eltype(sendbuf)), dest, sendtag,
374+
return Sendrecv!(sendbuf, sendcount, mpitype(eltype(sendbuf)), dest, sendtag,
373375
recvbuf, recvcount, mpitype(eltype(recvbuf)), source, recvtag, comm)
374376
end
375-
function Sendrecv(sendbuf::AbstractArray, dest::Integer, sendtag::Integer,
377+
function Sendrecv!(sendbuf::AbstractArray, dest::Integer, sendtag::Integer,
376378
recvbuf::AbstractArray, source::Integer, recvtag::Integer,
377379
comm::Comm)
378-
return Sendrecv(sendbuf, length(sendbuf), dest, sendtag,
380+
return Sendrecv!(sendbuf, length(sendbuf), dest, sendtag,
379381
recvbuf, length(recvbuf), source, recvtag, comm)
380382
end
381383

test/test_sendrecv.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,26 @@ comm_cart = MPI.Cart_create(comm, 1, Cint[comm_size], Cint[1], false)
114114
src_rank, dest_rank = MPI.Cart_shift(comm_cart, 0, -1)
115115

116116
# execute left shift using subarrays
117-
MPI.Sendrecv(a, 1, subarr_send, dest_rank, 0,
118-
a, 1, subarr_recv, src_rank, 0, comm_cart)
117+
MPI.Sendrecv!(a, 1, subarr_send, dest_rank, 0,
118+
a, 1, subarr_recv, src_rank, 0, comm_cart)
119119

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

122122
# send elements from a buffer
123123
# ---------------------------
124124
a = Float64[comm_rank, comm_rank, comm_rank]
125125
b = Float64[ -1, -1, -1]
126-
MPI.Sendrecv(a, 2, dest_rank, 1,
127-
b, 2, src_rank, 1, comm_cart)
126+
MPI.Sendrecv!(a, 2, dest_rank, 1,
127+
b, 2, src_rank, 1, comm_cart)
128128

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

131131
# send entire buffer
132132
# ---------------------------
133133
a = Float64[comm_rank, comm_rank, comm_rank]
134134
b = Float64[ -1, -1, -1]
135-
MPI.Sendrecv(a, dest_rank, 2,
136-
b, src_rank, 2, comm_cart)
135+
MPI.Sendrecv!(a, dest_rank, 2,
136+
b, src_rank, 2, comm_cart)
137137

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

0 commit comments

Comments
 (0)