From: Berk Hess Date: Fri, 3 Jul 2015 20:28:52 +0000 (+0200) Subject: Fix bug in GPU list balancing X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?p=alexxy%2Fgromacs.git;a=commitdiff_plain;h=466e36339dfce3cbb7a36d43741779a39f5bd5c6 Fix bug in GPU list balancing The function split_sci_entry could produce empty lists, which can cause illegal memory access or incorrect energies. Before commit 6106367b this bug was never triggered, since nsp_max was never smaller than a full cj4 entry. But 6106367b introduced a but that could produce negative nsp_max. Fixes #1767. Change-Id: I2007cf6851f94f4f2ca62f609a0628725014dbe7 --- diff --git a/src/gromacs/mdlib/nbnxn_search.c b/src/gromacs/mdlib/nbnxn_search.c index a372082356..d10ddf70b3 100644 --- a/src/gromacs/mdlib/nbnxn_search.c +++ b/src/gromacs/mdlib/nbnxn_search.c @@ -4014,7 +4014,8 @@ static void split_sci_entry(nbnxn_pairlist_t *nbl, nsp_cj4 += (nbl->cj4[cj4].imei[0].imask >> p) & 1; } - if (nsp_cj4 > 0 && nsp + nsp_cj4 > nsp_max) + /* Check if we should split at this cj4 to get a list of size nsp */ + if (nsp > 0 && nsp + nsp_cj4 > nsp_max) { /* Split the list at cj4 */ nbl->sci[sci].cj4_ind_end = cj4;