Don't print invalid performance data
authorMark Abraham <mark.j.abraham@gmail.com>
Fri, 20 Jan 2017 15:08:24 +0000 (16:08 +0100)
committerDavid van der Spoel <davidvanderspoel@gmail.com>
Mon, 30 Jan 2017 15:01:50 +0000 (16:01 +0100)
If mdrun finished before a scheduled reset of the timing information
(e.g. from mdrun -resetstep or mdrun -resethway), then misleading
timing information should not be reported.

Fixes #2041

Change-Id: I4bd4383c924a342c01e9a3f06b521da128f96a35

src/gromacs/mdlib/sim_util.cpp
src/gromacs/timing/walltime_accounting.cpp
src/gromacs/timing/walltime_accounting.h
src/programs/mdrun/md.cpp

index 5fd64cb318699b095a0d60214ea0a15198d71725..11a2f4faca27b4d98738f9e080265ddcf56d05d3 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -52,6 +52,7 @@
 #include "gromacs/essentialdynamics/edsam.h"
 #include "gromacs/ewald/pme.h"
 #include "gromacs/gmxlib/chargegroup.h"
+#include "gromacs/gmxlib/md_logging.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/gmxlib/nrnb.h"
 #include "gromacs/gmxlib/nonbonded/nb_free_energy.h"
@@ -2574,6 +2575,13 @@ void finish_run(FILE *fplog, t_commrec *cr,
             elapsed_time_over_all_threads,
             elapsed_time_over_all_threads_over_all_ranks;
 
+    if (!walltime_accounting_get_valid_finish(walltime_accounting))
+    {
+        md_print_warn(cr, fplog,
+                      "Simulation ended prematurely, no performance report will be written.");
+        return;
+    }
+
     if (cr->nnodes > 1)
     {
         snew(nrnb_tot, 1);
index bfcbf1d294cd28349c9483d850168e5a1b8911d7..eeb199eded1af28afc73abfb6996993571fdd239 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2013, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -86,6 +86,8 @@ typedef struct gmx_walltime_accounting {
     int             numOpenMPThreads;
     //! Set by integrators to report the amount of work they did
     gmx_int64_t     nsteps_done;
+    //! Whether the simulation has finished in a way valid for walltime reporting.
+    bool            isValidFinish;
 } t_gmx_walltime_accounting;
 
 /*! \brief Calls system timing routines (e.g. clock_gettime) to get
@@ -116,6 +118,7 @@ walltime_accounting_init(int numOpenMPThreads)
     walltime_accounting->elapsed_time                = 0;
     walltime_accounting->nsteps_done                 = 0;
     walltime_accounting->numOpenMPThreads            = numOpenMPThreads;
+    walltime_accounting->isValidFinish               = false;
 
     return walltime_accounting;
 }
@@ -229,6 +232,19 @@ gmx_gettime()
 #endif
 }
 
+void
+walltime_accounting_set_valid_finish(gmx_walltime_accounting_t walltime_accounting)
+{
+    walltime_accounting->isValidFinish = true;
+}
+
+//! Return whether the simulation finished in a way valid for reporting walltime.
+bool
+walltime_accounting_get_valid_finish(const gmx_walltime_accounting_t walltime_accounting)
+{
+    return walltime_accounting->isValidFinish;
+}
+
 static double
 gmx_gettime_per_thread()
 {
index fe1767fe2c67d0a3f5678427a8235af1d151842f..41f4df888aa3d4157f331dcbee9ddaf3ad4d0792 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2017, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -102,6 +102,14 @@ void
 walltime_accounting_set_nsteps_done(gmx_walltime_accounting_t   walltime_accounting,
                                     gmx_int64_t                 nsteps_done);
 
+//! Record that the simulation finished in a way valid for reporting walltime.
+void
+walltime_accounting_set_valid_finish(gmx_walltime_accounting_t walltime_accounting);
+
+//! Return whether the simulation finished in a way valid for reporting walltime.
+bool
+walltime_accounting_get_valid_finish(const gmx_walltime_accounting_t walltime_accounting);
+
 /*! \brief
  * Calls system timing routines (e.g. clock_gettime) to get the (fractional)
  * number of seconds elapsed since the epoch.
index 06c25f321404e012b870cfff79c5044308431b7e..4c4d069ef4f0712d010b4ca666c4c7bd618e180a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -1839,6 +1839,12 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     IMD_finalize(ir->bIMD, ir->imd);
 
     walltime_accounting_set_nsteps_done(walltime_accounting, step_rel);
+    if (step_rel >= wcycle_get_reset_counters(wcycle) &&
+        signals[eglsRESETCOUNTERS].set == 0 &&
+        !bResetCountersHalfMaxH)
+    {
+        walltime_accounting_set_valid_finish(walltime_accounting);
+    }
 
     return 0;
 }