From fba2b37310684f3caf1d21929855ca44d9c937c5 Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Thu, 20 Dec 2018 18:38:56 -0500 Subject: [PATCH] Call wallcycle counter cleanup function Cleans leak from unfreed wallcycle at end of mdrunner Change-Id: I18c9a4eb961c1480230dda98c02f75e3796aa3b4 --- src/gromacs/mdrun/runner.cpp | 3 +++ src/gromacs/timing/wallcycle.cpp | 8 +++----- src/gromacs/timing/wallcycle.h | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 060c83f33a..f2578234ec 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -1458,6 +1458,9 @@ int Mdrunner::mdrunner() pmedata, EI_DYNAMICS(inputrec->eI) && !isMultiSim(ms)); + // clean up cycle counter + wallcycle_destroy(wcycle); + // Free PME data if (pmedata) { diff --git a/src/gromacs/timing/wallcycle.cpp b/src/gromacs/timing/wallcycle.cpp index 92ce8cb343..9655d98868 100644 --- a/src/gromacs/timing/wallcycle.cpp +++ b/src/gromacs/timing/wallcycle.cpp @@ -205,9 +205,8 @@ gmx_wallcycle_t wallcycle_init(FILE *fplog, int resetstep, t_commrec gmx_unused return wc; } -/* TODO: Should be called from finish_run() or runner() - void wallcycle_destroy(gmx_wallcycle_t wc) - { +void wallcycle_destroy(gmx_wallcycle_t wc) +{ if (wc == nullptr) { return; @@ -226,8 +225,7 @@ gmx_wallcycle_t wallcycle_init(FILE *fplog, int resetstep, t_commrec gmx_unused sfree(wc->wcsc); } sfree(wc); - } - */ +} static void wallcycle_all_start(gmx_wallcycle_t wc, int ewc, gmx_cycles_t cycle) { diff --git a/src/gromacs/timing/wallcycle.h b/src/gromacs/timing/wallcycle.h index 9468a0b60a..cbf7596544 100644 --- a/src/gromacs/timing/wallcycle.h +++ b/src/gromacs/timing/wallcycle.h @@ -90,6 +90,9 @@ gmx_wallcycle_t wallcycle_init(FILE *fplog, int resetstep, struct t_commrec *cr) * Returns NULL when cycle counting is not supported. */ +/* cleans up wallcycle structure */ +void wallcycle_destroy(gmx_wallcycle_t wc); + void wallcycle_start(gmx_wallcycle_t wc, int ewc); /* Starts the cycle counter (and increases the call count) */ -- 2.22.0