13 : initializedByThisInstance(false)
16 const int ret = MPI_Initialized(&initialized);
18 if(ret != MPI_SUCCESS)
25 MPI_Init_thread(NULL, NULL, MPI_THREAD_FUNNELED, &provided);
27 if(ret != MPI_SUCCESS)
30 if(provided < MPI_THREAD_FUNNELED)
36 "`MPI_Init_thread` failed to provide a thread-safe "
40 initializedByThisInstance =
true;
46 #if defined(OPENMPCD_COMPILER_GCC) && __GNUC__ >= 6
47 #pragma GCC diagnostic push
48 #pragma GCC diagnostic ignored "-Wterminate"
52 const int ret = MPI_Finalized(&finalized);
54 if(ret != MPI_SUCCESS)
59 if(initializedByThisInstance)
62 "`MPI_Finalized` has been called by the wrong instance.");
66 if(initializedByThisInstance)
68 const int ret = MPI_Finalize();
69 if(ret != MPI_SUCCESS)
74 #if defined(OPENMPCD_COMPILER_GCC) && __GNUC__ >= 6
75 #pragma GCC diagnostic push
83 const int ret = MPI_Comm_size(MPI_COMM_WORLD, &size);
84 if(ret != MPI_SUCCESS)
87 #ifdef OPENMPCD_COMPILER_GCC
88 #pragma GCC diagnostic push
89 #pragma GCC diagnostic ignored "-Wsign-compare"
93 #ifdef OPENMPCD_COMPILER_GCC
94 #pragma GCC diagnostic push
97 return static_cast<std::size_t
>(size);
104 const int ret = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
105 if(ret != MPI_SUCCESS)
108 #ifdef OPENMPCD_COMPILER_GCC
109 #pragma GCC diagnostic push
110 #pragma GCC diagnostic ignored "-Wsign-compare"
114 #ifdef OPENMPCD_COMPILER_GCC
115 #pragma GCC diagnostic push
118 return static_cast<std::size_t
>(rank);
123 if(MPI_Barrier(MPI_COMM_WORLD) != MPI_SUCCESS)
128 MPI_Request*
const request, std::size_t*
const sender)
const
130 #ifdef OPENMPCD_DEBUG
134 if(*request == MPI_REQUEST_NULL)
140 const int ret = MPI_Test(request, &completed, &status);
141 if(ret != MPI_SUCCESS)
144 if(completed && sender != NULL)
146 #ifdef OPENMPCD_COMPILER_GCC
147 #pragma GCC diagnostic push
148 #pragma GCC diagnostic ignored "-Wsign-compare"
152 status.MPI_SOURCE <= std::numeric_limits<std::size_t>::max());
153 #ifdef OPENMPCD_COMPILER_GCC
154 #pragma GCC diagnostic push
157 *sender =
static_cast<std::size_t
>(status.MPI_SOURCE);