Skip to content

Commit

Permalink
Propagate changes to CommMode everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
dssgabriel committed Apr 11, 2024
1 parent d28054d commit eab0c8d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
22 changes: 10 additions & 12 deletions src/KokkosComm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

namespace KokkosComm {

template <KokkosExecutionSpace ExecSpace,KokkosView SendView,
Mode CommMode = Mode::Default>
KokkosView SendView>
// 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 : uint8_t {
Expand All @@ -48,27 +45,28 @@ enum class CommMode : uint8_t {
Synchronous,
};

template <CommMode SendMode = CommMode::Standard,
KokkosExecutionSpace ExecSpace, KokkosView SendView>
Req isend(const ExecSpace &space, const SendView &sv, int dest, int tag,
MPI_Comm comm) {
if constexpr (CommMode == Mode::Default) {
if constexpr (SendMode == CommMode::Standard) {
return Impl::isend(space, sv, dest, tag, comm);
} else if constexpr (CommMode == Mode::Ready) {
} else if constexpr (SendMode == CommMode::Ready) {
return Impl::irsend(space, sv, dest, tag, comm);
} else if constexpr (CommMode == Mode::Synchronous) {
} else if constexpr (SendMode == CommMode::Synchronous) {
return Impl::issend(space, sv, dest, tag, comm);
}
}

template <KokkosExecutionSpace ExecSpace,KokkosView SendView,
Mode CommMode = Mode::Default>
KokkosView SendView>
template <CommMode SendMode = CommMode::Standard,
KokkosExecutionSpace ExecSpace, KokkosView SendView>
void send(const ExecSpace &space, const SendView &sv, int dest, int tag,
MPI_Comm comm) {
if constexpr (CommMode == Mode::Default) {
if constexpr (SendMode == CommMode::Standard) {
return Impl::send(space, sv, dest, tag, comm);
} else if constexpr (CommMode == Mode::Ready) {
} else if constexpr (SendMode == CommMode::Ready) {
return Impl::rsend(space, sv, dest, tag, comm);
} else if constexpr (CommMode == Mode::Synchronous) {
} else if constexpr (SendMode == CommMode::Synchronous) {
return Impl::ssend(space, sv, dest, tag, comm);
}
}
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/test_irsendrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TYPED_TEST(IrsendRecv, 1D_contig) {
int dst = 1;
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::Req req = KokkosComm::isend<KokkosComm::Mode::Ready>(
KokkosComm::Req req = KokkosComm::isend<KokkosComm::CommMode::Ready>(
Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD);
req.wait();
} else if (1 == rank) {
Expand Down Expand Up @@ -75,7 +75,7 @@ TYPED_TEST(IrsendRecv, 1D_noncontig) {
int dst = 1;
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::Req req = KokkosComm::isend<KokkosComm::Mode::Ready>(
KokkosComm::Req req = KokkosComm::isend<KokkosComm::CommMode::Ready>(
Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD);
req.wait();
} else if (1 == rank) {
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/test_issendrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TYPED_TEST(IssendRecv, 1D_contig) {
int dst = 1;
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::Req req = KokkosComm::isend<KokkosComm::Mode::Synchronous>(
KokkosComm::Req req = KokkosComm::isend<KokkosComm::CommMode::Synchronous>(
Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD);
req.wait();
} else if (1 == rank) {
Expand Down Expand Up @@ -75,7 +75,7 @@ TYPED_TEST(IssendRecv, 1D_noncontig) {
int dst = 1;
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::Req req = KokkosComm::isend<KokkosComm::Mode::Synchronous>(
KokkosComm::Req req = KokkosComm::isend<KokkosComm::CommMode::Synchronous>(
Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD);
req.wait();
} else if (1 == rank) {
Expand Down
8 changes: 4 additions & 4 deletions unit_tests/test_rsendrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ TYPED_TEST(RsendRecv, 1D_contig) {
int dst = 1;
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::send<KokkosComm::Mode::Ready>(Kokkos::DefaultExecutionSpace(),
a, dst, 0, MPI_COMM_WORLD);
KokkosComm::send<KokkosComm::CommMode::Ready>(
Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD);
} else if (1 == rank) {
int src = 0;
KokkosComm::recv(Kokkos::DefaultExecutionSpace(), a, src, 0,
Expand All @@ -71,8 +71,8 @@ TYPED_TEST(RsendRecv, 1D_noncontig) {
int dst = 1;
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::send<KokkosComm::Mode::Ready>(Kokkos::DefaultExecutionSpace(),
a, dst, 0, MPI_COMM_WORLD);
KokkosComm::send<KokkosComm::CommMode::Ready>(
Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD);
} else if (1 == rank) {
int src = 0;
KokkosComm::recv(Kokkos::DefaultExecutionSpace(), a, src, 0,
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/test_ssendrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TYPED_TEST(SsendRecv, 1D_contig) {
int dst = 1;
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::send<KokkosComm::Mode::Synchronous>(
KokkosComm::send<KokkosComm::CommMode::Synchronous>(
Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD);
} else if (1 == rank) {
int src = 0;
Expand Down Expand Up @@ -71,7 +71,7 @@ TYPED_TEST(SsendRecv, 1D_noncontig) {
int dst = 1;
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::send<KokkosComm::Mode::Synchronous>(
KokkosComm::send<KokkosComm::CommMode::Synchronous>(
Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD);
} else if (1 == rank) {
int src = 0;
Expand Down

0 comments on commit eab0c8d

Please sign in to comment.