Skip to content

Commit

Permalink
feat: add support for buffered mode send operations
Browse files Browse the repository at this point in the history
  • Loading branch information
dssgabriel committed May 15, 2024
1 parent 5614211 commit 45c695f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/KokkosComm_comm_mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,25 @@ namespace KokkosComm {
// Scoped enumeration to specify the communication mode of a sending operation.
// See section 3.4 of the MPI standard for a complete specification.
enum class CommMode {
// Default mode: lets the user override the send operations behavior at
// compile-time. E.g., this can be set to mode "Synchronous" for debug
// builds by defining KOKKOSCOMM_FORCE_SYNCHRONOUS_MODE.
// Default mode: lets the user override the send operations behavior at compile-time. E.g. this can be set to mode
// "Synchronous" for debug builds by defining KOKKOSCOMM_FORCE_SYNCHRONOUS_MODE.
Default,
// Standard mode: MPI implementation decides whether outgoing messages will
// be buffered. Send operations can be started whether or not a matching
// receive has been started. They may complete before a matching receive is
// started. Standard mode is non-local: successful completion of the send
// operation may depend on the occurrence of a matching receive.
// Standard mode: MPI implementation decides whether outgoing messages will be buffered. Send operations can be
// started whether or not a matching receive has been started. They may complete before a matching receive is started.
// Standard mode is non-local: successful completion of the send operation may depend on the occurrence of a matching
// receive.
Standard,
// Ready mode: Send operations may be started only if the matching receive is
// already started.
// Buffered mode: Send operation can be started whether or not a matching receive has been started. It may complete
// before a matching receive is started. However, unlike the standard send, this operation is local, and its
// completion does not depend on the occurrence of a matching receive. Thus, if a send is executed and no matching
// receive is started, then MPI must buffer the outgoing message, so as to allow the send call to complete. An error
// will occur if there is insufficient buffer space. The amount of available buffer space is controlled by the user
// (see Section 3.6). Buffer allocation by the user may be required for the buffered mode to be effective.
Buffered,
// Ready mode: Send operations may be started only if the matching receive is already started.
Ready,
// Synchronous mode: Send operations complete successfully only if a matching
// receive is started, and the receive operation has started to receive the
// message sent.
// Synchronous mode: Send operations complete successfully only if a matching receive is started, and the receive
// operation has started to receive the message sent.
Synchronous,
};

Expand Down
2 changes: 2 additions & 0 deletions src/impl/KokkosComm_isend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ KokkosComm::Req isend(const ExecSpace &space, const SendView &sv, int dest, int
MPI_Comm mpi_comm, MPI_Request *mpi_req) {
if constexpr (SendMode == CommMode::Standard) {
MPI_Isend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm, mpi_req);
} else if constexpr (SendMode == CommMode::Buffered) {
MPI_Ibsend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm, mpi_req);

This comment has been minimized.

Copy link
@cedricchevalier19

cedricchevalier19 May 16, 2024

Member

Do you have any check on buffer size to do?

This comment has been minimized.

Copy link
@dssgabriel

dssgabriel May 16, 2024

Author Collaborator

Indeed we can add some bounds checks here.
Would you prefer a simple assert or an if?

} else if constexpr (SendMode == CommMode::Ready) {
MPI_Irsend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm, mpi_req);
} else if constexpr (SendMode == CommMode::Synchronous) {
Expand Down
2 changes: 2 additions & 0 deletions src/impl/KokkosComm_send.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void send(const ExecSpace &space, const SendView &sv, int dest, int tag, MPI_Com
MPI_Comm mpi_comm) {
if constexpr (SendMode == CommMode::Standard) {
MPI_Send(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm);
} else if constexpr (SendMode == CommMode::Buffered) {
MPI_Bsend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm);
} else if constexpr (SendMode == CommMode::Ready) {
MPI_Rsend(mpi_view, mpi_count, mpi_datatype, mpi_dest, mpi_tag, mpi_comm);
} else if constexpr (SendMode == CommMode::Synchronous) {
Expand Down

0 comments on commit 45c695f

Please sign in to comment.