From 0641a4a29e9c7263249f70ac626274eb83d83718 Mon Sep 17 00:00:00 2001 From: avinashkethineedi Date: Tue, 1 Oct 2024 18:33:36 +0000 Subject: [PATCH 1/2] make MPI_Init and MPI_Finalize independent of the test fixtures [ROCm/rocshmem commit: 0f7dc708940563eaa245ae2e67a3f5ff1f869a3b] --- .../rocshmem/tests/unit_tests/shmem_gtest.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp b/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp index 3115ef5e52..d5a982f4c7 100644 --- a/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp +++ b/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp @@ -21,8 +21,24 @@ *****************************************************************************/ #include "gtest/gtest.h" +#include int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + + int initialized; + MPI_Initialized(&initialized); + if (!initialized) { + int provided; + MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &provided); + } + + int ret_val = RUN_ALL_TESTS(); + + int finalized{0}; + MPI_Finalized(&finalized); + if (!finalized) { + MPI_Finalize(); + } + return ret_val; } From 285ac5cab6c0412d3a9e33f0f5e17d23deb6eb78 Mon Sep 17 00:00:00 2001 From: avinashkethineedi Date: Tue, 1 Oct 2024 20:05:15 +0000 Subject: [PATCH 2/2] Add MPI_THREAD_MULTIPLE check [ROCm/rocshmem commit: 2f0739d8234eafe8852309cc806dfd8f802bd381] --- projects/rocshmem/tests/unit_tests/shmem_gtest.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp b/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp index d5a982f4c7..8536ca638a 100644 --- a/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp +++ b/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp @@ -31,6 +31,9 @@ int main(int argc, char **argv) { if (!initialized) { int provided; MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &provided); + if (provided != MPI_THREAD_MULTIPLE) { + std::cerr << "MPI_THREAD_MULTIPLE support disabled.\n"; + } } int ret_val = RUN_ALL_TESTS();