Skip to content

Commit

Permalink
test(init/fini): update tests with new initialization/finalization APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
dssgabriel committed Jun 14, 2024
1 parent c99193b commit 6229187
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
15 changes: 6 additions & 9 deletions perf_tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//@HEADER

#include "KokkosComm_include_mpi.hpp"
#include "KokkosComm.hpp"

#include <Kokkos_Core.hpp>
#include <benchmark/benchmark.h>
Expand All @@ -32,15 +33,12 @@ class NullReporter : public ::benchmark::BenchmarkReporter {
// The main is rewritten to allow for MPI initializing and for selecting a
// reporter according to the process rank
int main(int argc, char **argv) {
MPI_Init(&argc, &argv);

int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

Kokkos::initialize();
KokkosComm::initialize(argc, &argv);

::benchmark::Initialize(&argc, argv);

int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)
// root process will use a reporter from the usual set provided by
// ::benchmark
Expand All @@ -51,7 +49,6 @@ int main(int argc, char **argv) {
::benchmark::RunSpecifiedBenchmarks(&null);
}

Kokkos::finalize();
MPI_Finalize();
KokkosComm::finalize();
return 0;
}
}
10 changes: 4 additions & 6 deletions unit_tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ int main(int argc, char *argv[]) {
// Intialize google test
::testing::InitGoogleTest(&argc, argv);

MPI_Init(&argc, &argv);
KokkosComm::initialize(argc, &argv);

int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
Expand All @@ -90,8 +91,6 @@ int main(int argc, char *argv[]) {
<< KOKKOSCOMM_VERSION_PATCH << ")\n";
}

Kokkos::initialize();

// Intialize google test
::testing::InitGoogleTest(&argc, argv);

Expand All @@ -105,9 +104,8 @@ int main(int argc, char *argv[]) {
// run tests
auto exit_code = RUN_ALL_TESTS();

// Finalize MPI before exiting
Kokkos::finalize();
MPI_Finalize();
// Finalize KokkosComm before exiting
KokkosComm::finalize();

return exit_code;
}

0 comments on commit 6229187

Please sign in to comment.