static void setupUpdateGroups(const gmx::MDLogger &mdlog,
const gmx_mtop_t &mtop,
const t_inputrec &inputrec,
+ real cutoffMargin,
int numMpiRanksTotal,
gmx_domdec_comm_t *comm)
{
/* To use update groups, the large domain-to-domain cutoff distance
* should be compatible with the box size.
*/
- /* TODO: add this cutoff check */
+ comm->useUpdateGroups = (atomToAtomIntoDomainToDomainCutoff(*comm, 0) < cutoffMargin);
+ /* TODO: Enable update groups when all infrastructure is present */
comm->useUpdateGroups = false;
if (comm->useUpdateGroups)
comm->useUpdateGroups = false;
if (ir->cutoff_scheme == ecutsVERLET)
{
- setupUpdateGroups(mdlog, *mtop, *ir, cr->nnodes, comm);
+ real cutoffMargin = std::sqrt(max_cutoff2(ir->ePBC, box)) - ir->rlist;
+ setupUpdateGroups(mdlog, *mtop, *ir, cutoffMargin, cr->nnodes, comm);
}
comm->bInterCGBondeds = ((ncg_mtop(mtop) > gmx_mtop_num_molecules(*mtop)) ||
comm->bInterCGMultiBody = FALSE;
}
- dd->splitConstraints = gmx::inter_charge_group_constraints(*mtop);
- dd->splitSettles = gmx::inter_charge_group_settles(*mtop);
+ if (comm->useUpdateGroups)
+ {
+ dd->splitConstraints = false;
+ dd->splitSettles = false;
+ }
+ else
+ {
+ dd->splitConstraints = gmx::inter_charge_group_constraints(*mtop);
+ dd->splitSettles = gmx::inter_charge_group_settles(*mtop);
+ }
if (ir->rlist == 0)
{
}
else
{
- comm->cutoff = ir->rlist;
+ comm->cutoff = atomToAtomIntoDomainToDomainCutoff(*comm, ir->rlist);
}
comm->cutoff_mbody = 0;
{
if (options.minimumCommunicationRange > 0)
{
- comm->cutoff_mbody = options.minimumCommunicationRange;
+ comm->cutoff_mbody = atomToAtomIntoDomainToDomainCutoff(*comm, options.minimumCommunicationRange);
if (options.useBondedCommunication)
{
comm->bBondComm = (comm->cutoff_mbody > comm->cutoff);
j = ind_start;
while (j < ind_end)
{
- int ftype;
- int nral;
- t_iatom tiatoms[1 + MAXATOMLIST];
-
- ftype = rtil[j++];
- gmx::ArrayRef<const t_iatom> iatoms = gmx::constArrayRefFromArray(rtil.data() + j, rtil.size() - j);
- nral = NRAL(ftype);
- if (ftype == F_SETTLE)
- {
- /* Settles are only in the reverse top when they
- * operate within a charge group. So we can assign
- * them without checks. We do this only for performance
- * reasons; it could be handled by the code below.
- */
- if (iz == 0)
- {
- /* Home zone: add this settle to the local topology */
- tiatoms[0] = iatoms[0];
- tiatoms[1] = i;
- tiatoms[2] = i + iatoms[2] - iatoms[1];
- tiatoms[3] = i + iatoms[3] - iatoms[1];
- add_ifunc(nral, tiatoms, &idef->il[ftype]);
- (*nbonded_local)++;
- }
- j += 1 + nral;
- }
- else if (interaction_function[ftype].flags & IF_VSITE)
+ t_iatom tiatoms[1 + MAXATOMLIST];
+
+ const int ftype = rtil[j++];
+ auto iatoms = gmx::constArrayRefFromArray(rtil.data() + j, rtil.size() - j);
+ const int nral = NRAL(ftype);
+ if (interaction_function[ftype].flags & IF_VSITE)
{
assert(!bInterMolInteractions);
/* The vsite construction goes where the vsite itself is */
gmx_domdec_comm_dim_t *cd;
cginfo_mb_t *cginfo_mb;
gmx_bool bBondComm, bDist2B, bDistMB, bDistBonded;
- real r_comm2, r_bcomm2;
dd_corners_t corners;
rvec *cg_cm, *normal, *v_d, *v_0 = nullptr, *v_1 = nullptr;
real skew_fac2_d, skew_fac_01;
/* Do we need to determine extra distances for only two-body bondeds? */
bDist2B = (bBondComm && !bDistMB);
- r_comm2 = gmx::square(comm->cutoff);
- r_bcomm2 = gmx::square(comm->cutoff_mbody);
+ const real r_comm2 = gmx::square(domainToDomainIntoAtomToDomainCutoff(*comm, comm->cutoff));
+ const real r_bcomm2 = gmx::square(domainToDomainIntoAtomToDomainCutoff(*comm, comm->cutoff_mbody));
if (debug)
{
PaddedRVecVector *f,
int numChargeGroups);
+/*! \brief Returns a domain-to-domain cutoff distance given an atom-to-atom cutoff */
+static inline real
+atomToAtomIntoDomainToDomainCutoff(const gmx_domdec_comm_t &comm,
+ real cutoff)
+{
+ if (comm.useUpdateGroups)
+ {
+ GMX_ASSERT(comm.updateGroupsCog, "updateGroupsCog should be initialized here");
+
+ cutoff += 2*comm.updateGroupsCog->maxUpdateGroupRadius();
+ }
+
+ return cutoff;
+}
+
+/*! \brief Returns an atom-to-domain cutoff distance given a domain-to-domain cutoff */
+static inline real
+domainToDomainIntoAtomToDomainCutoff(const gmx_domdec_comm_t &comm,
+ real cutoff)
+{
+ if (comm.useUpdateGroups)
+ {
+ GMX_ASSERT(comm.updateGroupsCog, "updateGroupsCog should be initialized here");
+
+ cutoff -= comm.updateGroupsCog->maxUpdateGroupRadius();
+ }
+
+ return cutoff;
+}
+
#endif