Disable GPU update in the presence of frozen atoms
authorAndrey Alekseenko <al42and@gmail.com>
Thu, 11 Mar 2021 11:43:07 +0000 (11:43 +0000)
committerPaul Bauer <paul.bauer.q@gmail.com>
Thu, 11 Mar 2021 11:43:07 +0000 (11:43 +0000)
There is a known bug (Issue #3920) affecting GPU update when frozen
atoms are present. The bug is expected to be resolved in GROMACS 2022.

In GROMACS 2021, we disable the invalid configuration to prevent users
from getting invalid results.

This is a backport of !1241 and !1255.

Refs #3920

src/gromacs/mdlib/mdatoms.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdtypes/inputrec.cpp
src/gromacs/mdtypes/inputrec.h
src/gromacs/modularsimulator/modularsimulator.cpp
src/gromacs/taskassignment/decidegpuusage.cpp
src/gromacs/taskassignment/decidegpuusage.h

index 0d1abd8565da3830a1ad7b112cc5b99bcffb4ccd..fb538837b19beba733cbfb1eebe84136115c2071 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team.
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, 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.
@@ -291,8 +291,7 @@ void atoms2md(const gmx_mtop_t*  mtop,
         {
             srenew(md->cACC, md->nalloc);
         }
-        if (opts->nFreeze
-            && (opts->ngfrz > 1 || opts->nFreeze[0][XX] || opts->nFreeze[0][YY] || opts->nFreeze[0][ZZ]))
+        if (inputrecFrozenAtoms(ir))
         {
             srenew(md->cFREEZE, md->nalloc);
         }
index f5ebb604bbea6d155c4d89377f14734862a5edb4..2a5a7c2fe88cb93e61e4f4e8ffeb9233ea92f3c3 100644 (file)
@@ -1240,12 +1240,13 @@ int Mdrunner::mdrunner()
     try
     {
         const bool useUpdateGroups = cr->dd ? ddUsesUpdateGroups(*cr->dd) : false;
+        const bool haveFrozenAtoms = inputrecFrozenAtoms(inputrec.get());
 
         useGpuForUpdate = decideWhetherToUseGpuForUpdate(
                 useDomainDecomposition, useUpdateGroups, pmeRunMode, domdecOptions.numPmeRanks > 0,
                 useGpuForNonbonded, updateTarget, gpusWereDetected, *inputrec, mtop,
                 doEssentialDynamics, gmx_mtop_ftype_count(mtop, F_ORIRES) > 0,
-                replExParams.exchangeInterval > 0, doRerun, devFlags, mdlog);
+                replExParams.exchangeInterval > 0, haveFrozenAtoms, doRerun, devFlags, mdlog);
     }
     GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
 
index b872095f52f5cf686882b47782bd3d3d42545c93..05a09523fbaa3909a97b16532397a7f8e4e0e899 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2010, The GROMACS development team.
  * Copyright (c) 2012,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -1506,6 +1506,13 @@ bool inputrecPbcXY2Walls(const t_inputrec* ir)
     return (ir->pbcType == PbcType::XY && ir->nwall == 2);
 }
 
+bool inputrecFrozenAtoms(const t_inputrec* ir)
+{
+    return ((ir->opts.nFreeze != nullptr)
+            && (ir->opts.ngfrz > 1 || ir->opts.nFreeze[0][XX] != 0 || ir->opts.nFreeze[0][YY] != 0
+                || ir->opts.nFreeze[0][ZZ] != 0));
+}
+
 bool integratorHasConservedEnergyQuantity(const t_inputrec* ir)
 {
     if (!EI_MD(ir->eI))
index 46cb924592cacf8d4fc62a9f2773747cb065ce35..6e4ee727ab460c59fb8e6c377a56670c930fe41e 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -644,6 +644,9 @@ gmx_bool inputrecNphTrotter(const t_inputrec* ir);
 /*! \brief Return true if the simulation is 2D periodic with two walls. */
 bool inputrecPbcXY2Walls(const t_inputrec* ir);
 
+//! \brief Return true if the simulation has frozen atoms (non-trivial freeze groups).
+bool inputrecFrozenAtoms(const t_inputrec* ir);
+
 /*! \brief Returns true for MD integator with T and/or P-coupling that supports
  * calculating a conserved energy quantity.
  *
index 2450711c10f94220fa489b298d64329984bd982a..102fe2a2ffbcb9b2c793aa8f60b45bd6f7cb614e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, 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.
@@ -257,9 +257,7 @@ bool ModularSimulator::isInputCompatible(bool                             exitOn
                                  "Acceleration is not supported by the modular simulator.");
     isInputCompatible =
             isInputCompatible
-            && conditionalAssert(inputrec->opts.ngfrz == 1 && inputrec->opts.nFreeze[0][XX] == 0
-                                         && inputrec->opts.nFreeze[0][YY] == 0
-                                         && inputrec->opts.nFreeze[0][ZZ] == 0,
+            && conditionalAssert(!inputrecFrozenAtoms(inputrec),
                                  "Freeze groups are not supported by the modular simulator.");
     isInputCompatible =
             isInputCompatible
index 7d96638fde3fe7c3ad8444fac2575a9d7a53b1c4..53ff94c3463707bd3cbe19173dde1d3155267a56 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2015,2016,2017,2018,2019 by the GROMACS development team.
- * Copyright (c) 2020, by the GROMACS development team, led by
+ * Copyright (c) 2020,2021, 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.
@@ -544,6 +544,7 @@ bool decideWhetherToUseGpuForUpdate(const bool                     isDomainDecom
                                     const bool                     useEssentialDynamics,
                                     const bool                     doOrientationRestraints,
                                     const bool                     useReplicaExchange,
+                                    const bool                     haveFrozenAtoms,
                                     const bool                     doRerun,
                                     const DevelopmentFeatureFlags& devFlags,
                                     const gmx::MDLogger&           mdlog)
@@ -684,6 +685,11 @@ bool decideWhetherToUseGpuForUpdate(const bool                     isDomainDecom
                 "The number of coupled constraints is higher than supported in the GPU LINCS "
                 "code.\n";
     }
+    if (haveFrozenAtoms)
+    {
+        // There is a known bug with frozen atoms and GPU update, see Issue #3920.
+        errorMessage += "Frozen atoms not supported.\n";
+    }
 
     if (!errorMessage.empty())
     {
index b5fd83907fae8e834cfb18bd137a20ef8ea5b210..765636c448dec7cb1f69c683270c0bfc1b3322f6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, 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.
@@ -278,6 +278,7 @@ bool decideWhetherToUseGpusForBonded(bool              useGpuForNonbonded,
  * \param[in]  useEssentialDynamics         If essential dynamics is active.
  * \param[in]  doOrientationRestraints      If orientation restraints are enabled.
  * \param[in]  useReplicaExchange           If this is a REMD simulation.
+ * \param[in]  haveFrozenAtoms              If this simulation has frozen atoms (see Issue #3920).
  * \param[in]  doRerun                      It this is a rerun.
  * \param[in]  devFlags                     GPU development / experimental feature flags.
  * \param[in]  mdlog                        MD logger.
@@ -298,6 +299,7 @@ bool decideWhetherToUseGpuForUpdate(bool                           isDomainDecom
                                     bool                           useEssentialDynamics,
                                     bool                           doOrientationRestraints,
                                     bool                           useReplicaExchange,
+                                    bool                           haveFrozenAtoms,
                                     bool                           doRerun,
                                     const DevelopmentFeatureFlags& devFlags,
                                     const gmx::MDLogger&           mdlog);