Make all thread-mpi threads release cr structure
authorKevin Boyd <kevin.boyd@uconn.edu>
Fri, 21 Dec 2018 00:10:46 +0000 (19:10 -0500)
committerDavid van der Spoel <spoel@xray.bmc.uu.se>
Thu, 27 Dec 2018 12:44:18 +0000 (13:44 +0100)
done_commrec had only been called on master thread, leading to
potential leaks

Change-Id: I03215880e9ded9c18dc0642357889f9e469f2a4f

src/gromacs/gmxlib/network.cpp
src/gromacs/mdrun/runner.cpp

index 9276f5a444a83fb0d147ac4baeb28e22a26fbf25..3acd596aca74c9727223d135ba3935d5b35adce5 100644 (file)
@@ -125,12 +125,15 @@ void done_mpi_in_place_buf(mpi_in_place_buf_t *buf)
 
 void done_commrec(t_commrec *cr)
 {
-    if (nullptr != cr->dd)
+    if (MASTER(cr))
     {
-        // TODO: implement
-        // done_domdec(cr->dd);
+        if (nullptr != cr->dd)
+        {
+            // TODO: implement
+            // done_domdec(cr->dd);
+        }
+        done_mpi_in_place_buf(cr->mpb);
     }
-    done_mpi_in_place_buf(cr->mpb);
     sfree(cr);
 }
 
index f2578234ec46bff0390db83bcf9a502f710fb410..81ae467a68d7c03153a299c4578d95495b51852b 100644 (file)
@@ -1516,11 +1516,11 @@ int Mdrunner::mdrunner()
        wait for that. */
     if (PAR(cr) && MASTER(cr))
     {
-        done_commrec(cr);
         tMPI_Finalize();
     }
+    //TODO free commrec in MPI simulations
+    done_commrec(cr);
 #endif
-
     return rc;
 }