Skip to content

Commit e7dc076

Browse files
authored
Configure Open MPI shmem defaults on macOS (#802)
Open MPI 5 can warn while probing mmap backing files under macOS TMPDIR paths, so default to the POSIX shmem component before MPI_Init unless the user already configured it
1 parent c629ff1 commit e7dc076

11 files changed

Lines changed: 39 additions & 2 deletions

File tree

.clang-format

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ UseTab: Never
66
AllowShortFunctionsOnASingleLine: Empty
77
IndentPPDirectives: AfterHash
88
SortIncludes: true
9+
IncludeCategories:
10+
- Regex: '^<gtest/.*\.h>'
11+
Priority: 1
12+
SortPriority: 0
13+
CaseSensitive: false
14+
- Regex: '^<.*\.h>'
15+
Priority: 2
16+
SortPriority: 0
17+
CaseSensitive: false
18+
- Regex: '^<.*'
19+
Priority: 3
20+
SortPriority: 0
21+
CaseSensitive: false
22+
- Regex: '.*'
23+
Priority: 4
24+
SortPriority: 0
25+
CaseSensitive: false
926
FixNamespaceComments: true
1027
InsertBraces: true
1128
QualifierAlignment: Left

modules/runners/src/runners.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "runners/include/runners.hpp"
22

33
#include <gtest/gtest.h>
4+
45
#include <mpi.h>
56

67
#include <chrono>
@@ -140,6 +141,7 @@ int RunAllTestsSafely() {
140141
} // namespace
141142

142143
int Init(int argc, char **argv) {
144+
ppc::util::ConfigureMpiEnvironment();
143145
const int init_res = MPI_Init(&argc, &argv);
144146
if (init_res != MPI_SUCCESS) {
145147
std::cerr << std::format("[ ERROR ] MPI_Init failed with code {}", init_res) << '\n';

modules/util/include/func_test_util.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <gtest/gtest.h>
4+
45
#include <tbb/tick_count.h>
56

67
#include <concepts>

modules/util/include/perf_test_util.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22

3-
#include <benchmark/benchmark.h>
43
#include <gtest/gtest.h>
4+
5+
#include <benchmark/benchmark.h>
56
#include <mpi.h>
67
#include <omp.h>
78
#include <tbb/tick_count.h>

modules/util/include/util.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ double GetTaskMaxTime();
9595
double GetPerfMaxTime();
9696
double GetTimeMPI();
9797
int GetMPIRank();
98+
void ConfigureMpiEnvironment();
9899
void SynchronizeMpiRanks();
99100

100101
template <typename T>

modules/util/src/util.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ bool ppc::util::IsUnderMpirun() {
6868
});
6969
}
7070

71+
void ppc::util::ConfigureMpiEnvironment() {
72+
#ifdef __APPLE__
73+
// Open MPI 5 can emit mmap backing-file probe warnings for macOS TMPDIR paths.
74+
if (!env::get<std::string>("OMPI_MCA_shmem").has_value()) {
75+
env::detail::set_environment_variable("OMPI_MCA_shmem", "posix");
76+
}
77+
#endif
78+
}
79+
7180
void ppc::util::SynchronizeMpiRanks() {
7281
int initialized = 0;
7382
if (MPI_Initialized(&initialized) != MPI_SUCCESS || initialized == 0) {

tasks/common/runners/performance.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#include <gtest/gtest.h>
2+
13
#include <benchmark/benchmark.h>
24
#include <benchmark/reporter.h>
3-
#include <gtest/gtest.h>
45
#include <mpi.h>
56

67
#include <chrono>
@@ -177,6 +178,7 @@ int SynchronizeStatus(int local_status, std::string_view stage) {
177178
}
178179

179180
int RunPerformanceMain(int argc, char **argv) {
181+
ppc::util::ConfigureMpiEnvironment();
180182
const int init_res = MPI_Init(&argc, &argv);
181183
if (init_res != MPI_SUCCESS) {
182184
std::cerr << "[ ERROR ] MPI_Init failed with code " << init_res << '\n';

tasks/example/processes/t1/tests/functional/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <gtest/gtest.h>
2+
23
#include <stb/stb_image.h>
34

45
#include <algorithm>

tasks/example/processes/t2/tests/functional/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <gtest/gtest.h>
2+
23
#include <stb/stb_image.h>
34

45
#include <algorithm>

tasks/example/processes/t3/tests/functional/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <gtest/gtest.h>
2+
23
#include <stb/stb_image.h>
34

45
#include <algorithm>

0 commit comments

Comments
 (0)