From c8ce978a50c9cc4bcfd8f12272f393c77999af3f Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Tue, 9 Sep 2014 14:35:52 +0200 Subject: [PATCH] Fixed DD state collection issue Collecting the cg distribution state to the master (for output of replica exchange) could go wrong when the DD was out of sync. This code path was probably never executed. Change-Id: I14b41c15ddc827a46f7c6448fb7bd90414f8e210 --- src/gromacs/mdlib/domdec.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gromacs/mdlib/domdec.c b/src/gromacs/mdlib/domdec.c index 401b6effdb..2d2ffb0fd5 100644 --- a/src/gromacs/mdlib/domdec.c +++ b/src/gromacs/mdlib/domdec.c @@ -1320,7 +1320,6 @@ static void dd_collect_cg(gmx_domdec_t *dd, { gmx_domdec_master_t *ma = NULL; int buf2[2], *ibuf, i, ncg_home = 0, *cg = NULL, nat_home = 0; - t_block *cgs_gl; if (state_local->ddp_count == dd->comm->master_cg_ddp_count) { @@ -1330,12 +1329,18 @@ static void dd_collect_cg(gmx_domdec_t *dd, if (state_local->ddp_count == dd->ddp_count) { + /* The local state and DD are in sync, use the DD indices */ ncg_home = dd->ncg_home; cg = dd->index_gl; nat_home = dd->nat_home; } else if (state_local->ddp_count_cg_gl == state_local->ddp_count) { + /* The DD is out of sync with the local state, but we have stored + * the cg indices with the local state, so we can use those. + */ + t_block *cgs_gl; + cgs_gl = &dd->comm->cgs_gl; ncg_home = state_local->ncg_gl; @@ -1351,8 +1356,8 @@ static void dd_collect_cg(gmx_domdec_t *dd, gmx_incons("Attempted to collect a vector for a state for which the charge group distribution is unknown"); } - buf2[0] = dd->ncg_home; - buf2[1] = dd->nat_home; + buf2[0] = ncg_home; + buf2[1] = nat_home; if (DDMASTER(dd)) { ma = dd->ma; @@ -1394,7 +1399,7 @@ static void dd_collect_cg(gmx_domdec_t *dd, /* Collect the charge group indices on the master */ dd_gatherv(dd, - dd->ncg_home*sizeof(int), dd->index_gl, + ncg_home*sizeof(int), cg, DDMASTER(dd) ? ma->ibuf : NULL, DDMASTER(dd) ? ma->ibuf+dd->nnodes : NULL, DDMASTER(dd) ? ma->cg : NULL); -- 2.22.0