cj_ind_start = nbl_ci->cj_ind_start;
cj_ind_end = nbl_ci->cj_ind_end;
- /* In worst case we have alternating energy groups and create npair lists */
- nri_max = nbl->na_ci*(cj_ind_end - cj_ind_start);
+ /* In worst case we have alternating energy groups
+ * and create #atom-pair lists, which means we need the size
+ * of a cluster pair (na_ci*na_cj) times the number of cj's.
+ */
+ nri_max = nbl->na_ci*nbl->na_cj*(cj_ind_end - cj_ind_start);
if (nlist->nri + nri_max > nlist->maxnri)
{
nlist->maxnri = over_alloc_large(nlist->nri + nri_max);
if (nlist->nrj > nlist->jindex[nri])
{
+ /* Actually add this new, non-empty, list */
nlist->nri++;
nlist->jindex[nlist->nri] = nlist->nrj;
}
cj4_ind_start = nbl_sci->cj4_ind_start;
cj4_ind_end = nbl_sci->cj4_ind_end;
- /* No energy groups (yet), so we split lists in max_nrj_fep pairs */
- nri_max = nbl->na_sc*(1 + ((cj4_ind_end - cj4_ind_start)*NBNXN_GPU_JGROUP_SIZE)/max_nrj_fep);
+ /* Here we process one super-cell, max #atoms na_sc, versus a list
+ * cj4 entries, each with max NBNXN_GPU_JGROUP_SIZE cj's, each
+ * of size na_cj atoms.
+ * On the GPU we don't support energy groups (yet).
+ * So for each of the na_sc i-atoms, we need max one FEP list
+ * for each max_nrj_fep j-atoms.
+ */
+ nri_max = nbl->na_sc*nbl->na_cj*(1 + ((cj4_ind_end - cj4_ind_start)*NBNXN_GPU_JGROUP_SIZE)/max_nrj_fep);
if (nlist->nri + nri_max > nlist->maxnri)
{
nlist->maxnri = over_alloc_large(nlist->nri + nri_max);
if (nlist->nrj > nlist->jindex[nri])
{
+ /* Actually add this new, non-empty, list */
nlist->nri++;
nlist->jindex[nlist->nri] = nlist->nrj;
}