Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : restore previous version of smpi_finalize if MC is enabled
[simgrid.git] / src / smpi / smpi_global.c
index d17f4bd..1ac052f 100644 (file)
@@ -128,44 +128,44 @@ void smpi_process_destroy(void)
  */
 void smpi_process_finalize(void)
 {
-#if 0
-  // wait for all pending asynchronous comms to finish
-  while (SIMIX_process_has_pending_comms(SIMIX_process_self())) {
-    simcall_process_sleep(0.01);
-  }
-#else
-  int i;
-  int size = smpi_comm_size(MPI_COMM_WORLD);
-  int rank = smpi_comm_rank(MPI_COMM_WORLD);
-  /* All non-root send & receive zero-length message. */
-  if (rank > 0) {
-    smpi_mpi_ssend (NULL, 0, MPI_BYTE, 0,
-                    COLL_TAG_BARRIER,
-                    MPI_COMM_WORLD);
-    smpi_mpi_recv (NULL, 0, MPI_BYTE, 0,
-                    COLL_TAG_BARRIER,
-                    MPI_COMM_WORLD, MPI_STATUS_IGNORE);
-  }
-  /* The root collects and broadcasts the messages. */
-  else {
-    MPI_Request* requests;
-    requests = (MPI_Request*)malloc( size * sizeof(MPI_Request) );
-    for (i = 1; i < size; ++i) {
-      requests[i] = smpi_mpi_irecv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE,
-                                   COLL_TAG_BARRIER, MPI_COMM_WORLD
-                                   );
+  if(MC_is_active()){
+    // wait for all pending asynchronous comms to finish
+    while (SIMIX_process_has_pending_comms(SIMIX_process_self())) {
+      simcall_process_sleep(0.01);
     }
-    smpi_mpi_waitall( size-1, requests+1, MPI_STATUSES_IGNORE );
-    for (i = 1; i < size; ++i) {
-      requests[i] = smpi_mpi_issend(NULL, 0, MPI_BYTE, i,
-                                   COLL_TAG_BARRIER,
-                                   MPI_COMM_WORLD
-                                   );
+  }else{
+    int i;
+    int size = smpi_comm_size(MPI_COMM_WORLD);
+    int rank = smpi_comm_rank(MPI_COMM_WORLD);
+    /* All non-root send & receive zero-length message. */
+    if (rank > 0) {
+      smpi_mpi_ssend (NULL, 0, MPI_BYTE, 0,
+                      COLL_TAG_BARRIER,
+                      MPI_COMM_WORLD);
+      smpi_mpi_recv (NULL, 0, MPI_BYTE, 0,
+                     COLL_TAG_BARRIER,
+                     MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+    }
+    /* The root collects and broadcasts the messages. */
+    else {
+      MPI_Request* requests;
+      requests = (MPI_Request*)malloc( size * sizeof(MPI_Request) );
+      for (i = 1; i < size; ++i) {
+        requests[i] = smpi_mpi_irecv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE,
+                                     COLL_TAG_BARRIER, MPI_COMM_WORLD
+                                     );
+      }
+      smpi_mpi_waitall( size-1, requests+1, MPI_STATUSES_IGNORE );
+      for (i = 1; i < size; ++i) {
+        requests[i] = smpi_mpi_issend(NULL, 0, MPI_BYTE, i,
+                                      COLL_TAG_BARRIER,
+                                      MPI_COMM_WORLD
+                                      );
+      }
+      smpi_mpi_waitall( size-1, requests+1, MPI_STATUSES_IGNORE );
+      free( requests );
     }
-    smpi_mpi_waitall( size-1, requests+1, MPI_STATUSES_IGNORE );
-    free( requests );
   }
-#endif
 }
 
 /**