Point-to-point communication¶
All operations take the communicator last. Arguments with an obvious default can be left out in front of it: the
tag (0 for sends, any tag for receives) and the source of a receive (any source). See Calling conventions.
Blocking operations return the buffers they were given: owned buffers (passed as rvalues) by value, borrowed buffers
(lvalues) by reference. Non-blocking operations return an iresult that hands the buffers back on completion; see
Results and non-blocking operations.
Sending¶
-
template<is_send_mode SendMode, send_buffer SBuf, rank Dest, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
SBuf send(SendMode&&, SBuf &&sbuf, Dest dest, Tag tag, Comm const &comm)¶
(1) -
template<is_send_mode SendMode, send_buffer SBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm>
SBuf send(SendMode &&mode, SBuf &&sbuf, Dest dest, Comm const &comm)¶
(2) -
template<send_buffer SBuf, rank Dest, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
SBuf send(SBuf &&sbuf, Dest dest, Tag tag, Comm const &comm)¶
(3) -
template<send_buffer SBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm>
SBuf send(SBuf &&sbuf, Dest dest, Comm const &comm)¶
(4) (1) Sends
sbuftodestwithtagin the givensend_mode(MPI_Send,MPI_Bsend,MPI_SsendorMPI_Rsend).(2) Sends
sbuftodestwithDEFAULT_SEND_TAGin the givensend_mode.(3) Sends
sbuftodestwithtagin standard mode (MPI_Send).(4) Sends
sbuftodestwithDEFAULT_SEND_TAGin standard mode (MPI_Send).- Returns:
The send buffer (owned if passed as rvalue, borrowed otherwise).
Defined in header
<kamping/v2/p2p/send.hpp>
The send mode is selected with a tag as first argument, e.g. v2::send(v2::send_mode::sync, buf, dest, comm):
-
standard_t standard¶
Standard mode (
MPI_Send).Defined in header
<kamping/v2/p2p/send_mode.hpp>
-
buffered_t buffered¶
Buffered mode (
MPI_Bsend).Defined in header
<kamping/v2/p2p/send_mode.hpp>
-
sync_t sync¶
Synchronous mode (
MPI_Ssend).Defined in header
<kamping/v2/p2p/send_mode.hpp>
-
ready_t ready¶
Ready mode (
MPI_Rsend).Defined in header
<kamping/v2/p2p/send_mode.hpp>
-
int DEFAULT_SEND_TAG¶
The tag used by point-to-point operations that are called without an explicit tag.
Defined in header
<kamping/v2/p2p/constants.hpp>
Receiving¶
-
template<recv_buffer RBuf, rank Source, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
RBuf recv(RBuf &&rbuf, Source source, Tag tag, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(1) -
template<recv_buffer RBuf, rank Source, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
RBuf recv(RBuf &&rbuf, Source source, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(2) -
template<recv_buffer RBuf, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
RBuf recv(RBuf &&rbuf, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(3) (1) Receives a message from
sourcewithtagintorbuf(MPI_Recv).If
rbufis a deferred receive buffer (e.g.views::resizeorauto_recv<T>()), the message is matched withMPI_Mprobefirst andrbufis resized to fit, then received withMPI_Mrecv.(2) Receives a message from
sourcewith any tag intorbuf; see the overload above.(3) Receives a message from any source with any tag into
rbuf; see the overload above.- Parameters:
status– Optional: filled with the status of the received message. Defaults toMPI_STATUS_IGNORE.
- Returns:
The receive buffer (owned if passed as rvalue, borrowed otherwise).
Defined in header
<kamping/v2/p2p/recv.hpp>
Sending and receiving at once¶
-
template<send_buffer SBuf, recv_buffer RBuf, rank Dest, rank Source, tag SendTag, tag RecvTag, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
result<SBuf, RBuf> sendrecv(SBuf &&sbuf, Dest dest, SendTag send_tag, RBuf &&rbuf, Source source, RecvTag recv_tag, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(1) -
template<send_buffer SBuf, recv_buffer RBuf, rank Dest, rank Source, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
result<SBuf, RBuf> sendrecv(SBuf &&sbuf, Dest dest, RBuf &&rbuf, Source source, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(2) -
template<send_buffer SBuf, recv_buffer RBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
result<SBuf, RBuf> sendrecv(SBuf &&sbuf, Dest dest, RBuf &&rbuf, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(3) (1) Sends
sbuftodestwithsend_tagand receives intorbuffromsourcewithrecv_tagin one call (MPI_Sendrecv).If
rbufis a deferred receive buffer (e.g.views::resize), the counts are exchanged first andrbufis resized.(2) Like the overload above, sending with
DEFAULT_SEND_TAGand receiving with any tag.(3) Like the overload above, receiving from any source.
- Parameters:
status– Optional: filled with the status of the received message. Defaults toMPI_STATUS_IGNORE.
- Returns:
The send and receive buffer (owned if passed as rvalue, borrowed otherwise).
Defined in header
<kamping/v2/p2p/sendrecv.hpp>
With one buffer for both directions:
-
template<send_recv_buffer SRBuf, rank Dest, rank Source, tag SendTag, tag RecvTag, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
SRBuf sendrecv_replace(SRBuf &&send_recv_buf, Dest dest, SendTag send_tag, Source source, RecvTag recv_tag, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(1) -
template<send_recv_buffer SRBuf, rank Dest, rank Source, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
SRBuf sendrecv_replace(SRBuf &&send_recv_buf, Dest dest, Source source, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(2) -
template<send_recv_buffer SRBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
SRBuf sendrecv_replace(SRBuf &&send_recv_buf, Dest dest, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(3) (1) Sends the contents of
send_recv_buftodestwithsend_tagand replaces them with a message received fromsourcewithrecv_tag, in one call (MPI_Sendrecv_replace).The same buffer, count and datatype are used for both directions:
count(send_recv_buf)elements are sent, and the received message must not be longer. The defaultinfer()therefore rejects deferred receive buffers such asviews::resize; usesendrecvwith a separate receive buffer for messages of unknown size.(2) Like the overload above, sending with
DEFAULT_SEND_TAGand receiving with any tag.(3) Like the overload above, receiving from any source.
- Parameters:
status– Optional: filled with the status of the received message. Defaults toMPI_STATUS_IGNORE.
- Returns:
The buffer (owned if passed as rvalue, borrowed otherwise).
Defined in header
<kamping/v2/p2p/sendrecv_replace.hpp>
Probing¶
-
template<rank Source, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
void probe(Source source, Tag tag, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(1) -
template<rank Source, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
void probe(Source source, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(2) -
template<convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
void probe(Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(3) (1) Blocks until a message matching
sourceandtagis available, without receiving it (MPI_Probe).(2) Like the overload above, probing for any tag.
(3) Like the overload above, probing for any source and any tag.
- Parameters:
status– Optional: filled with the status of the message. Defaults toMPI_STATUS_IGNORE.
Defined in header
<kamping/v2/p2p/probe.hpp>
-
template<rank Source, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
bool iprobe(Source source, Tag tag, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(1) -
template<rank Source, convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
bool iprobe(Source source, Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(2) -
template<convertible_to_mpi_handle<MPI_Comm> Comm, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
bool iprobe(Comm const &comm, Status &&status = MPI_STATUS_IGNORE)¶
(3) (1) Checks whether a message matching
sourceandtagis available, without blocking or receiving it (MPI_Iprobe).(2) Like the overload above, probing for any tag.
(3) Like the overload above, probing for any source and any tag.
- Parameters:
status– Optional: filled with the status of the message if one is available. Defaults toMPI_STATUS_IGNORE.
- Returns:
trueif a matching message is available.
Defined in header
<kamping/v2/p2p/probe.hpp>
-
class probe_result¶
Result of a matched probe: the matched message together with its status.
Provides the status accessors (
source(),tag(),count()) directly and satisfiesconvertible_to_mpi_handle_ptr<MPI_Message>, so it can be passed tomrecv()/imrecv()to receive the message. Move-only: it terminates the program if destroyed while the matched message has not been received or released.Defined in header
<kamping/v2/p2p/probe.hpp>-
const_status_view status() const¶
(1) -
status_view status()¶
(2) - Returns:
(1) A read-only view of the status of the matched message.
(2) A view of the status of the matched message.
-
MPI_Message release() noexcept¶
Gives up responsibility for the matched message and returns it; the caller must then receive it.
-
int source() const¶
- Returns:
The source rank.
-
int tag() const¶
- Returns:
The tag.
-
std::optional<int> count(MPI_Datatype datatype) const¶
(1) -
template<typename T>
requires kamping::types::is_builtin_type_v<T>
std::optional<int> count() const¶
(2) - Template parameters:
T– A builtin MPI-mappable type.
- Parameters:
datatype– The MPI datatype.
- Returns:
(1) The number of top-level elements of the given datatype in the message. In cases where MPI_Get_count would return MPI_UNDEFINED,
std::nulloptis returned.(2) The number of top-level elements of type
Tin the message. In cases where MPI_Get_count would return MPI_UNDEFINED,std::nulloptis returned.
-
const_status_view status() const¶
Matched probe and receive¶
-
template<rank Source, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
probe_result mprobe(Source source, Tag tag, Comm const &comm)¶
(1) -
template<rank Source, convertible_to_mpi_handle<MPI_Comm> Comm>
probe_result mprobe(Source source, Comm const &comm)¶
(2) -
template<convertible_to_mpi_handle<MPI_Comm> Comm>
probe_result mprobe(Comm const &comm)¶
(3) (1) Blocks until a message matching
sourceandtagarrives and matches it (MPI_Mprobe).The message is removed from the matching queue and must be received through the returned
probe_result.(2) Like the overload above, matching a message with any tag.
(3) Like the overload above, matching a message from any source with any tag.
- Returns:
The matched message and its status.
Defined in header
<kamping/v2/p2p/probe.hpp>
-
template<rank Source, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
std::optional<probe_result> improbe(Source source, Tag tag, Comm const &comm)¶
(1) -
template<rank Source, convertible_to_mpi_handle<MPI_Comm> Comm>
std::optional<probe_result> improbe(Source source, Comm const &comm)¶
(2) -
template<convertible_to_mpi_handle<MPI_Comm> Comm>
std::optional<probe_result> improbe(Comm const &comm)¶
(3) (1) Matches a message matching
sourceandtagif one is available, without blocking (MPI_Improbe).A matched message is removed from the matching queue and must be received through the returned
probe_result.(2) Like the overload above, matching a message with any tag.
(3) Like the overload above, matching a message from any source with any tag.
- Returns:
The matched message and its status, or
std::nulloptif no matching message is available.
Defined in header
<kamping/v2/p2p/probe.hpp>
-
template<recv_buffer RBuf, convertible_to_mpi_handle_ptr<MPI_Status> Status = MPI_Status*>
RBuf mrecv(RBuf &&rbuf, probe_result probe, Status &&status = MPI_STATUS_IGNORE)¶ Receives the message matched by
probeintorbuf(MPI_Mrecv).Calls the
infer(comm_op::mrecv, ...)customization point first; the default overload sizes a deferred recv buffer (e.g.views::resize) from the probed count, so no further probing is needed. Takesprobeby value, so the caller must hand it over withstd::move— the message can be received only once.- Parameters:
status– Optional: filled with the status of the receive. Defaults toMPI_STATUS_IGNORE.
- Returns:
The buffer (ownership semantics match blocking recv).
Defined in header
<kamping/v2/p2p/mrecv.hpp>
-
template<recv_buffer RBuf, convertible_to_mpi_handle_ptr<MPI_Request> Request>
RBuf imrecv(Request &&request, RBuf &&rbuf, probe_result probe)¶
(1) -
template<recv_buffer RBuf>
iresult<RBuf> imrecv(RBuf &&rbuf, probe_result probe)¶
(2) (1) Starts a non-blocking receive of the message matched by
probeintorbuf, using a caller-supplied request (MPI_Imrecv).Like
mrecv, sizes a deferred recv buffer from the probed count before the receive is started. The message is consumed immediately, soprobeneed not outlive the request; the caller must keeprbufalive and completerequest.(2) Starts a non-blocking receive of the message matched by
probeintorbuf(MPI_Imrecv).Like
mrecv, sizes a deferred recv buffer from the probed count before the receive is started. The message is consumed immediately, soprobeneed not outlive the returned iresult, which owns the request and keeps the buffer alive until completion.- Returns:
(1) The buffer (ownership semantics match blocking recv).
(2) An iresult to wait on or test for the received buffer.
Defined in header
<kamping/v2/p2p/mrecv.hpp>
Non-blocking operations¶
-
template<is_send_mode SendMode, convertible_to_mpi_handle_ptr<MPI_Request> Request, send_buffer SBuf, rank Dest, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
SBuf isend(SendMode&&, Request &&request, SBuf &&sbuf, Dest dest, Tag tag, Comm const &comm)¶
(1) -
template<is_send_mode SendMode, convertible_to_mpi_handle_ptr<MPI_Request> Request, send_buffer SBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm>
SBuf isend(SendMode &&mode, Request &&request, SBuf &&sbuf, Dest dest, Comm const &comm)¶
(2) -
template<is_send_mode SendMode, send_buffer SBuf, rank Dest, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<SBuf> isend(SendMode &&mode, SBuf &&sbuf, Dest dest, Tag tag, Comm const &comm)¶
(3) -
template<is_send_mode SendMode, send_buffer SBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<SBuf> isend(SendMode &&mode, SBuf &&sbuf, Dest dest, Comm const &comm)¶
(4) -
template<convertible_to_mpi_handle_ptr<MPI_Request> Request, send_buffer SBuf, rank Dest, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
SBuf isend(Request &&request, SBuf &&sbuf, Dest dest, Tag tag, Comm const &comm)¶
(5) -
template<convertible_to_mpi_handle_ptr<MPI_Request> Request, send_buffer SBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm>
SBuf isend(Request &&request, SBuf &&sbuf, Dest dest, Comm const &comm)¶
(6) -
template<send_buffer SBuf, rank Dest, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<SBuf> isend(SBuf &&sbuf, Dest dest, Tag tag, Comm const &comm)¶
(7) -
template<send_buffer SBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<SBuf> isend(SBuf &&sbuf, Dest dest, Comm const &comm)¶
(8) (1) Starts sending
sbuftodestwithtagin the givensend_mode, using the caller-suppliedrequest(MPI_Isend,MPI_Ibsend,MPI_IssendorMPI_Irsend). The caller must keepsbufalive and completerequest.(2) Like the overload above, with
DEFAULT_SEND_TAG.(3) Starts sending
sbuftodestwithtagin the givensend_mode.(4) Like the overload above, with
DEFAULT_SEND_TAG.(5) Starts sending
sbuftodestwithtagin standard mode, using the caller-suppliedrequest(MPI_Isend).(6) Like the overload above, with
DEFAULT_SEND_TAG.(7) Starts sending
sbuftodestwithtagin standard mode (MPI_Isend).(8) Like the overload above, with
DEFAULT_SEND_TAG.- Returns:
Defined in header
<kamping/v2/p2p/isend.hpp>
-
template<convertible_to_mpi_handle_ptr<MPI_Request> Request, recv_buffer RBuf, rank Source, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
RBuf irecv(Request &&request, RBuf &&rbuf, Source source, Tag tag, Comm const &comm)¶
(1) -
template<convertible_to_mpi_handle_ptr<MPI_Request> Request, recv_buffer RBuf, rank Source, convertible_to_mpi_handle<MPI_Comm> Comm>
RBuf irecv(Request &&request, RBuf &&rbuf, Source source, Comm const &comm)¶
(2) -
template<convertible_to_mpi_handle_ptr<MPI_Request> Request, recv_buffer RBuf, convertible_to_mpi_handle<MPI_Comm> Comm>
RBuf irecv(Request &&request, RBuf &&rbuf, Comm const &comm)¶
(3) -
template<recv_buffer RBuf, rank Source, tag Tag, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<RBuf> irecv(RBuf &&rbuf, Source source, Tag tag, Comm const &comm)¶
(4) -
template<recv_buffer RBuf, rank Source, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<RBuf> irecv(RBuf &&rbuf, Source source, Comm const &comm)¶
(5) -
template<recv_buffer RBuf, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<RBuf> irecv(RBuf &&rbuf, Comm const &comm)¶
(6) (1) Starts receiving a message from
sourcewithtagintorbuf, using the caller-suppliedrequest(MPI_Irecv, orMPI_Imrecvfor a deferred buffer). The caller must keeprbufalive and completerequest.(2) Like the overload above, receiving with any tag.
(3) Like the overload above, receiving from any source with any tag.
(4) Starts receiving a message from
sourcewithtagintorbuf(MPI_Irecv, orMPI_Imrecvfor a deferred buffer).(5) Like the overload above, receiving with any tag.
(6) Like the overload above, receiving from any source with any tag.
- Returns:
Defined in header
<kamping/v2/p2p/irecv.hpp>
-
template<convertible_to_mpi_handle_ptr<MPI_Request> Request, send_buffer SBuf, recv_buffer RBuf, rank Dest, rank Source, tag SendTag, tag RecvTag, convertible_to_mpi_handle<MPI_Comm> Comm>
result<SBuf, RBuf> isendrecv(Request &&request, SBuf &&sbuf, Dest dest, SendTag send_tag, RBuf &&rbuf, Source source, RecvTag recv_tag, Comm const &comm)¶
(1) -
template<convertible_to_mpi_handle_ptr<MPI_Request> Request, send_buffer SBuf, recv_buffer RBuf, rank Dest, rank Source, convertible_to_mpi_handle<MPI_Comm> Comm>
result<SBuf, RBuf> isendrecv(Request &&request, SBuf &&sbuf, Dest dest, RBuf &&rbuf, Source source, Comm const &comm)¶
(2) -
template<convertible_to_mpi_handle_ptr<MPI_Request> Request, send_buffer SBuf, recv_buffer RBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm>
result<SBuf, RBuf> isendrecv(Request &&request, SBuf &&sbuf, Dest dest, RBuf &&rbuf, Comm const &comm)¶
(3) -
template<send_buffer SBuf, recv_buffer RBuf, rank Dest, rank Source, tag SendTag, tag RecvTag, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<SBuf, RBuf> isendrecv(SBuf &&sbuf, Dest dest, SendTag send_tag, RBuf &&rbuf, Source source, RecvTag recv_tag, Comm const &comm)¶
(4) -
template<send_buffer SBuf, recv_buffer RBuf, rank Dest, rank Source, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<SBuf, RBuf> isendrecv(SBuf &&sbuf, Dest dest, RBuf &&rbuf, Source source, Comm const &comm)¶
(5) -
template<send_buffer SBuf, recv_buffer RBuf, rank Dest, convertible_to_mpi_handle<MPI_Comm> Comm>
iresult<SBuf, RBuf> isendrecv(SBuf &&sbuf, Dest dest, RBuf &&rbuf, Comm const &comm)¶
(6) (1) Starts sending
sbuftodestwithsend_tagand receiving intorbuffromsourcewithrecv_tag, using the caller-suppliedrequest(MPI_Isendrecv). The caller must keep both buffers alive and completerequest.(2) Like the overload above, sending with
DEFAULT_SEND_TAGand receiving with any tag.(3) Like the overload above, receiving from any source.
(4) Starts sending
sbuftodestwithsend_tagand receiving intorbuffromsourcewithrecv_tag(MPI_Isendrecv).(5) Like the overload above, sending with
DEFAULT_SEND_TAGand receiving with any tag.(6) Like the overload above, receiving from any source.
- Returns:
Defined in header
<kamping/v2/p2p/isendrecv.hpp>