7#ifdef NF_WITH_MPI_SUPPORT
20#ifdef NF_WITH_MPI_SUPPORT
37 Init(
int argc,
char** argv)
39#ifdef NF_REQUIRE_MPI_THREAD_SUPPORT
41 MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
43 provided == MPI_THREAD_MULTIPLE,
"The MPI library does not have full thread support"
46 MPI_Init(&argc, &argv);
53 ~Init() { MPI_Finalize(); }
70 Environment(MPI_Comm commGroup = MPI_COMM_WORLD) : communicator(commGroup)
72 MPI_Initialized(&mpiInitialized);
74 if (std::getenv(
"NEON_FORCE_HOST_BUFFER") !=
nullptr) gpuAwareMpi_ =
false;
80 ~Environment() =
default;
87 bool isInitialized()
const {
return mpiInitialized == 1; }
94 size_t sizeRank()
const {
return static_cast<size_t>(mpiSize); }
101 size_t rank()
const {
return static_cast<size_t>(mpiRank); }
108 MPI_Comm comm()
const {
return communicator; }
116 bool gpuAwareMpi()
const {
return gpuAwareMpi_; }
121 bool& gpuAwareMpi() {
return gpuAwareMpi_; }
125 MPI_Comm communicator {MPI_COMM_NULL};
126 int mpiInitialized {0};
129 bool gpuAwareMpi_ {
true};
134 void updateRankData()
138 MPI_Comm_rank(communicator, &mpiRank);
139 MPI_Comm_size(communicator, &mpiSize);
#define NF_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false.
Integer types used throughout NeoN.