Ensure coordinates are copied for dipole moment calculation
authorAndrey Alekseenko <al42and@gmail.com>
Thu, 15 Apr 2021 06:17:53 +0000 (06:17 +0000)
committerPaul Bauer <paul.bauer.q@gmail.com>
Thu, 15 Apr 2021 06:17:53 +0000 (06:17 +0000)
docs/release-notes/2021/2021.2.rst
src/gromacs/mdlib/sim_util.cpp

index 2dc166fe551730539e68f3a6c90c77661aaff032..c60ee464afded864370798b65a7a9f0ff5b073d9 100644 (file)
@@ -16,6 +16,14 @@ in the :ref:`release-notes`.
 Fixes where mdrun could behave incorrectly
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+Removed a potential race condition with GPU update
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Fixed possible (but so far unobserved) race condition in coordinate copy when
+using GPU update with dipole moment calculation.
+
+:issue:`4024`
+
 Fixes for ``gmx`` tools
 ^^^^^^^^^^^^^^^^^^^^^^^
 
index 9ef783b67a189d8096b22af45f2761754abee40a..a235dbc1d5207b02934db78f20387cce761b3d48 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013-2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2013-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.
@@ -1231,7 +1231,7 @@ void do_force(FILE*                               fplog,
     bool gmx_used_in_debug haveCopiedXFromGpu = false;
     if (simulationWork.useGpuUpdate && !stepWork.doNeighborSearch
         && (runScheduleWork->domainWork.haveCpuLocalForceWork || stepWork.computeVirial
-            || haveHostPmePpComms || haveHostHaloExchangeComms))
+            || haveHostPmePpComms || haveHostHaloExchangeComms || simulationWork.computeMuTot))
     {
         stateGpu->copyCoordinatesFromGpu(x.unpaddedArrayRef(), AtomLocality::Local);
         haveCopiedXFromGpu = true;
@@ -1573,6 +1573,13 @@ void do_force(FILE*                               fplog,
     {
         const int start = 0;
 
+        if (simulationWork.useGpuUpdate && !stepWork.doNeighborSearch)
+        {
+            GMX_ASSERT(haveCopiedXFromGpu,
+                       "a wait should only be triggered if copy has been scheduled");
+            stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local);
+        }
+
         /* Calculate total (local) dipole moment in a temporary common array.
          * This makes it possible to sum them over nodes faster.
          */