Skip to content

Commit cc26ebe

Browse files
committed
Configure Open MPI shmem defaults on macOS
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 7d6efad commit cc26ebe

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

modules/runners/src/runners.cpp

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

33
#include <gtest/gtest.h>
4-
#include <mpi.h>
54

65
#include <chrono>
76
#include <cstdint>
@@ -10,6 +9,7 @@
109
#include <format>
1110
#include <iostream>
1211
#include <memory>
12+
#include <mpi.h>
1313
#include <random>
1414
#include <stdexcept>
1515
#include <string>
@@ -140,6 +140,7 @@ int RunAllTestsSafely() {
140140
} // namespace
141141

142142
int Init(int argc, char **argv) {
143+
ppc::util::ConfigureMpiEnvironment();
143144
const int init_res = MPI_Init(&argc, &argv);
144145
if (init_res != MPI_SUCCESS) {
145146
std::cerr << std::format("[ ERROR ] MPI_Init failed with code {}", init_res) << '\n';

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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include "util/include/util.hpp"
22

3-
#include <mpi.h>
4-
53
#include <algorithm>
64
#include <array>
75
#include <filesystem>
86
#include <libenvpp/detail/get.hpp>
7+
#include <mpi.h>
98
#include <string>
109

1110
namespace {
@@ -68,6 +67,15 @@ bool ppc::util::IsUnderMpirun() {
6867
});
6968
}
7069

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

tasks/common/runners/performance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ int SynchronizeStatus(int local_status, std::string_view stage) {
177177
}
178178

179179
int RunPerformanceMain(int argc, char **argv) {
180+
ppc::util::ConfigureMpiEnvironment();
180181
const int init_res = MPI_Init(&argc, &argv);
181182
if (init_res != MPI_SUCCESS) {
182183
std::cerr << "[ ERROR ] MPI_Init failed with code " << init_res << '\n';

0 commit comments

Comments
 (0)