Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
handle pending asynchronous requests on finalize (should be harmless in
authorsuter <frederic.suter@cc.in2p3.fr>
Wed, 6 Nov 2013 17:39:48 +0000 (18:39 +0100)
committersuter <frederic.suter@cc.in2p3.fr>
Wed, 6 Nov 2013 17:39:48 +0000 (18:39 +0100)
most cases, everybody should has completed)

src/smpi/smpi_replay.c

index a57b594..507957f 100644 (file)
@@ -965,10 +965,23 @@ void smpi_replay_init(int *argc, char***argv){
 int smpi_replay_finalize(){
   double sim_time= 1.;
   /* One active process will stop. Decrease the counter*/
-  active_processes--;
   XBT_DEBUG("There are %lu elements in reqq[*]",
             xbt_dynar_length(reqq[smpi_comm_rank(MPI_COMM_WORLD)]));
-  xbt_dynar_free(&reqq[smpi_comm_rank(MPI_COMM_WORLD)]);
+  if (!xbt_dynar_is_empty(reqq[smpi_comm_rank(MPI_COMM_WORLD)])){
+    int count_requests=xbt_dynar_length(reqq[smpi_comm_rank(MPI_COMM_WORLD)]);
+    MPI_Request requests[count_requests];
+    MPI_Status status[count_requests];
+    unsigned int i;
+
+    xbt_dynar_foreach(reqq[smpi_comm_rank(MPI_COMM_WORLD)],i,requests[i]);
+    smpi_mpi_waitall(count_requests, requests, status);
+    active_processes--;
+  } else {
+    active_processes--;
+  }
+
+  xbt_dynar_free_container(&(reqq[smpi_comm_rank(MPI_COMM_WORLD)]));
+
   if(!active_processes){
     /* Last process alive speaking */
     /* end the simulated timer */