Change the behavior of the GPU update UI
[alexxy/gromacs.git] / src / gromacs / taskassignment / decidegpuusage.cpp
index adda067bfadb5aa61aafaf44df584209f96c5674..9b069fd890a44c139a700fe8bc9a00001855848a 100644 (file)
@@ -489,7 +489,7 @@ bool decideWhetherToUseGpusForBonded(const bool       useGpuForNonbonded,
     return gpusWereDetected && usingOurCpuForPmeOrEwald;
 }
 
-bool decideWhetherToUseGpuForUpdate(const bool        forceGpuUpdateDefaultWithDD,
+bool decideWhetherToUseGpuForUpdate(const bool        forceGpuUpdateDefault,
                                     const bool        isDomainDecomposition,
                                     const bool        useUpdateGroups,
                                     const bool        useGpuForPme,
@@ -504,7 +504,8 @@ bool decideWhetherToUseGpuForUpdate(const bool        forceGpuUpdateDefaultWithD
                                     const bool        doRerun)
 {
 
-    if (updateTarget == TaskTarget::Cpu)
+    // '-update cpu' overrides the environment variable, '-update auto' does not
+    if (updateTarget == TaskTarget::Cpu || (updateTarget == TaskTarget::Auto && !forceGpuUpdateDefault))
     {
         return false;
     }
@@ -515,7 +516,7 @@ bool decideWhetherToUseGpuForUpdate(const bool        forceGpuUpdateDefaultWithD
 
     if (isDomainDecomposition)
     {
-        if (!forceGpuUpdateDefaultWithDD)
+        if (!forceGpuUpdateDefault)
         {
             errorMessage += "Domain decomposition is not supported.\n ";
         }
@@ -627,10 +628,12 @@ bool decideWhetherToUseGpuForUpdate(const bool        forceGpuUpdateDefaultWithD
 
     if (isDomainDecomposition)
     {
-        return forceGpuUpdateDefaultWithDD;
+        return forceGpuUpdateDefault;
+    }
+    else
+    {
+        return (updateTarget == TaskTarget::Gpu || forceGpuUpdateDefault);
     }
-
-    return true;
 }
 
 } // namespace gmx