Avoid near-silent generation of zero energies
authorMark Abraham <mark.j.abraham@gmail.com>
Fri, 23 Jan 2015 14:28:01 +0000 (15:28 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 2 Feb 2015 14:48:57 +0000 (15:48 +0100)
There is note printed about this case for Verlet+GPU+energy groups,
and this is OK for normal simulations because the decomposition of the
energy into groups is unimportant. However, a user doing such a rerun
is probably seeking the energy decomposition, and in that case getting
zeroes is unexpected behaviour.

Instead, default to not using GPUs with mdrun -rerun -nb auto and more
than one energy group. In that case with mdrun -rerun -nb gpu, give a
fatal error and suggest the probable solutions.

Change-Id: I3006ed3ded31620d4faf4fc4a24cc85e9322c5c2

src/programs/mdrun/md.c
src/programs/mdrun/runner.c

index ca7e29a2bf79107f6843f1f233b2dbe7b611d4d9..73cc2103e6192901a09bc7f38a54a1eab4809231 100644 (file)
@@ -350,6 +350,11 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
         gmx_fatal(FARGS, "Normal Mode analysis is not supported with virtual sites.\nIf you'd like to help with adding support, we have an open discussion at http://redmine.gromacs.org/issues/879\n");
     }
 
+    if (bRerunMD && fr->cutoff_scheme == ecutsVERLET && ir->opts.ngener > 1 && fr->nbv && fr->nbv->bUseGPU)
+    {
+        gmx_fatal(FARGS, "The Verlet scheme on GPUs does not support energy groups, so your rerun should probably use a .tpr file without energy groups, or mdrun -nb auto");
+    }
+
     if (DEFORM(*ir))
     {
         tMPI_Thread_mutex_lock(&deform_init_box_mutex);
index 9129317a255091612f00be9f8f5198c508a7e282..c87a06497ec9ea1a91bb0ad101c5367dab951be1 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, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015, 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.
@@ -1092,7 +1092,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
              int repl_ex_seed, real pforce, real cpt_period, real max_hours,
              const char *deviceOptions, int imdport, unsigned long Flags)
 {
-    gmx_bool                  bForceUseGPU, bTryUseGPU;
+    gmx_bool                  bForceUseGPU, bTryUseGPU, bRerunMD, bCantUseGPU;
     double                    nodetime = 0, realtime;
     t_inputrec               *inputrec;
     t_state                  *state = NULL;
@@ -1137,8 +1137,20 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
         fplog = NULL;
     }
 
+    bRerunMD     = (Flags & MD_RERUN);
     bForceUseGPU = (strncmp(nbpu_opt, "gpu", 3) == 0);
     bTryUseGPU   = (strncmp(nbpu_opt, "auto", 4) == 0) || bForceUseGPU;
+    /* Rerun execution time is dominated by I/O and pair search, so
+     * GPUs are not very useful, plus they do not support more than
+     * one energy group. Don't select them when they can't be used,
+     * unless the user requested it, then fatal_error is called later.
+     *
+     * TODO it would be nice to notify the user that if this check
+     * causes GPUs not to be used that this is what is happening, and
+     * why, but that will be easier to do after some future
+     * cleanup. */
+    bCantUseGPU = bRerunMD && (inputrec->opts.ngener > 1);
+    bTryUseGPU  = bTryUseGPU && !(bCantUseGPU && !bForceUseGPU);
 
     /* Detect hardware, gather information. This is an operation that is
      * global for this process (MPI rank). */
@@ -1345,7 +1357,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
                   );
     }
 
-    if ((Flags & MD_RERUN) &&
+    if (bRerunMD &&
         (EI_ENERGY_MINIMIZATION(inputrec->eI) || eiNM == inputrec->eI))
     {
         gmx_fatal(FARGS, "The .mdp file specified an energy mininization or normal mode algorithm, and these are not compatible with mdrun -rerun");