Enable GPU update for supported cases of FEP
authorArtem Zhmurov <zhmurov@gmail.com>
Thu, 19 Dec 2019 15:50:05 +0000 (16:50 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Mon, 3 Feb 2020 15:11:00 +0000 (16:11 +0100)
Only mass and constraints perturbation is not supported by the
GPU constraints, hence FEP can be enabled for the rest of the cases.

Change-Id: I0ec487823ec4aeda5b09ba66a504c5358e778c8e

docs/release-notes/2021/major/performance.rst
docs/user-guide/mdrun-performance.rst
src/gromacs/mdrun/md.cpp
src/gromacs/mdtypes/inputrec.cpp
src/gromacs/mdtypes/inputrec.h
src/gromacs/taskassignment/decidegpuusage.cpp

index 0a72678f80f26386be4e62f7c4d387c87b4fddf5..f1053389eca953c97c3efdc63fad598d6ac91d69 100644 (file)
@@ -7,3 +7,8 @@ Performance improvements
    Also, please use the syntax :issue:`number` to reference issues on redmine, without the
    a space between the colon and number!
 
+Extend supported use-cases for GPU version of update and constraints
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+GPU version of update and constraints can now be used for FEP, except mass and constraints
+free-energy perturbation.
index 8c8e5474c9acd6ad5967f4a9cd5004ec26edbd41..ee1e4d0cbe7543df565db32a96615d838e735b8c 100644 (file)
@@ -531,9 +531,10 @@ behavior.
     Setting "gpu" requires that a compatible CUDA GPU is available,
     the simulation uses a single rank.
     Update and constraints on a GPU is currently not supported
-    with domain decomposition, free-energy, virtual sites,
-    Ewald surface correction, replica exchange, constraint pulling,
-    orientation restraints and computational electrophysiology.
+    with mass and constraints free-energy perturbation, domain
+    decomposition, virtual sites, Ewald surface correction,
+    replica exchange, constraint pulling, orientation restraints
+    and computational electrophysiology.
 
 ``-gpu_id``
     A string that specifies the ID numbers of the GPUs that
index 91d932e3d8fd286f28cb7529523cc371f19e1cbc..7e2e98f648e397366d07b740ae6eaec5ba537438 100644 (file)
@@ -353,8 +353,11 @@ void gmx::LegacySimulator::do_md()
                            "Constraints pulling is not supported with the GPU update.\n");
         GMX_RELEASE_ASSERT(fcd->orires.nr == 0,
                            "Orientation restraints are not supported with the GPU update.\n");
-        GMX_RELEASE_ASSERT(ir->efep == efepNO,
-                           "Free energy perturbations are not supported with the GPU update.");
+        GMX_RELEASE_ASSERT(
+                ir->efep == efepNO
+                        || (!haveFreeEnergyType(*ir, efptBONDED) && !haveFreeEnergyType(*ir, efptMASS)),
+                "Free energy perturbation of masses and constraints are not supported with the GPU "
+                "update.");
         GMX_RELEASE_ASSERT(graph == nullptr, "The graph is not supported with GPU update.");
 
         if (constr != nullptr && constr->numConstraintsTotal() > 0)
index 6f6e386f963f850c023d11b15babe848892b05b7..a57b89d6da8c3a5ddd18095e12e9affa8ff09987 100644 (file)
@@ -1575,3 +1575,15 @@ bool haveEwaldSurfaceContribution(const t_inputrec& ir)
 {
     return EEL_PME_EWALD(ir.coulombtype) && (ir.ewald_geometry == eewg3DC || ir.epsilon_surface != 0);
 }
+
+bool haveFreeEnergyType(const t_inputrec& ir, const int fepType)
+{
+    for (int i = 0; i < ir.fepvals->n_lambda; i++)
+    {
+        if (ir.fepvals->all_lambda[fepType][i] > 0)
+        {
+            return true;
+        }
+    }
+    return false;
+}
index 4659516b558fb08d469f7bb7768ecb13405ec12a..b7a903accf0b528f2d96824e383c9d58bdb10b1f 100644 (file)
@@ -700,4 +700,13 @@ real maxReferenceTemperature(const t_inputrec& ir);
  */
 bool haveEwaldSurfaceContribution(const t_inputrec& ir);
 
+/*! \brief Check if calculation of the specific FEP type was requested.
+ *
+ * \param[in] ir       Input record.
+ * \param[in] fepType  Free-energy perturbation type to check for.
+ *
+ * \returns If the \p fepType is perturbed in this run.
+ */
+bool haveFreeEnergyType(const t_inputrec& ir, int fepType);
+
 #endif /* GMX_MDTYPES_INPUTREC_H */
index d8fa6a93e9f71c6510c18af4eb3971d2cd67365a..b6659b2e7b4adc8a048a8203a3dd885b68a89da7 100644 (file)
@@ -630,10 +630,10 @@ bool decideWhetherToUseGpuForUpdate(const bool           forceGpuUpdateDefault,
         // The graph is needed, but not supported
         errorMessage += "Orientation restraints are not supported.\n";
     }
-    if (inputrec.efep != efepNO)
+    if (inputrec.efep != efepNO
+        && (haveFreeEnergyType(inputrec, efptBONDED) || haveFreeEnergyType(inputrec, efptMASS)))
     {
-        // Actually all free-energy options except for mass and constraint perturbation are supported
-        errorMessage += "Free energy perturbations are not supported.\n";
+        errorMessage += "Free energy perturbation for mass and constraints are not supported.\n";
     }
     const auto particleTypes = gmx_mtop_particletype_count(mtop);
     if (particleTypes[eptShell] > 0)