Skip to content

Commit

Permalink
Merge pull request #93 from hmt23/develop
Browse files Browse the repository at this point in the history
Replace MPI_Init to MPI_Init_thread when needed
  • Loading branch information
cwpearson authored Jun 19, 2024
2 parents e314fb6 + 859ea43 commit ceefa75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions perf_tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ 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 provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
if (provided != MPI_THREAD_MULTIPLE) {
throw std::runtime_error("MPI_THREAD_MULTIPLE is needed");
}

int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
Expand All @@ -54,4 +58,4 @@ int main(int argc, char **argv) {
Kokkos::finalize();
MPI_Finalize();
return 0;
}
}
6 changes: 5 additions & 1 deletion unit_tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ int main(int argc, char *argv[]) {
// Intialize google test
::testing::InitGoogleTest(&argc, argv);

MPI_Init(&argc, &argv);
int provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
if (provided != MPI_THREAD_MULTIPLE) {
throw std::runtime_error("MPI_THREAD_MULTIPLE is needed");
}
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
Expand Down

0 comments on commit ceefa75

Please sign in to comment.