Disable GPU update/constraints when neither PME nor buffer ops are offloaded.
authorArtem Zhmurov <zhmurov@gmail.com>
Mon, 16 Sep 2019 14:23:48 +0000 (16:23 +0200)
committerArtem Zhmurov <zhmurov@gmail.com>
Sun, 22 Sep 2019 09:15:26 +0000 (11:15 +0200)
Using the GPU-version of update makes sense if forces are already on the GPU,
i.e. if at least:
1. PME is on the GPU (there should be a copy of coordinates on a GPU in rvec
   format for PME spread).
2. Non-bonded interactions and buffer ops are on the GPU.

This is temporary solution, needed because the buffer ops offload switch is
operated by the environment variable. More favorable behavior would be to
switch on the GPU buffer ops in the second case rather then disabling the
GPU update.

Refs. #2816.

Change-Id: I37a9969dd6c74dcfa41a95da13ae54d014c9ea60

src/gromacs/mdrun/runner.cpp
src/gromacs/taskassignment/decidegpuusage.cpp
src/gromacs/taskassignment/decidegpuusage.h

index 3347dd39dd378adca208f6a1d4696196cbf55193..a1928eaa1b4de64a3e6c89801a4c58659b70d166 100644 (file)
@@ -1485,7 +1485,9 @@ int Mdrunner::mdrunner()
 
         // Before we start the actual simulator, try if we can run the update task on the GPU.
         useGpuForUpdate = decideWhetherToUseGpuForUpdate(DOMAINDECOMP(cr),
+                                                         useGpuForPme,
                                                          useGpuForNonbonded,
+                                                         c_enableGpuBufOps,
                                                          updateTarget,
                                                          gpusWereDetected,
                                                          *inputrec,
index b9f0d7aff848a974cec2851da4700f1269c5d17c..148765993527815ea50a04859ba09872a9fa3719 100644 (file)
@@ -492,7 +492,9 @@ bool decideWhetherToUseGpusForBonded(const bool       useGpuForNonbonded,
 }
 
 bool decideWhetherToUseGpuForUpdate(bool              isDomainDecomposition,
+                                    bool              useGpuForPme,
                                     bool              useGpuForNonbonded,
+                                    bool              useGpuForBufferOps,
                                     TaskTarget        updateTarget,
                                     bool              gpusWereDetected,
                                     const t_inputrec &inputrec,
@@ -512,9 +514,12 @@ bool decideWhetherToUseGpuForUpdate(bool              isDomainDecomposition,
     {
         errorMessage += "Domain decomposition is not supported.\n";
     }
-    if (!useGpuForNonbonded)
+    // Using the GPU-version of update makes sense if forces are already on the GPU, i.e. if at least:
+    // 1. PME is on the GPU (there should be a copy of coordinates on a GPU in rvec format for PME spread).
+    // 2. Non-bonded interactions and buffer ops are on the GPU.
+    if (!(useGpuForPme || (useGpuForNonbonded && useGpuForBufferOps)))
     {
-        errorMessage += "Short-ranged non-bonded interaction tasks must run on the GPU.\n";
+        errorMessage += "Either PME or short-ranged non-bonded interaction tasks must run on the GPU.\n";
     }
     if (!gpusWereDetected)
     {
index 707b1e49b3c1de7634da72a2d74202ced7a62b64..48ecf2e88f33102bd286809b9259a048589f8711 100644 (file)
@@ -232,7 +232,9 @@ bool decideWhetherToUseGpusForBonded(bool       useGpuForNonbonded,
 /*! \brief Decide whether to use GPU for update.
  *
  * \param[in]  isDomainDecomposition     Whether there more than one domain.
+ * \param[in]  useGpuForPme              Whether GPUs will be used for PME interactions.
  * \param[in]  useGpuForNonbonded        Whether GPUs will be used for nonbonded interactions.
+ * \param[in]  useGpuForBufferOps        Whether GPUs will be used for buffer operations.
  * \param[in]  updateTarget              User choice for running simulation on GPU.
  * \param[in]  gpusWereDetected          Whether compatible GPUs were detected on any node.
  * \param[in]  inputrec                  The user input.
@@ -246,7 +248,9 @@ bool decideWhetherToUseGpusForBonded(bool       useGpuForNonbonded,
  *             InconsistentInputError    If the user requirements are inconsistent.
  */
 bool decideWhetherToUseGpuForUpdate(bool              isDomainDecomposition,
+                                    bool              useGpuForPme,
                                     bool              useGpuForNonbonded,
+                                    bool              useGpuForBufferOps,
                                     TaskTarget        updateTarget,
                                     bool              gpusWereDetected,
                                     const t_inputrec &inputrec,