Skip to content

Commit 45c695f

Browse files
committed
feat: add support for buffered mode send operations
1 parent 5614211 commit 45c695f

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/KokkosComm_comm_mode.hpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ namespace KokkosComm {
2121
// Scoped enumeration to specify the communication mode of a sending operation.
2222
// See section 3.4 of the MPI standard for a complete specification.
2323
enum class CommMode {
24-
// Default mode: lets the user override the send operations behavior at
25-
// compile-time. E.g., this can be set to mode "Synchronous" for debug
26-
// builds by defining KOKKOSCOMM_FORCE_SYNCHRONOUS_MODE.
24+
// Default mode: lets the user override the send operations behavior at compile-time. E.g. this can be set to mode
25+
// "Synchronous" for debug builds by defining KOKKOSCOMM_FORCE_SYNCHRONOUS_MODE.
2726
Default,
28-
// Standard mode: MPI implementation decides whether outgoing messages will
29-
// be buffered. Send operations can be started whether or not a matching
30-
// receive has been started. They may complete before a matching receive is
31-
// started. Standard mode is non-local: successful completion of the send
32-
// operation may depend on the occurrence of a matching receive.
27+
// Standard mode: MPI implementation decides whether outgoing messages will be buffered. Send operations can be
28+
// started whether or not a matching receive has been started. They may complete before a matching receive is started.
29+
// Standard mode is non-local: successful completion of the send operation may depend on the occurrence of a matching
30+
// receive.
3331
Standard,
34-
// Ready mode: Send operations may be started only if the matching receive is
35-
// already started.
32+
// Buffered mode: Send operation can be started whether or not a matching receive has been started. It may complete
33+
// before a matching receive is started. However, unlike the standard send, this operation is local, and its
34+
// completion does not depend on the occurrence of a matching receive. Thus, if a send is executed and no matching
35+
// receive is started, then MPI must buffer the outgoing message, so as to allow the send call to complete. An error
36+
// will occur if there is insufficient buffer space. The amount of available buffer space is controlled by the user
37+
// (see Section 3.6). Buffer allocation by the user may be required for the buffered mode to be effective.
38+
Buffered,
39+
// Ready mode: Send operations may be started only if the matching receive is already started.
3640
Ready,
37-
// Synchronous mode: Send operations complete successfully only if a matching
38-
// receive is started, and the receive operation has started to receive the
39-
// message sent.
41+
// Synchronous mode: Send operations complete successfully only if a matching receive is started, and the receive
42+
// operation has started to receive the message sent.
4043
Synchronous,
4144
};
4245

src/impl/KokkosComm_isend.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ KokkosComm::Req isend(const ExecSpace &space, const SendView &sv, int dest, int
4444
MPI_Comm mpi_comm, MPI_Request *mpi_req) {
4545
if constexpr (SendMode == CommMode::Standard) {
4646
MPI_Isend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm, mpi_req);
47+
} else if constexpr (SendMode == CommMode::Buffered) {
48+
MPI_Ibsend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm, mpi_req);
4749
} else if constexpr (SendMode == CommMode::Ready) {
4850
MPI_Irsend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm, mpi_req);
4951
} else if constexpr (SendMode == CommMode::Synchronous) {

src/impl/KokkosComm_send.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ void send(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Com
3636
MPI_Comm mpi_comm) {
3737
if constexpr (SendMode == CommMode::Standard) {
3838
MPI_Send(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm);
39+
} else if constexpr (SendMode == CommMode::Buffered) {
40+
MPI_Bsend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm);
3941
} else if constexpr (SendMode == CommMode::Ready) {
4042
MPI_Rsend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm);
4143
} else if constexpr (SendMode == CommMode::Synchronous) {

0 commit comments

Comments
 (0)