Skip to content

Commit 4de2408

Browse files
committed
lower level forms
1 parent 4cd7118 commit 4de2408

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

src/pointtopoint.jl

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ $(_doc_external("MPI_Send"))
1616
Send(data, comm::Comm; dest::Integer, tag::Integer=Cint(0)) =
1717
Send(data, dest, tag, comm)
1818

19-
20-
function Send(buf::Buffer, dest::Integer, tag::Integer, comm::Comm)
19+
function Send(data::Union{MPIPtr, MPIBuffertype}, count::Integer, datatype::Union{MPI_Datatype, Datatype}, dest::Integer, tag::Integer, comm::Union{MPI_Comm, Comm})
2120
# int MPI_Send(const void* buf, int count, MPI_Datatype datatype, int dest,
2221
# int tag, MPI_Comm comm)
2322
@mpichk ccall((:MPI_Send, libmpi), Cint,
2423
(MPIPtr, Cint, MPI_Datatype, Cint, Cint, MPI_Comm),
25-
buf.data, buf.count, buf.datatype, dest, tag, comm)
24+
data, count, datatype, dest, tag, comm)
2625
return nothing
2726
end
27+
Send(buf::Buffer, dest::Integer, tag::Integer, comm::Comm) =
28+
Send(buf.data, buf.count, buf.datatype, dest, tag, comm.val)
2829
Send(arr::Union{Ref,AbstractArray}, dest::Integer, tag::Integer, comm::Comm) =
2930
Send(Buffer(arr), dest, tag, comm)
3031
function Send(obj::T, dest::Integer, tag::Integer, comm::Comm) where T
@@ -60,14 +61,17 @@ $(_doc_external("MPI_Isend"))
6061
"""
6162
Isend(data, comm::Comm; dest::Integer, tag::Integer=0) =
6263
Isend(data, dest, tag, comm)
63-
64-
function Isend(buf::Buffer, dest::Integer, tag::Integer, comm::Comm)
65-
req = Request()
64+
function Isend(data::Union{MPIPtr, MPIBuffertype}, count::Integer, datatype::Union{MPI_Datatype, Datatype}, dest::Integer, tag::Integer, comm::Union{MPI_Comm, Comm}, req::Union{MPI_Request, Request})
6665
# int MPI_Isend(const void* buf, int count, MPI_Datatype datatype, int dest,
6766
# int tag, MPI_Comm comm, MPI_Request *request)
6867
@mpichk ccall((:MPI_Isend, libmpi), Cint,
6968
(MPIPtr, Cint, MPI_Datatype, Cint, Cint, MPI_Comm, Ptr{MPI_Request}),
70-
buf.data, buf.count, buf.datatype, dest, tag, comm, req)
69+
data, count, datatype, dest, tag, comm, req)
70+
return nothing
71+
end
72+
function Isend(buf::Buffer, dest::Integer, tag::Integer, comm::Comm)
73+
req = Request()
74+
Isend(buf.data, buf.count, buf.datatype, dest, tag, comm, req)
7175
req.buffer = buf
7276
finalizer(free, req)
7377
return req
@@ -113,12 +117,16 @@ $(_doc_external("MPI_Recv"))
113117
Recv!(recvbuf, comm::Comm, status=nothing; source=Consts.MPI_ANY_SOURCE[], tag=Consts.MPI_ANY_TAG[]) =
114118
Recv!(recvbuf, source, tag, comm, status)
115119

116-
function Recv!(recvbuf::Buffer, source::Integer, tag::Integer, comm::Comm, status::Union{Ref{Status},Nothing})
120+
function Recv!(data::Union{MPIPtr, MPIBuffertype}, count::Integer, datatype::Union{MPI_Datatype, Datatype}, source::Integer, tag::Integer, comm::Union{MPI_Comm, Comm}, status::Union{Ref{Status}, Ptr{Nothing}})
117121
# int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source,
118122
# int tag, MPI_Comm comm, MPI_Status *status)
119123
@mpichk ccall((:MPI_Recv, libmpi), Cint,
120124
(MPIPtr, Cint, MPI_Datatype, Cint, Cint, MPI_Comm, Ptr{Status}),
121-
recvbuf.data, recvbuf.count, recvbuf.datatype, source, tag, comm, something(status, Consts.MPI_STATUS_IGNORE[]))
125+
data, count, datatype, source, tag, comm, status)
126+
return nothing
127+
end
128+
function Recv!(recvbuf::Buffer, source::Integer, tag::Integer, comm::Comm, status::Union{Ref{Status},Nothing})
129+
Recv!(recvbuf.data, recvbuf.count, recvbuf.datatype, source, tag, comm, something(status, Consts.MPI_STATUS_IGNORE[]))
122130
return recvbuf.data
123131
end
124132
Recv!(recvbuf, source::Integer, tag::Integer, comm::Comm, status::Union{Ref{Status},Nothing}) =
@@ -204,13 +212,19 @@ $(_doc_external("MPI_Irecv"))
204212
"""
205213
Irecv!(recvbuf, comm::Comm; source::Integer=Consts.MPI_ANY_SOURCE[], tag::Integer=Consts.MPI_ANY_TAG[]) =
206214
Irecv!(recvbuf, source, tag, comm)
207-
function Irecv!(buf::Buffer, source::Integer, tag::Integer, comm::Comm)
208-
req = Request()
215+
function Irecv!(data::Union{MPIPtr, MPIBuffertype}, count::Integer, datatype::Union{MPI_Datatype, Datatype}, source::Integer, tag::Integer, comm::Union{MPI_Comm, Comm}, req::Union{MPI_Request, Request})
209216
# int MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int source,
210217
# int tag, MPI_Comm comm, MPI_Request *request)
211218
@mpichk ccall((:MPI_Irecv, libmpi), Cint,
212219
(MPIPtr, Cint, MPI_Datatype, Cint, Cint, MPI_Comm, Ptr{MPI_Request}),
213-
buf.data, buf.count, buf.datatype, source, tag, comm, req)
220+
data, count, datatype, source, tag, comm, req)
221+
return nothing
222+
end
223+
Irecv!(buf::Buffer, source::Integer, tag::Integer, comm::Comm, req::Request) =
224+
Irecv!(buf.data, buf.count, buf.datatype, source, tag, comm, req)
225+
function Irecv!(buf::Buffer, source::Integer, tag::Integer, comm::Comm)
226+
req = Request()
227+
Irecv!(buf.data, buf.count, buf.datatype, source, tag, comm, req)
214228
req.buffer = buf
215229
finalizer(free, req)
216230
return req
@@ -249,20 +263,27 @@ $(_doc_external("MPI_Sendrecv"))
249263
"""
250264
Sendrecv!(sendbuf, recvbuf, comm::MPI.Comm, status=nothing; dest::Integer, sendtag::Integer=0, source::Integer=Consts.MPI_ANY_SOURCE[], recvtag::Integer=Consts.MPI_ANY_TAG[]) =
251265
Sendrecv!(sendbuf, dest, sendtag, recvbuf, source, recvtag, comm, status)
252-
253-
function Sendrecv!(sendbuf::Buffer, dest::Integer, sendtag::Integer,
254-
recvbuf::Buffer, source::Integer, recvtag::Integer,
255-
comm::Comm, status::Union{Ref{Status}, Nothing})
266+
function Sendrecv!(sendbuf::Union{MPIPtr, MPIBuffertype}, sendcount::Integer, sendtype::Union{MPI_Datatype, Datatype}, dest::Integer, sendtag::Integer,
267+
recvbuf::Union{MPIPtr, MPIBuffertype}, recvcount::Integer, recvtype::Union{MPI_Datatype, Datatype}, source::Integer, recvtag::Integer,
268+
comm::Union{MPI_Comm, Comm}, status::Union{Ref{Status}, Ptr{Nothing}})
256269
# int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag,
257270
# void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag,
258271
# MPI_Comm comm, MPI_Status *status)
259272
@mpichk ccall((:MPI_Sendrecv, libmpi), Cint,
260273
(MPIPtr, Cint, MPI_Datatype, Cint, Cint,
261274
MPIPtr, Cint, MPI_Datatype, Cint, Cint,
262275
MPI_Comm, Ptr{Status}),
263-
sendbuf.data, sendbuf.count, sendbuf.datatype, dest, sendtag,
264-
recvbuf.data, recvbuf.count, recvbuf.datatype, source, recvtag,
265-
comm, something(status, Consts.MPI_STATUS_IGNORE[]))
276+
sendbuf, sendcount, sendtype, dest, sendtag,
277+
recvbuf, recvcount, recvtype, source, recvtag,
278+
comm, status)
279+
return nothing
280+
end
281+
function Sendrecv!(sendbuf::Buffer, dest::Integer, sendtag::Integer,
282+
recvbuf::Buffer, source::Integer, recvtag::Integer,
283+
comm::Comm, status::Union{Ref{Status}, Nothing})
284+
Sendrecv!(sendbuf.data, sendbuf.count, sendbuf.datatype, dest, sendtag,
285+
recvbuf.data, recvbuf.count, recvbuf.datatype, source, recvtag,
286+
comm, something(status, Consts.MPI_STATUS_IGNORE[]))
266287
return recvbuf.data
267288
end
268289
Sendrecv!(sendbuf, dest::Integer, sendtag::Integer, recvbuf, source::Integer, recvtag::Integer, comm::Comm, status::Union{Ref{Status}, Nothing}) =

0 commit comments

Comments
 (0)