Allow using GPU update with DD and update groups
[alexxy/gromacs.git] / src / gromacs / taskassignment / decidegpuusage.cpp
index b7eff1d3bfc408d3c27e0043857bbc8d362cdc54..fc1f4faf605b6916d07d80ae417b7800db5a418f 100644 (file)
@@ -489,7 +489,9 @@ bool decideWhetherToUseGpusForBonded(const bool       useGpuForNonbonded,
     return gpusWereDetected && usingOurCpuForPmeOrEwald;
 }
 
-bool decideWhetherToUseGpuForUpdate(const bool        isDomainDecomposition,
+bool decideWhetherToUseGpuForUpdate(const bool        forceGpuUpdateDefaultWithDD,
+                                    const bool        isDomainDecomposition,
+                                    const bool        useUpdateGroups,
                                     const bool        useGpuForPme,
                                     const bool        useGpuForNonbonded,
                                     const TaskTarget  updateTarget,
@@ -507,11 +509,20 @@ bool decideWhetherToUseGpuForUpdate(const bool        isDomainDecomposition,
         return false;
     }
 
+    const bool hasAnyConstraints = gmx_mtop_interaction_count(mtop, IF_CONSTRAINT) > 0;
+
     std::string errorMessage;
 
-    if (isDomainDecomposition)
+    if (isDomainDecomposition && hasAnyConstraints && !useUpdateGroups)
+    {
+        errorMessage +=
+                "Domain decomposition is only supported with constraints when update groups are "
+                "used. This means constraining all bonds is not supported, except for small "
+                "molecules, and box sizes close to half the pair-list cutoff are not supported.\n ";
+    }
+    if (inputrec.eConstrAlg == econtSHAKE && hasAnyConstraints && gmx_mtop_ftype_count(mtop, F_CONSTR) > 0)
     {
-        errorMessage += "Domain decomposition is not supported.\n";
+        errorMessage += "SHAKE constraints are not supported.\n";
     }
     // Using the GPU-version of update if:
     // 1. PME is on the GPU (there should be a copy of coordinates on GPU for PME spread), or
@@ -606,6 +617,11 @@ bool decideWhetherToUseGpuForUpdate(const bool        isDomainDecomposition,
         return false;
     }
 
+    if (isDomainDecomposition)
+    {
+        return forceGpuUpdateDefaultWithDD;
+    }
+
     return true;
 }