Skip to content

Commit b6fe4e6

Browse files
committed
infra: stabilize MPI tests and prevent hangs
- Sync gtest random_seed + filter across ranks - Abort on worker failure; wrap RunAllTests with MPI_Abort on exceptions - Make PPC_TEST_TMPDIR per MPI rank - Pass env to mpiexec on Windows (-env), keep -x on *nix
1 parent 54ebdfb commit b6fe4e6

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

modules/runners/src/runners.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,6 @@
1818
#include "oneapi/tbb/global_control.h"
1919
#include "util/include/util.hpp"
2020

21-
namespace {
22-
[[maybe_unused]] void SyncGTestSeed() {
23-
unsigned int seed = 0;
24-
int rank = -1;
25-
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
26-
if (rank == 0) {
27-
try {
28-
seed = std::random_device{}();
29-
} catch (...) {
30-
seed = 0;
31-
}
32-
if (seed == 0) {
33-
const auto now = static_cast<std::uint64_t>(std::chrono::steady_clock::now().time_since_epoch().count());
34-
seed = static_cast<unsigned int>(((now & 0x7fffffffULL) | 1ULL));
35-
}
36-
}
37-
MPI_Bcast(&seed, 1, MPI_UNSIGNED, 0, MPI_COMM_WORLD);
38-
::testing::GTEST_FLAG(random_seed) = static_cast<int>(seed);
39-
}
40-
41-
[[maybe_unused]] void SyncGTestFilter() {
42-
int rank = -1;
43-
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
44-
std::string filter = (rank == 0) ? ::testing::GTEST_FLAG(filter) : std::string{};
45-
int len = static_cast<int>(filter.size());
46-
MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
47-
if (rank != 0) {
48-
filter.resize(static_cast<std::size_t>(len));
49-
}
50-
if (len > 0) {
51-
MPI_Bcast(filter.data(), len, MPI_CHAR, 0, MPI_COMM_WORLD);
52-
}
53-
::testing::GTEST_FLAG(filter) = filter;
54-
}
55-
56-
[[maybe_unused]] bool HasFlag(int argc, char **argv, std::string_view flag) {
57-
for (int i = 1; i < argc; ++i) {
58-
if (argv[i] != nullptr && std::string_view(argv[i]) == flag) {
59-
return true;
60-
}
61-
}
62-
return false;
63-
}
64-
} // namespace
65-
6621
namespace ppc::runners {
6722

6823
void UnreadMessagesDetector::OnTestEnd(const ::testing::TestInfo & /*test_info*/) {

0 commit comments

Comments
 (0)