52 {
53#if defined(GPR_HAVE_MPI) || defined(GPR_LINALG_SCALAPACK)
54 int finalized = 0;
55 MPI_Finalized(&finalized);
56 if (finalized)
57 throw std::runtime_error("cannot enter a finalized MPI world");
58 int initialized = 0;
59 MPI_Initialized(&initialized);
60 borrowed_ = initialized != 0;
61 int provided = MPI_THREAD_SINGLE;
62 if (!borrowed_) {
64 if (MPI_Init_thread(&argc, &argv,
65 linalg::requiredMpiThreadSupport(),
66 &provided) != MPI_SUCCESS)
67 throw std::runtime_error("could not initialize MPI");
68 owns_ = true;
69 } else if (MPI_Query_thread(&provided) != MPI_SUCCESS) {
70 throw std::runtime_error("could not inspect MPI thread support");
71 }
72 if (provided < linalg::requiredMpiThreadSupport()) {
74 throw std::runtime_error(linalg::mpiThreadSupportError());
75 }
76#else
77 (void)argc;
78 (void)argv;
79#endif
80 }
void excludeLibfabricBtlOnOneNode() noexcept