Skip to content

Commit

Permalink
chore: fix include in CMake & format
Browse files Browse the repository at this point in the history
  • Loading branch information
dssgabriel committed Nov 4, 2024
1 parent c54fb9d commit d4b3045
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/KokkosComm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if(KOKKOSCOMM_ENABLE_MPI)
endif()

# --- COMPILE FLAGS --- #
src(CheckCXXCompilerFlag)
include(CheckCXXCompilerFlag)

macro(kokkoscomm_check_and_add_compile_options)
set(target ${ARGV0})
Expand Down
9 changes: 6 additions & 3 deletions unit_tests/mpi/test_allgather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ void test_allgather_0d() {
Kokkos::View<Scalar *> rv("rv", size);

// fill send buffer
Kokkos::parallel_for(sv.extent(0), KOKKOS_LAMBDA(const int) { sv() = rank; });
Kokkos::parallel_for(
sv.extent(0), KOKKOS_LAMBDA(const int) { sv() = rank; });

KokkosComm::mpi::allgather(Kokkos::DefaultExecutionSpace(), sv, rv, MPI_COMM_WORLD);

int errs;
Kokkos::parallel_reduce(rv.extent(0), KOKKOS_LAMBDA(const int &src, int &lsum) { lsum += rv(src) != src; }, errs);
Kokkos::parallel_reduce(
rv.extent(0), KOKKOS_LAMBDA(const int &src, int &lsum) { lsum += rv(src) != src; }, errs);
EXPECT_EQ(errs, 0);
}

Expand All @@ -62,7 +64,8 @@ void test_allgather_1d_contig() {
Kokkos::View<Scalar *> rv("rv", size * nContrib);

// fill send buffer
Kokkos::parallel_for(sv.extent(0), KOKKOS_LAMBDA(const int i) { sv(i) = rank + i; });
Kokkos::parallel_for(
sv.extent(0), KOKKOS_LAMBDA(const int i) { sv(i) = rank + i; });

KokkosComm::mpi::allgather(Kokkos::DefaultExecutionSpace(), sv, rv, MPI_COMM_WORLD);

Expand Down
6 changes: 4 additions & 2 deletions unit_tests/mpi/test_alltoall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void test_alltoall_1d_contig() {
Kokkos::View<Scalar *> rv("rv", size * nContrib);

// fill send buffer
Kokkos::parallel_for(sv.extent(0), KOKKOS_LAMBDA(const int i) { sv(i) = rank + i; });
Kokkos::parallel_for(
sv.extent(0), KOKKOS_LAMBDA(const int i) { sv(i) = rank + i; });

KokkosComm::Impl::alltoall(Kokkos::DefaultExecutionSpace(), sv, nContrib, rv, nContrib, MPI_COMM_WORLD);

Expand Down Expand Up @@ -70,7 +71,8 @@ void test_alltoall_1d_inplace_contig() {
Kokkos::View<Scalar *> rv("rv", size * nContrib);

// fill send buffer
Kokkos::parallel_for(rv.extent(0), KOKKOS_LAMBDA(const int i) { rv(i) = rank + i; });
Kokkos::parallel_for(
rv.extent(0), KOKKOS_LAMBDA(const int i) { rv(i) = rank + i; });

KokkosComm::Impl::alltoall(Kokkos::DefaultExecutionSpace(), rv, nContrib, MPI_COMM_WORLD);

Expand Down
12 changes: 8 additions & 4 deletions unit_tests/mpi/test_isendrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ void isend_comm_mode_1d_contig() {

if (0 == h.rank()) {
int dst = 1;
Kokkos::parallel_for(a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::Req req = KokkosComm::mpi::isend(h, a, dst, 0, IsendMode{});
KokkosComm::wait(req);
} else if (1 == h.rank()) {
int src = 0;
KokkosComm::mpi::recv(h.space(), a, src, 0, h.mpi_comm());
int errs;
Kokkos::parallel_reduce(a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != Scalar(i); }, errs);
Kokkos::parallel_reduce(
a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != Scalar(i); }, errs);
ASSERT_EQ(errs, 0);
}
}
Expand All @@ -78,14 +80,16 @@ void isend_comm_mode_1d_noncontig() {

if (0 == h.rank()) {
int dst = 1;
Kokkos::parallel_for(a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::Req req = KokkosComm::mpi::isend(h, a, dst, 0, IsendMode{});
KokkosComm::wait(req);
} else if (1 == h.rank()) {
int src = 0;
KokkosComm::mpi::recv(h.space(), a, src, 0, h.mpi_comm());
int errs;
Kokkos::parallel_reduce(a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != Scalar(i); }, errs);
Kokkos::parallel_reduce(
a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != Scalar(i); }, errs);
ASSERT_EQ(errs, 0);
}
}
Expand Down
3 changes: 2 additions & 1 deletion unit_tests/mpi/test_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ void test_reduce_1d_contig() {
}

// fill send buffer
Kokkos::parallel_for(sendv.extent(0), KOKKOS_LAMBDA(const int i) { sendv(i) = rank + i; });
Kokkos::parallel_for(
sendv.extent(0), KOKKOS_LAMBDA(const int i) { sendv(i) = rank + i; });

KokkosComm::mpi::reduce(Kokkos::DefaultExecutionSpace(), sendv, recvv, MPI_SUM, 0, MPI_COMM_WORLD);

Expand Down
12 changes: 8 additions & 4 deletions unit_tests/mpi/test_sendrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ void send_comm_mode_1d_contig() {

if (0 == rank) {
int dst = 1;
Kokkos::parallel_for(a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::mpi::send(Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD, SendMode{});
} else if (1 == rank) {
int src = 0;
KokkosComm::mpi::recv(Kokkos::DefaultExecutionSpace(), a, src, 0, MPI_COMM_WORLD);
int errs;
Kokkos::parallel_reduce(a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != i; }, errs);
Kokkos::parallel_reduce(
a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != i; }, errs);
ASSERT_EQ(errs, 0);
}
}
Expand All @@ -76,13 +78,15 @@ void send_comm_mode_1d_noncontig() {

if (0 == rank) {
int dst = 1;
Kokkos::parallel_for(a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::mpi::send(Kokkos::DefaultExecutionSpace(), a, dst, 0, MPI_COMM_WORLD, SendMode{});
} else if (1 == rank) {
int src = 0;
KokkosComm::mpi::recv(Kokkos::DefaultExecutionSpace(), a, src, 0, MPI_COMM_WORLD);
int errs;
Kokkos::parallel_reduce(a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != i; }, errs);
Kokkos::parallel_reduce(
a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != i; }, errs);
ASSERT_EQ(errs, 0);
}
}
Expand Down
9 changes: 6 additions & 3 deletions unit_tests/test_sendrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ void test_1d(const View1D &a) {

if (0 == h.rank()) {
int dst = 1;
Kokkos::parallel_for(a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
Kokkos::parallel_for(
a.extent(0), KOKKOS_LAMBDA(const int i) { a(i) = i; });
KokkosComm::wait(KokkosComm::send(h, a, dst));
} else if (1 == h.rank()) {
int src = 0;
KokkosComm::wait(KokkosComm::recv(h, a, src));
int errs;
Kokkos::parallel_reduce(a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != Scalar(i); }, errs);
Kokkos::parallel_reduce(
a.extent(0), KOKKOS_LAMBDA(const int &i, int &lsum) { lsum += a(i) != Scalar(i); }, errs);
ASSERT_EQ(errs, 0);
}
}
Expand All @@ -69,7 +71,8 @@ void test_2d(const View2D &a) {

if (0 == h.rank()) {
int dst = 1;
Kokkos::parallel_for(policy, KOKKOS_LAMBDA(int i, int j) { a(i, j) = i * a.extent(0) + j; });
Kokkos::parallel_for(
policy, KOKKOS_LAMBDA(int i, int j) { a(i, j) = i * a.extent(0) + j; });
KokkosComm::wait(KokkosComm::send(h, a, dst));
} else if (1 == h.rank()) {
int src = 0;
Expand Down

0 comments on commit d4b3045

Please sign in to comment.