Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SMPI: before terminating a process, wait for its asynchronous comms
[simgrid.git] / src / smpi / smpi_global.c
index 6fa73d2..470be9c 100644 (file)
@@ -70,6 +70,17 @@ void smpi_process_destroy(void)
   XBT_DEBUG("<%d> Process left the game", index);
 }
 
+/**
+ * @brief Prepares the current process for termination.
+ */
+void smpi_process_finalize(void)
+{
+  // wait for all pending asynchronous comms to finish
+  while (SIMIX_process_has_pending_comms(SIMIX_process_self())) {
+    SIMIX_req_process_sleep(1);
+  }
+}
+
 int smpi_process_argc(void) {
   smpi_process_data_t data = smpi_process_data();