Fix bug with vsites, DD, OpenMP and large systems
authorBerk Hess <hess@kth.se>
Tue, 28 Sep 2021 06:24:06 +0000 (06:24 +0000)
committerMagnus Lundborg <magnus.lundborg@scilifelab.se>
Tue, 28 Sep 2021 06:24:06 +0000 (06:24 +0000)
docs/release-notes/2021/2021.4.rst
src/gromacs/mdlib/vsite.cpp

index 8d44aea03978d6686de7ffc76e984696da8d22f3..cdf6d4569aa4967fc3eeebcf0d698b5333535ef4 100644 (file)
@@ -16,6 +16,15 @@ in the :ref:`release-notes`.
 Fixes where mdrun could behave incorrectly
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+Fixed crash for large system with virtual sites
+"""""""""""""""""""""""""""""""""""""""""""""""
+
+When large system with virtual sites were ran with domain decomposition
+and OpenMP threading, mdrun would crash when the number of atoms in
+a domain and its halo were more than 200000.
+
+:issue:`4167`
+
 Fixes for ``gmx`` tools
 ^^^^^^^^^^^^^^^^^^^^^^^
 
index 35628004ecea0774db522eebf30461901a804bc6..f96b7eafe4849cde05797ee65f020ff627f8d1f9 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 The GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,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.
@@ -2335,7 +2335,16 @@ static void assignVsitesToThread(VsiteThread*                    tData,
                                    "a constructing atom that does not belong to our task, such "
                                    "vsites should be assigned to the single 'master' task");
 
-                        task = nthread + thread;
+                        if (tData->useInterdependentTask)
+                        {
+                            // Assign to the interdependent task
+                            task = nthread + thread;
+                        }
+                        else
+                        {
+                            // Assign to the separate, non-parallel task
+                            task = 2 * nthread;
+                        }
                     }
                 }
             }
@@ -2570,12 +2579,13 @@ void ThreadingInfo::setVirtualSites(ArrayRef<const InteractionList> ilists,
             }
 
             /* To avoid large f_buf allocations of #threads*vsite_atom_range
-             * we don't use task2 with more than 200000 atoms. This doesn't
-             * affect performance, since with such a large range relatively few
-             * vsites will end up in the separate task.
-             * Note that useTask2 should be the same for all threads.
+             * we don't use the interdependent tasks with more than 200000 atoms.
+             * This doesn't affect performance, since with such a large range
+             * relatively few vsites will end up in the separate task.
+             * Note that useInterdependentTask should be the same for all threads.
              */
-            tData.useInterdependentTask = (vsite_atom_range <= 200000);
+            const int c_maxNumLocalAtomsForInterdependentTask = 200000;
+            tData.useInterdependentTask = (vsite_atom_range <= c_maxNumLocalAtomsForInterdependentTask);
             if (tData.useInterdependentTask)
             {
                 size_t              natoms_use_in_vsites = vsite_atom_range;