Fix segmentation fault in DD code
authorBerk Hess <hess@kth.se>
Thu, 3 Jan 2019 13:18:33 +0000 (14:18 +0100)
committerBerk Hess <hess@kth.se>
Thu, 3 Jan 2019 13:18:33 +0000 (14:18 +0100)
mdrun could exit with a segmentation fault in DD when DLB was disabled.

Fixes #2813

Change-Id: Ie20ca1995c93fa74f41d8db5becfce1cb20348a3

docs/release-notes/2019/2019.1.rst
src/gromacs/domdec/partition.cpp

index 8be5e1a870f2c9cdb135c39f49161f866c9dec49..581e2f6b64eedadcc5597a7901ba5e33f1a564ca 100644 (file)
@@ -10,6 +10,11 @@ in the :ref:`release-notes`.
 Fixes where mdrun could behave incorrectly
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+Fix segmentation fault in mdrun with domain decomposition
+---------------------------------------------------------
+
+:issue: `2813`
+
 Fixes for ``gmx`` tools
 ^^^^^^^^^^^^^^^^^^^^^^^
 
index 252477f65136b4ec001e725fdd153d2560276723..96ae045367318a1af2f980e00e360e876f49852f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, 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.
@@ -879,7 +879,7 @@ static void get_load_distribution(gmx_domdec_t *dd, gmx_wallcycle_t wcycle)
 
     for (int d = dd->ndim - 1; d >= 0; d--)
     {
-        const DDCellsizesWithDlb &cellsizes = comm->cellsizesWithDlb[d];
+        const DDCellsizesWithDlb *cellsizes = (isDlbOn(dd->comm) ? &comm->cellsizesWithDlb[d] : nullptr);
         const int                 dim       = dd->dim[d];
         /* Check if we participate in the communication in this dimension */
         if (d == dd->ndim-1 ||
@@ -888,7 +888,7 @@ static void get_load_distribution(gmx_domdec_t *dd, gmx_wallcycle_t wcycle)
             load = &comm->load[d];
             if (isDlbOn(dd->comm))
             {
-                cell_frac = cellsizes.fracUpper - cellsizes.fracLower;
+                cell_frac = cellsizes->fracUpper - cellsizes->fracLower;
             }
             int pos = 0;
             if (d == dd->ndim-1)
@@ -901,8 +901,8 @@ static void get_load_distribution(gmx_domdec_t *dd, gmx_wallcycle_t wcycle)
                     sbuf[pos++] = cell_frac;
                     if (d > 0)
                     {
-                        sbuf[pos++] = cellsizes.fracLowerMax;
-                        sbuf[pos++] = cellsizes.fracUpperMin;
+                        sbuf[pos++] = cellsizes->fracLowerMax;
+                        sbuf[pos++] = cellsizes->fracUpperMin;
                     }
                 }
                 if (bSepPME)
@@ -922,8 +922,8 @@ static void get_load_distribution(gmx_domdec_t *dd, gmx_wallcycle_t wcycle)
                     sbuf[pos++] = comm->load[d+1].flags;
                     if (d > 0)
                     {
-                        sbuf[pos++] = cellsizes.fracLowerMax;
-                        sbuf[pos++] = cellsizes.fracUpperMin;
+                        sbuf[pos++] = cellsizes->fracLowerMax;
+                        sbuf[pos++] = cellsizes->fracUpperMin;
                     }
                 }
                 if (bSepPME)
@@ -948,7 +948,7 @@ static void get_load_distribution(gmx_domdec_t *dd, gmx_wallcycle_t wcycle)
 
                 if (isDlbOn(comm))
                 {
-                    rowMaster = cellsizes.rowMaster.get();
+                    rowMaster = cellsizes->rowMaster.get();
                 }
                 load->sum      = 0;
                 load->max      = 0;