From 6a6574748e5f71a6413b9376e09d097890e1b94c Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Thu, 20 Dec 2018 19:10:46 -0500 Subject: [PATCH] Make all thread-mpi threads release cr structure done_commrec had only been called on master thread, leading to potential leaks Change-Id: I03215880e9ded9c18dc0642357889f9e469f2a4f --- src/gromacs/gmxlib/network.cpp | 11 +++++++---- src/gromacs/mdrun/runner.cpp | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gromacs/gmxlib/network.cpp b/src/gromacs/gmxlib/network.cpp index 9276f5a444..3acd596aca 100644 --- a/src/gromacs/gmxlib/network.cpp +++ b/src/gromacs/gmxlib/network.cpp @@ -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); } diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index f2578234ec..81ae467a68 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -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; } -- 2.22.0