const t_inputrec& inputrec,
DDBondedChecking ddBondedChecking);
+/*! \brief Return whether the total bonded interaction count across
+ * domains should be checked this step. */
+bool shouldCheckNumberOfBondedInteractions(const gmx_domdec_t& dd);
+
+//! Return the number of bonded interactions in this domain.
+int numBondedInteractions(const gmx_domdec_t& dd);
+
+/*! \brief Set total bonded interaction count across domains. */
+void setNumberOfBondedInteractionsOverAllDomains(const gmx_domdec_t& dd, int newValue);
+
+/*! \brief Check whether bonded interactions are missing from the reverse topology
+ * produced by domain decomposition.
+ *
+ * Must only be called when DD is active.
+ *
+ * \param[in] mdlog Logger
+ * \param[in] cr Communication object
+ * \param[in] top_global Global topology for the error message
+ * \param[in] top_local Local topology for the error message
+ * \param[in] x Position vector for the error message
+ * \param[in] box Box matrix for the error message
+ */
+void checkNumberOfBondedInteractions(const gmx::MDLogger& mdlog,
+ t_commrec* cr,
+ const gmx_mtop_t& top_global,
+ const gmx_localtop_t* top_local,
+ gmx::ArrayRef<const gmx::RVec> x,
+ const matrix box);
+
/*! \brief Generate the local topology and virtual site data */
void dd_make_local_top(struct gmx_domdec_t* dd,
struct gmx_domdec_zones_t* zones,
/* Global atom number to interaction list */
std::unique_ptr<gmx_reverse_top_t> reverse_top;
- int nbonded_global = 0;
- int nbonded_local = 0;
/* Whether we have non-self exclusion */
bool haveExclusions = false;
#include <algorithm>
#include <memory>
+#include <optional>
#include <string>
#include "gromacs/domdec/domdec.h"
InteractionDefinitions idef; /**< Partial local topology */
std::unique_ptr<gmx::VsitePbc> vsitePbc = nullptr; /**< vsite PBC structure */
- int nbonded = 0; /**< The number of bondeds in this struct */
- ListOfLists<int> excl; /**< List of exclusions */
- int excl_count = 0; /**< The total exclusion count for \p excl */
+ int numBondedInteractions = 0; /**< The number of bonded interactions observed */
+ ListOfLists<int> excl; /**< List of exclusions */
+ int excl_count = 0; /**< The total exclusion count for \p excl */
};
/*! \brief Options for setting up gmx_reverse_top_t */
//! \brief Intermolecular reverse ilist
reverse_ilist_t ril_intermol;
- //! The interaction count for the interactions that have to be present
- int numInteractionsToCheck;
+ /*! \brief Data to help check reverse topology construction
+ *
+ * Partitioning could incorrectly miss a bonded interaction.
+ * However, checking for that requires a global communication
+ * stage, which does not otherwise happen during partitioning. So,
+ * for performance, we do that alongside the first global energy
+ * reduction after a new DD is made. These variables handle
+ * whether the check happens, its input for this domain, output
+ * across all domains, and the expected value it should match. */
+ /*! \{ */
+ /*! \brief Number of bonded interactions found in the reverse
+ * topology for this domain. */
+ int numBondedInteractions = 0;
+ /*! \brief Whether to check at the next global communication
+ * stage the total number of bonded interactions found.
+ *
+ * Cleared after that number is found. */
+ bool shouldCheckNumberOfBondedInteractions = false;
+ /*! \brief The total number of bonded interactions found in
+ * the reverse topology across all domains.
+ *
+ * Only has a value after reduction across all ranks, which is
+ * removed when it is again time to check after a new
+ * partition. */
+ std::optional<int> numBondedInteractionsOverAllDomains;
+ //! The number of bonded interactions computed from the full topology
+ int expectedNumGlobalBondedInteractions = 0;
+ /*! \} */
/* Work data structures for multi-threading */
//! \brief Thread work array for local topology generation
}
}
-void dd_print_missing_interactions(const gmx::MDLogger& mdlog,
- t_commrec* cr,
- int local_count,
- const gmx_mtop_t& top_global,
- const gmx_localtop_t* top_local,
+void dd_print_missing_interactions(const gmx::MDLogger& mdlog,
+ t_commrec* cr,
+ int numBondedInteractionsOverAllDomains,
+ const gmx_mtop_t& top_global,
+ const gmx_localtop_t* top_local,
gmx::ArrayRef<const gmx::RVec> x,
const matrix box)
{
"Not all bonded interactions have been properly assigned to the domain "
"decomposition cells");
- const int ndiff_tot = local_count - dd->nbonded_global;
+ const int ndiff_tot = numBondedInteractionsOverAllDomains
+ - dd->reverse_top->impl_->expectedNumGlobalBondedInteractions;
for (int ftype = 0; ftype < F_NRE; ftype++)
{
if (DDMASTER(dd))
{
GMX_LOG(mdlog.warning).appendText("A list of missing interactions:");
- int rest_global = dd->nbonded_global;
- int rest_local = local_count;
+ int rest_global = dd->reverse_top->impl_->expectedNumGlobalBondedInteractions;
+ int rest = numBondedInteractionsOverAllDomains;
for (int ftype = 0; ftype < F_NRE; ftype++)
{
/* In the reverse and local top all constraints are merged
-ndiff);
}
rest_global -= n;
- rest_local -= cl[ftype];
+ rest -= cl[ftype];
}
}
- int ndiff = rest_local - rest_global;
+ int ndiff = rest - rest_global;
if (ndiff != 0)
{
GMX_LOG(mdlog.warning).appendTextFormatted("%20s of %6d missing %6d", "exclusions", rest_global, -ndiff);
"two-body cut-off distance (%g nm), see option -rdd, for pairs and tabulated bonds "
"also see option -ddcheck",
-ndiff_tot,
- cr->dd->nbonded_global,
+ dd->reverse_top->impl_->expectedNumGlobalBondedInteractions,
dd_cutoff_multibody(dd),
dd_cutoff_twobody(dd));
}
fprintf(debug, "The total size of the atom to interaction index is %d integers\n", ril_mt_tot_size);
}
- numInteractionsToCheck = 0;
+ expectedNumGlobalBondedInteractions = 0;
for (const gmx_molblock_t& molblock : mtop.molblock)
{
- numInteractionsToCheck += molblock.nmol * nint_mt[molblock.type];
+ expectedNumGlobalBondedInteractions += molblock.nmol * nint_mt[molblock.type];
}
/* Make an intermolecular reverse top, if necessary */
GMX_RELEASE_ASSERT(mtop.intermolecular_ilist,
"We should have an ilist when intermolecular interactions are on");
- numInteractionsToCheck += make_reverse_ilist(
+ expectedNumGlobalBondedInteractions += make_reverse_ilist(
*mtop.intermolecular_ilist, &atoms_global, options, AtomLinkRule::FirstAtom, &ril_intermol);
}
dd->reverse_top = std::make_unique<gmx_reverse_top_t>(
mtop, inputrec.efep != FreeEnergyPerturbationType::No, rtOptions);
- dd->nbonded_global = dd->reverse_top->impl_->numInteractionsToCheck;
-
dd->haveExclusions = false;
for (const gmx_molblock_t& molb : mtop.molblock)
{
}
}
-/*! \brief Check and when available assign bonded interactions for local atom i
+/*! \brief Determine whether the local domain has responsibility for
+ * any of the bonded interactions for local atom i
+ *
+ * \returns The total number of bonded interactions for this atom for
+ * which this domain is responsible.
*/
-static inline void check_assign_interactions_atom(int i,
- int i_gl,
- int mol,
- int i_mol,
- int numAtomsInMolecule,
- gmx::ArrayRef<const int> index,
- gmx::ArrayRef<const int> rtil,
- gmx_bool bInterMolInteractions,
- int ind_start,
- int ind_end,
- const gmx_ga2la_t& ga2la,
- const gmx_domdec_zones_t* zones,
- const gmx_molblock_t* molb,
- gmx_bool bRCheckMB,
- const ivec rcheck,
- gmx_bool bRCheck2B,
- real rc2,
- t_pbc* pbc_null,
- rvec* cg_cm,
- const t_iparams* ip_in,
- InteractionDefinitions* idef,
- int iz,
- const DDBondedChecking ddBondedChecking,
- int* nbonded_local)
+static inline int assign_interactions_atom(int i,
+ int i_gl,
+ int mol,
+ int i_mol,
+ int numAtomsInMolecule,
+ gmx::ArrayRef<const int> index,
+ gmx::ArrayRef<const int> rtil,
+ gmx_bool bInterMolInteractions,
+ int ind_start,
+ int ind_end,
+ const gmx_ga2la_t& ga2la,
+ const gmx_domdec_zones_t* zones,
+ const gmx_molblock_t* molb,
+ gmx_bool bRCheckMB,
+ const ivec rcheck,
+ gmx_bool bRCheck2B,
+ real rc2,
+ t_pbc* pbc_null,
+ rvec* cg_cm,
+ const t_iparams* ip_in,
+ InteractionDefinitions* idef,
+ int iz,
+ const DDBondedChecking ddBondedChecking)
{
gmx::ArrayRef<const DDPairInteractionRanges> iZones = zones->iZones;
+ int numBondedInteractions = 0;
+
int j = ind_start;
while (j < ind_end)
{
else
{
/* Assign this multi-body bonded interaction to
- * the local node if we have all the atoms involved
+ * the local domain if we have all the atoms involved
* (local or communicated) and the minimum zone shift
* in each dimension is zero, for dimensions
* with 2 DD cells an extra check may be necessary.
if (ddBondedChecking == DDBondedChecking::All
|| !(interaction_function[ftype].flags & IF_LIMZERO))
{
- (*nbonded_local)++;
+ numBondedInteractions++;
}
}
}
j += 1 + nral_rt(ftype);
}
+
+ return numBondedInteractions;
}
/*! \brief This function looks up and assigns bonded interactions for zone iz.
const auto ddBondedChecking = rt->impl_->options.ddBondedChecking;
- int nbonded_local = 0;
+ int numBondedInteractions = 0;
for (int i : atomRange)
{
gmx::ArrayRef<const int> index = rt->impl_->ril_mt[mt].index;
gmx::ArrayRef<const t_iatom> rtil = rt->impl_->ril_mt[mt].il;
- check_assign_interactions_atom(i,
- i_gl,
- mol,
- i_mol,
- rt->impl_->ril_mt[mt].numAtomsInMolecule,
- index,
- rtil,
- FALSE,
- index[i_mol],
- index[i_mol + 1],
- ga2la,
- zones,
- &molb[mb],
- bRCheckMB,
- rcheck,
- bRCheck2B,
- rc2,
- pbc_null,
- cg_cm,
- ip_in,
- idef,
- izone,
- ddBondedChecking,
- &nbonded_local);
+ numBondedInteractions += assign_interactions_atom(i,
+ i_gl,
+ mol,
+ i_mol,
+ rt->impl_->ril_mt[mt].numAtomsInMolecule,
+ index,
+ rtil,
+ FALSE,
+ index[i_mol],
+ index[i_mol + 1],
+ ga2la,
+ zones,
+ &molb[mb],
+ bRCheckMB,
+ rcheck,
+ bRCheck2B,
+ rc2,
+ pbc_null,
+ cg_cm,
+ ip_in,
+ idef,
+ izone,
+ ddBondedChecking);
if (rt->impl_->bIntermolecularInteractions)
index = rt->impl_->ril_intermol.index;
rtil = rt->impl_->ril_intermol.il;
- check_assign_interactions_atom(i,
- i_gl,
- mol,
- i_mol,
- rt->impl_->ril_mt[mt].numAtomsInMolecule,
- index,
- rtil,
- TRUE,
- index[i_gl],
- index[i_gl + 1],
- ga2la,
- zones,
- &molb[mb],
- bRCheckMB,
- rcheck,
- bRCheck2B,
- rc2,
- pbc_null,
- cg_cm,
- ip_in,
- idef,
- izone,
- ddBondedChecking,
- &nbonded_local);
+ numBondedInteractions += assign_interactions_atom(i,
+ i_gl,
+ mol,
+ i_mol,
+ rt->impl_->ril_mt[mt].numAtomsInMolecule,
+ index,
+ rtil,
+ TRUE,
+ index[i_gl],
+ index[i_gl + 1],
+ ga2la,
+ zones,
+ &molb[mb],
+ bRCheckMB,
+ rcheck,
+ bRCheck2B,
+ rc2,
+ pbc_null,
+ cg_cm,
+ ip_in,
+ idef,
+ izone,
+ ddBondedChecking);
}
}
- return nbonded_local;
+ return numBondedInteractions;
}
/*! \brief Set the exclusion data for i-zone \p iz */
}
/*! \brief Generate and store all required local bonded interactions in \p idef and local exclusions in \p lexcls */
-static int make_local_bondeds_excls(gmx_domdec_t* dd,
- gmx_domdec_zones_t* zones,
- const gmx_mtop_t& mtop,
- const int* cginfo,
- gmx_bool bRCheckMB,
- ivec rcheck,
- gmx_bool bRCheck2B,
- real rc,
- t_pbc* pbc_null,
- rvec* cg_cm,
- InteractionDefinitions* idef,
- ListOfLists<int>* lexcls,
- int* excl_count)
+static void make_local_bondeds_excls(gmx_domdec_t* dd,
+ gmx_domdec_zones_t* zones,
+ const gmx_mtop_t& mtop,
+ const int* cginfo,
+ gmx_bool bRCheckMB,
+ ivec rcheck,
+ gmx_bool bRCheck2B,
+ real rc,
+ t_pbc* pbc_null,
+ rvec* cg_cm,
+ InteractionDefinitions* idef,
+ ListOfLists<int>* lexcls,
+ int* excl_count)
{
int nzone_bondeds = 0;
/* Clear the counts */
idef->clear();
- int nbonded_local = 0;
+ dd->reverse_top->impl_->numBondedInteractions = 0;
lexcls->clear();
*excl_count = 0;
idef_t->clear();
}
- rt->impl_->th_work[thread].nbonded = make_bondeds_zone(rt,
- dd->globalAtomIndices,
- *dd->ga2la,
- zones,
- mtop.molblock,
- bRCheckMB,
- rcheck,
- bRCheck2B,
- rc2,
- pbc_null,
- cg_cm,
- idef->iparams.data(),
- idef_t,
- izone,
- gmx::Range<int>(cg0t, cg1t));
+ rt->impl_->th_work[thread].numBondedInteractions =
+ make_bondeds_zone(rt,
+ dd->globalAtomIndices,
+ *dd->ga2la,
+ zones,
+ mtop.molblock,
+ bRCheckMB,
+ rcheck,
+ bRCheck2B,
+ rc2,
+ pbc_null,
+ cg_cm,
+ idef->iparams.data(),
+ idef_t,
+ izone,
+ gmx::Range<int>(cg0t, cg1t));
if (izone < numIZonesForExclusions)
{
for (const thread_work_t& th_work : rt->impl_->th_work)
{
- nbonded_local += th_work.nbonded;
+ dd->reverse_top->impl_->numBondedInteractions += th_work.numBondedInteractions;
}
if (izone < numIZonesForExclusions)
}
}
+ // Note that it's possible for this to still be true from the last
+ // time it was set, e.g. if repartitioning was triggered before
+ // global communication that would have acted on the true
+ // value. This could happen for example when replica exchange took
+ // place soon after a partition.
+ dd->reverse_top->impl_->shouldCheckNumberOfBondedInteractions = true;
+ // Clear the old global value, which is now invalid
+ dd->reverse_top->impl_->numBondedInteractionsOverAllDomains.reset();
+
if (debug)
{
fprintf(debug, "We have %d exclusions, check count %d\n", lexcls->numElements(), *excl_count);
}
+}
+
+bool shouldCheckNumberOfBondedInteractions(const gmx_domdec_t& dd)
+{
+ return dd.reverse_top->impl_->shouldCheckNumberOfBondedInteractions;
+}
- return nbonded_local;
+int numBondedInteractions(const gmx_domdec_t& dd)
+{
+ return dd.reverse_top->impl_->numBondedInteractions;
+}
+
+void setNumberOfBondedInteractionsOverAllDomains(const gmx_domdec_t& dd, int newValue)
+{
+ GMX_RELEASE_ASSERT(!dd.reverse_top->impl_->numBondedInteractionsOverAllDomains.has_value(),
+ "Cannot set number of bonded interactions because it is already set");
+ dd.reverse_top->impl_->numBondedInteractionsOverAllDomains.emplace(newValue);
+}
+
+void checkNumberOfBondedInteractions(const gmx::MDLogger& mdlog,
+ t_commrec* cr,
+ const gmx_mtop_t& top_global,
+ const gmx_localtop_t* top_local,
+ gmx::ArrayRef<const gmx::RVec> x,
+ const matrix box)
+{
+ GMX_RELEASE_ASSERT(
+ DOMAINDECOMP(cr),
+ "No need to check number of bonded interactions when not using domain decomposition");
+ if (cr->dd->reverse_top->impl_->shouldCheckNumberOfBondedInteractions)
+ {
+ GMX_RELEASE_ASSERT(cr->dd->reverse_top->impl_->numBondedInteractionsOverAllDomains.has_value(),
+ "The check for the total number of bonded interactions requires the "
+ "value to have been reduced across all domains");
+ if (cr->dd->reverse_top->impl_->numBondedInteractionsOverAllDomains.value()
+ != cr->dd->reverse_top->impl_->expectedNumGlobalBondedInteractions)
+ {
+ dd_print_missing_interactions(
+ mdlog,
+ cr,
+ cr->dd->reverse_top->impl_->numBondedInteractionsOverAllDomains.value(),
+ top_global,
+ top_local,
+ x,
+ box); // Does not return
+ }
+ // Now that the value is set and the check complete, future
+ // global communication should not compute the value until
+ // after the next partitioning.
+ cr->dd->reverse_top->impl_->shouldCheckNumberOfBondedInteractions = false;
+ }
}
void dd_make_local_top(gmx_domdec_t* dd,
}
}
- dd->nbonded_local = make_local_bondeds_excls(dd,
- zones,
- mtop,
- fr->cginfo.data(),
- bRCheckMB,
- rcheck,
- bRCheck2B,
- rc,
- pbc_null,
- cgcm_or_x,
- <op->idef,
- <op->excls,
- &nexcl);
+ make_local_bondeds_excls(dd,
+ zones,
+ mtop,
+ fr->cginfo.data(),
+ bRCheckMB,
+ rcheck,
+ bRCheck2B,
+ rc,
+ pbc_null,
+ cgcm_or_x,
+ <op->idef,
+ <op->excls,
+ &nexcl);
/* The ilist is not sorted yet,
* we can only do this when we have the charge arrays.
wallcycle_stop(wcycle, ewcDOMDEC);
}
-
-/*! \brief Check whether bonded interactions are missing, if appropriate */
-void checkNumberOfBondedInteractions(const gmx::MDLogger& mdlog,
- t_commrec* cr,
- int totalNumberOfBondedInteractions,
- const gmx_mtop_t& top_global,
- const gmx_localtop_t* top_local,
- gmx::ArrayRef<const gmx::RVec> x,
- const matrix box,
- bool* shouldCheckNumberOfBondedInteractions)
-{
- if (*shouldCheckNumberOfBondedInteractions)
- {
- if (totalNumberOfBondedInteractions != cr->dd->nbonded_global)
- {
- dd_print_missing_interactions(
- mdlog, cr, totalNumberOfBondedInteractions, top_global, top_local, x, box); // Does not return
- }
- *shouldCheckNumberOfBondedInteractions = false;
- }
-}
gmx_wallcycle* wcycle,
gmx_bool bVerbose);
-/*! \brief Check whether bonded interactions are missing, if appropriate
- *
- * \param[in] mdlog Logger
- * \param[in] cr Communication object
- * \param[in] totalNumberOfBondedInteractions Result of the global reduction over the number of bonds treated in each domain
- * \param[in] top_global Global topology for the error message
- * \param[in] top_local Local topology for the error message
- * \param[in] x Position vector for the error message
- * \param[in] box Box matrix for the error message
- * \param[in,out] shouldCheckNumberOfBondedInteractions Whether we should do the check. Always set to false.
- */
-void checkNumberOfBondedInteractions(const gmx::MDLogger& mdlog,
- t_commrec* cr,
- int totalNumberOfBondedInteractions,
- const gmx_mtop_t& top_global,
- const gmx_localtop_t* top_local,
- gmx::ArrayRef<const gmx::RVec> x,
- const matrix box,
- bool* shouldCheckNumberOfBondedInteractions);
-
#endif
gmx::ArrayRef<real> constraintsRmsdData,
gmx::SimulationSignaller* signalCoordinator,
const matrix lastbox,
- int* totalNumberOfBondedInteractions,
gmx_bool* bSumEkinhOld,
const int flags)
{
bStopCM ? vcm : nullptr,
signalBuffer.size(),
signalBuffer.data(),
- totalNumberOfBondedInteractions,
*bSumEkinhOld,
flags);
wallcycle_stop(wcycle, ewcMoveE);
gmx::ArrayRef<real> constraintsRmsdData,
gmx::SimulationSignaller* signalCoordinator,
const matrix lastbox,
- int* totalNumberOfBondedInteractions,
gmx_bool* bSumEkinhOld,
int flags);
t_vcm* vcm,
int nsig,
real* sig,
- int* totalNumberOfBondedInteractions,
bool bSumEkinhOld,
int flags)
/* instead of current system, gmx_booleans for summing virial, kinetic energy, and other terms */
if (checkNumberOfBondedInteractions)
{
- nb = cr->dd->nbonded_local;
+ GMX_RELEASE_ASSERT(DOMAINDECOMP(cr),
+ "No need to check number of bonded interactions when not using domain "
+ "decomposition");
+ nb = numBondedInteractions(*cr->dd);
inb = add_bind(rb, 1, &nb);
}
if (nsig > 0)
if (checkNumberOfBondedInteractions)
{
extract_bind(rb, inb, 1, &nb);
- *totalNumberOfBondedInteractions = gmx::roundToInt(nb);
+ GMX_RELEASE_ASSERT(DOMAINDECOMP(cr),
+ "No need to check number of bonded interactions when not using domain "
+ "decomposition");
+ setNumberOfBondedInteractionsOverAllDomains(*cr->dd, gmx::roundToInt(nb));
}
if (nsig > 0)
t_vcm* vcm,
int nsig,
real* sig,
- int* totalNumberOfBondedInteractions,
bool bSumEkinhOld,
int flags);
#include <algorithm>
#include <memory>
-#include "gromacs/domdec/partition.h"
+#include "gromacs/domdec/domdec.h"
#include "gromacs/gmxlib/nrnb.h"
#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/timing/wallcycle.h"
#include "gromacs/topology/topology.h"
-void integrateVVFirstStep(int64_t step,
- bool bFirstStep,
- bool bInitStep,
- gmx::StartingBehavior startingBehavior,
- int nstglobalcomm,
- const t_inputrec* ir,
- t_forcerec* fr,
- t_commrec* cr,
- t_state* state,
- t_mdatoms* mdatoms,
- const t_fcdata& fcdata,
- t_extmass* MassQ,
- t_vcm* vcm,
- const gmx_mtop_t& top_global,
- const gmx_localtop_t& top,
- gmx_enerdata_t* enerd,
- gmx_ekindata_t* ekind,
- gmx_global_stat* gstat,
- real* last_ekin,
- bool bCalcVir,
- tensor total_vir,
- tensor shake_vir,
- tensor force_vir,
- tensor pres,
- matrix M,
- bool do_log,
- bool do_ene,
- bool bCalcEner,
- bool bGStat,
- bool bStopCM,
- bool bTrotter,
- bool bExchanged,
- bool* bSumEkinhOld,
- bool* shouldCheckNumberOfBondedInteractions,
- real* saved_conserved_quantity,
- gmx::ForceBuffers* f,
- gmx::Update* upd,
- gmx::Constraints* constr,
- gmx::SimulationSignaller* nullSignaller,
+void integrateVVFirstStep(int64_t step,
+ bool bFirstStep,
+ bool bInitStep,
+ gmx::StartingBehavior startingBehavior,
+ int nstglobalcomm,
+ const t_inputrec* ir,
+ t_forcerec* fr,
+ t_commrec* cr,
+ t_state* state,
+ t_mdatoms* mdatoms,
+ const t_fcdata& fcdata,
+ t_extmass* MassQ,
+ t_vcm* vcm,
+ const gmx_mtop_t& top_global,
+ const gmx_localtop_t& top,
+ gmx_enerdata_t* enerd,
+ gmx_ekindata_t* ekind,
+ gmx_global_stat* gstat,
+ real* last_ekin,
+ bool bCalcVir,
+ tensor total_vir,
+ tensor shake_vir,
+ tensor force_vir,
+ tensor pres,
+ matrix M,
+ bool do_log,
+ bool do_ene,
+ bool bCalcEner,
+ bool bGStat,
+ bool bStopCM,
+ bool bTrotter,
+ bool bExchanged,
+ bool* bSumEkinhOld,
+ real* saved_conserved_quantity,
+ gmx::ForceBuffers* f,
+ gmx::Update* upd,
+ gmx::Constraints* constr,
+ gmx::SimulationSignaller* nullSignaller,
std::array<std::vector<int>, ettTSEQMAX> trotter_seq,
t_nrnb* nrnb,
const gmx::MDLogger& mdlog,
if (bGStat || do_per_step(step - 1, nstglobalcomm))
{
wallcycle_stop(wcycle, ewcUPDATE);
- int totalNumberOfBondedInteractions = -1;
+ int cglo_flags =
+ ((bGStat ? CGLO_GSTAT : 0) | (bCalcEner ? CGLO_ENERGY : 0)
+ | (bTemp ? CGLO_TEMPERATURE : 0) | (bPres ? CGLO_PRESSURE : 0)
+ | (bPres ? CGLO_CONSTRAINT : 0) | (bStopCM ? CGLO_STOPCM : 0) | CGLO_SCALEEKIN);
+ if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd))
+ {
+ cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS;
+ }
compute_globals(gstat,
cr,
ir,
(bCalcEner && constr != nullptr) ? constr->rmsdData() : gmx::ArrayRef<real>{},
nullSignaller,
state->box,
- &totalNumberOfBondedInteractions,
bSumEkinhOld,
- (bGStat ? CGLO_GSTAT : 0) | (bCalcEner ? CGLO_ENERGY : 0)
- | (bTemp ? CGLO_TEMPERATURE : 0) | (bPres ? CGLO_PRESSURE : 0)
- | (bPres ? CGLO_CONSTRAINT : 0) | (bStopCM ? CGLO_STOPCM : 0)
- | (*shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS
- : 0)
- | CGLO_SCALEEKIN);
+ cglo_flags);
/* explanation of above:
a) We compute Ekin at the full time step
if 1) we are using the AveVel Ekin, and it's not the
time step kinetic energy for the pressure (always true now, since we want accurate statistics).
b) If we are using EkinAveEkin for the kinetic energy for the temperature control, we still feed in
EkinAveVel because it's needed for the pressure */
- checkNumberOfBondedInteractions(mdlog,
- cr,
- totalNumberOfBondedInteractions,
- top_global,
- &top,
- makeConstArrayRef(state->x),
- state->box,
- shouldCheckNumberOfBondedInteractions);
+ if (DOMAINDECOMP(cr))
+ {
+ checkNumberOfBondedInteractions(
+ mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box);
+ }
if (bStopCM)
{
process_and_stopcm_grp(
gmx::ArrayRef<real>{},
nullSignaller,
state->box,
- nullptr,
bSumEkinhOld,
CGLO_GSTAT | CGLO_TEMPERATURE);
wallcycle_start(wcycle, ewcUPDATE);
gmx::ArrayRef<real>{},
nullSignaller,
lastbox,
- nullptr,
bSumEkinhOld,
(bGStat ? CGLO_GSTAT : 0) | CGLO_TEMPERATURE);
wallcycle_start(wcycle, ewcUPDATE);
* \param[in] bTrotter Do trotter routines this step.
* \param[in] bExchanged If this is a replica exchange step.
* \param[out] bSumEkinhOld Old kinetic energies will need to be summed up.
- * \param[out] shouldCheckNumberOfBondedInteractions If checks for missing bonded
- * interactions will be needed.
* \param[out] saved_conserved_quantity Place to store the conserved energy.
* \param[in] f Force buffers.
* \param[in] upd Update object.
* \param[in] fplog Another logger.
* \param[in] wcycle Wall-clock cycle counter.
*/
-void integrateVVFirstStep(int64_t step,
- bool bFirstStep,
- bool bInitStep,
- gmx::StartingBehavior startingBehavior,
- int nstglobalcomm,
- const t_inputrec* ir,
- t_forcerec* fr,
- t_commrec* cr,
- t_state* state,
- t_mdatoms* mdatoms,
- const t_fcdata& fcdata,
- t_extmass* MassQ,
- t_vcm* vcm,
- const gmx_mtop_t& top_global,
- const gmx_localtop_t& top,
- gmx_enerdata_t* enerd,
- gmx_ekindata_t* ekind,
- gmx_global_stat* gstat,
- real* last_ekin,
- bool bCalcVir,
- tensor total_vir,
- tensor shake_vir,
- tensor force_vir,
- tensor pres,
- matrix M,
- bool do_log,
- bool do_ene,
- bool bCalcEner,
- bool bGStat,
- bool bStopCM,
- bool bTrotter,
- bool bExchanged,
- bool* bSumEkinhOld,
- bool* shouldCheckNumberOfBondedInteractions,
- real* saved_conserved_quantity,
- gmx::ForceBuffers* f,
- gmx::Update* upd,
- gmx::Constraints* constr,
- gmx::SimulationSignaller* nullSignaller,
+void integrateVVFirstStep(int64_t step,
+ bool bFirstStep,
+ bool bInitStep,
+ gmx::StartingBehavior startingBehavior,
+ int nstglobalcomm,
+ const t_inputrec* ir,
+ t_forcerec* fr,
+ t_commrec* cr,
+ t_state* state,
+ t_mdatoms* mdatoms,
+ const t_fcdata& fcdata,
+ t_extmass* MassQ,
+ t_vcm* vcm,
+ const gmx_mtop_t& top_global,
+ const gmx_localtop_t& top,
+ gmx_enerdata_t* enerd,
+ gmx_ekindata_t* ekind,
+ gmx_global_stat* gstat,
+ real* last_ekin,
+ bool bCalcVir,
+ tensor total_vir,
+ tensor shake_vir,
+ tensor force_vir,
+ tensor pres,
+ matrix M,
+ bool do_log,
+ bool do_ene,
+ bool bCalcEner,
+ bool bGStat,
+ bool bStopCM,
+ bool bTrotter,
+ bool bExchanged,
+ bool* bSumEkinhOld,
+ real* saved_conserved_quantity,
+ gmx::ForceBuffers* f,
+ gmx::Update* upd,
+ gmx::Constraints* constr,
+ gmx::SimulationSignaller* nullSignaller,
std::array<std::vector<int>, ettTSEQMAX> trotter_seq,
t_nrnb* nrnb,
const gmx::MDLogger& mdlog,
bool bInteractiveMDstep = false;
- /* Domain decomposition could incorrectly miss a bonded
- interaction, but checking for that requires a global
- communication stage, which does not otherwise happen in DD
- code. So we do that alongside the first global energy reduction
- after a new DD is made. These variables handle whether the
- check happens, and the result it returns. */
- bool shouldCheckNumberOfBondedInteractions = false;
- int totalNumberOfBondedInteractions = -1;
-
SimulationSignals signals;
// Most global communnication stages don't propagate mdrun
// signals, and will use this object to achieve that.
nrnb,
nullptr,
FALSE);
- shouldCheckNumberOfBondedInteractions = true;
upd.setNumAtoms(state->natoms);
}
else
cglo_flags_iteration |= CGLO_STOPCM;
cglo_flags_iteration &= ~CGLO_TEMPERATURE;
}
+ if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd) && cgloIteration == 0)
+ {
+ cglo_flags_iteration |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS;
+ }
compute_globals(gstat,
cr,
ir,
gmx::ArrayRef<real>{},
&nullSignaller,
state->box,
- &totalNumberOfBondedInteractions,
&bSumEkinhOld,
- cglo_flags_iteration
- | (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS
- : 0));
+ cglo_flags_iteration);
if (cglo_flags_iteration & CGLO_STOPCM)
{
/* At initialization, do not pass x with acceleration-correction mode
inc_nrnb(nrnb, eNR_STOPCM, mdatoms->homenr);
}
}
- checkNumberOfBondedInteractions(mdlog,
- cr,
- totalNumberOfBondedInteractions,
- top_global,
- &top,
- makeConstArrayRef(state->x),
- state->box,
- &shouldCheckNumberOfBondedInteractions);
+ if (DOMAINDECOMP(cr))
+ {
+ checkNumberOfBondedInteractions(
+ mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box);
+ }
if (ir->eI == IntegrationAlgorithm::VVAK)
{
/* a second call to get the half step temperature initialized as well */
gmx::ArrayRef<real>{},
&nullSignaller,
state->box,
- nullptr,
&bSumEkinhOld,
cglo_flags & ~CGLO_PRESSURE);
}
nrnb,
wcycle,
do_verbose && !bPMETunePrinting);
- shouldCheckNumberOfBondedInteractions = true;
upd.setNumAtoms(state->natoms);
}
}
/* We need the kinetic energy at minus the half step for determining
* the full step kinetic energy and possibly for T-coupling.*/
/* This may not be quite working correctly yet . . . . */
+ int cglo_flags = CGLO_GSTAT | CGLO_TEMPERATURE;
+ if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd))
+ {
+ cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS;
+ }
compute_globals(gstat,
cr,
ir,
gmx::ArrayRef<real>{},
&nullSignaller,
state->box,
- &totalNumberOfBondedInteractions,
&bSumEkinhOld,
- CGLO_GSTAT | CGLO_TEMPERATURE | CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS);
- checkNumberOfBondedInteractions(mdlog,
- cr,
- totalNumberOfBondedInteractions,
- top_global,
- &top,
- makeConstArrayRef(state->x),
- state->box,
- &shouldCheckNumberOfBondedInteractions);
+ cglo_flags);
+ if (DOMAINDECOMP(cr))
+ {
+ checkNumberOfBondedInteractions(
+ mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box);
+ }
}
clear_mat(force_vir);
bTrotter,
bExchanged,
&bSumEkinhOld,
- &shouldCheckNumberOfBondedInteractions,
&saved_conserved_quantity,
&f,
&upd,
: gmx::ArrayRef<real>{},
&signaller,
lastbox,
- &totalNumberOfBondedInteractions,
&bSumEkinhOld,
(bGStat ? CGLO_GSTAT : 0) | (!EI_VV(ir->eI) && bCalcEner ? CGLO_ENERGY : 0)
| (!EI_VV(ir->eI) && bStopCM ? CGLO_STOPCM : 0)
| (!EI_VV(ir->eI) ? CGLO_TEMPERATURE : 0)
| (!EI_VV(ir->eI) ? CGLO_PRESSURE : 0) | CGLO_CONSTRAINT
- | (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS
- : 0));
- checkNumberOfBondedInteractions(mdlog,
- cr,
- totalNumberOfBondedInteractions,
- top_global,
- &top,
- makeConstArrayRef(state->x),
- state->box,
- &shouldCheckNumberOfBondedInteractions);
+ | (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd)
+ ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS
+ : 0));
+ if (DOMAINDECOMP(cr))
+ {
+ checkNumberOfBondedInteractions(
+ mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box);
+ }
if (!EI_VV(ir->eI) && bStopCM)
{
process_and_stopcm_grp(
nrnb,
wcycle,
FALSE);
- shouldCheckNumberOfBondedInteractions = true;
upd.setNumAtoms(state->natoms);
}
double cycles;
- /* Domain decomposition could incorrectly miss a bonded
- interaction, but checking for that requires a global
- communication stage, which does not otherwise happen in DD
- code. So we do that alongside the first global energy reduction
- after a new DD is made. These variables handle whether the
- check happens, and the result it returns. */
- bool shouldCheckNumberOfBondedInteractions = false;
- int totalNumberOfBondedInteractions = -1;
-
SimulationSignals signals;
// Most global communnication stages don't propagate mdrun
// signals, and will use this object to achieve that.
nrnb,
nullptr,
FALSE);
- shouldCheckNumberOfBondedInteractions = true;
}
else
{
}
{
- int cglo_flags =
- (CGLO_GSTAT
- | (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0));
+ int cglo_flags = CGLO_GSTAT;
+ if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd))
+ {
+ cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS;
+ }
bool bSumEkinhOld = false;
t_vcm* vcm = nullptr;
compute_globals(gstat,
gmx::ArrayRef<real>{},
&nullSignaller,
state->box,
- &totalNumberOfBondedInteractions,
&bSumEkinhOld,
cglo_flags);
+ if (DOMAINDECOMP(cr))
+ {
+ checkNumberOfBondedInteractions(
+ mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box);
+ }
}
- checkNumberOfBondedInteractions(mdlog,
- cr,
- totalNumberOfBondedInteractions,
- top_global,
- &top,
- makeConstArrayRef(state->x),
- state->box,
- &shouldCheckNumberOfBondedInteractions);
if (MASTER(cr))
{
nrnb,
wcycle,
mdrunOptions.verbose);
- shouldCheckNumberOfBondedInteractions = true;
}
if (MASTER(cr))
t_vcm* vcm = nullptr;
SimulationSignaller signaller(&signals, cr, ms, doInterSimSignal, doIntraSimSignal);
+ int cglo_flags = CGLO_GSTAT | CGLO_ENERGY;
+ if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd))
+ {
+ cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS;
+ }
compute_globals(gstat,
cr,
ir,
constr != nullptr ? constr->rmsdData() : gmx::ArrayRef<real>{},
&signaller,
state->box,
- &totalNumberOfBondedInteractions,
&bSumEkinhOld,
- CGLO_GSTAT | CGLO_ENERGY
- | (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS
- : 0));
- checkNumberOfBondedInteractions(mdlog,
- cr,
- totalNumberOfBondedInteractions,
- top_global,
- &top,
- makeConstArrayRef(state->x),
- state->box,
- &shouldCheckNumberOfBondedInteractions);
+ cglo_flags);
+ if (DOMAINDECOMP(cr))
+ {
+ checkNumberOfBondedInteractions(
+ mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box);
+ }
}
{
nullptr,
1,
&terminate,
- nullptr,
FALSE,
CGLO_ENERGY | CGLO_PRESSURE | CGLO_CONSTRAINT);
double cycles;
- /* Domain decomposition could incorrectly miss a bonded
- interaction, but checking for that requires a global
- communication stage, which does not otherwise happen in DD
- code. So we do that alongside the first global energy reduction
- after a new DD is made. These variables handle whether the
- check happens, and the result it returns. */
- bool shouldCheckNumberOfBondedInteractions = false;
- int totalNumberOfBondedInteractions = -1;
-
SimulationSignals signals;
// Most global communnication stages don't propagate mdrun
// signals, and will use this object to achieve that.
nrnb,
nullptr,
FALSE);
- shouldCheckNumberOfBondedInteractions = true;
}
else
{
}
{
- int cglo_flags =
- (CGLO_GSTAT
- | (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0));
+ int cglo_flags = CGLO_GSTAT;
+ if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd))
+ {
+ cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS;
+ }
bool bSumEkinhOld = false;
t_vcm* vcm = nullptr;
compute_globals(gstat,
gmx::ArrayRef<real>{},
&nullSignaller,
state->box,
- &totalNumberOfBondedInteractions,
&bSumEkinhOld,
cglo_flags);
+ if (DOMAINDECOMP(cr))
+ {
+ checkNumberOfBondedInteractions(
+ mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box);
+ }
}
- checkNumberOfBondedInteractions(mdlog,
- cr,
- totalNumberOfBondedInteractions,
- top_global,
- &top,
- makeConstArrayRef(state->x),
- state->box,
- &shouldCheckNumberOfBondedInteractions);
if (MASTER(cr))
{
nrnb,
wcycle,
mdrunOptions.verbose);
- shouldCheckNumberOfBondedInteractions = true;
}
if (MASTER(cr))
t_vcm* vcm = nullptr;
SimulationSignaller signaller(&signals, cr, ms, doInterSimSignal, doIntraSimSignal);
+ int cglo_flags = CGLO_GSTAT | CGLO_ENERGY;
+ if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd))
+ {
+ cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS;
+ }
compute_globals(gstat,
cr,
ir,
constr != nullptr ? constr->rmsdData() : gmx::ArrayRef<real>{},
&signaller,
state->box,
- &totalNumberOfBondedInteractions,
&bSumEkinhOld,
- CGLO_GSTAT | CGLO_ENERGY
- | (shouldCheckNumberOfBondedInteractions ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS
- : 0));
- checkNumberOfBondedInteractions(mdlog,
- cr,
- totalNumberOfBondedInteractions,
- top_global,
- &top,
- makeConstArrayRef(state->x),
- state->box,
- &shouldCheckNumberOfBondedInteractions);
+ cglo_flags);
+ if (DOMAINDECOMP(cr))
+ {
+ checkNumberOfBondedInteractions(
+ mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box);
+ }
}
/* Note: this is OK, but there are some numerical precision issues with using the convergence of
#include "computeglobalselement.h"
-#include "gromacs/domdec/partition.h"
+#include "gromacs/domdec/domdec.h"
#include "gromacs/gmxlib/network.h"
#include "gromacs/gmxlib/nrnb.h"
#include "gromacs/math/vec.h"
lastStep_(inputrec->nsteps + inputrec->init_step),
initStep_(inputrec->init_step),
nullSignaller_(std::make_unique<SimulationSignaller>(nullptr, nullptr, nullptr, false, false)),
- totalNumberOfBondedInteractions_(0),
- shouldCheckNumberOfBondedInteractions_(false),
statePropagatorData_(statePropagatorData),
energyData_(energyData),
localTopology_(nullptr),
auto lastbox = useLastBox ? statePropagatorData_->constPreviousBox()
: statePropagatorData_->constBox();
- compute_globals(
- gstat_,
- cr_,
- inputrec_,
- fr_,
- energyData_->ekindata(),
- x,
- v,
- box,
- mdAtoms_->mdatoms(),
- nrnb_,
- &vcm_,
- step != -1 ? wcycle_ : nullptr,
- energyData_->enerdata(),
- energyData_->forceVirial(step),
- energyData_->constraintVirial(step),
- energyData_->totalVirial(step),
- energyData_->pressure(step),
- (((flags & CGLO_ENERGY) != 0) && constr_ != nullptr) ? constr_->rmsdData()
- : gmx::ArrayRef<real>{},
- signaller,
- lastbox,
- &totalNumberOfBondedInteractions_,
- energyData_->needToSumEkinhOld(),
- flags | (shouldCheckNumberOfBondedInteractions_ ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0));
- checkNumberOfBondedInteractions(
- mdlog_, cr_, totalNumberOfBondedInteractions_, top_global_, localTopology_, x, box, &shouldCheckNumberOfBondedInteractions_);
+ if (DOMAINDECOMP(cr_) && shouldCheckNumberOfBondedInteractions(*cr_->dd))
+ {
+ flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS;
+ }
+ compute_globals(gstat_,
+ cr_,
+ inputrec_,
+ fr_,
+ energyData_->ekindata(),
+ x,
+ v,
+ box,
+ mdAtoms_->mdatoms(),
+ nrnb_,
+ &vcm_,
+ step != -1 ? wcycle_ : nullptr,
+ energyData_->enerdata(),
+ energyData_->forceVirial(step),
+ energyData_->constraintVirial(step),
+ energyData_->totalVirial(step),
+ energyData_->pressure(step),
+ (((flags & CGLO_ENERGY) != 0) && constr_ != nullptr) ? constr_->rmsdData()
+ : gmx::ArrayRef<real>{},
+ signaller,
+ lastbox,
+ energyData_->needToSumEkinhOld(),
+ flags);
+ if (DOMAINDECOMP(cr_))
+ {
+ checkNumberOfBondedInteractions(mdlog_, cr_, top_global_, localTopology_, x, box);
+ }
if (flags & CGLO_STOPCM && !isInit)
{
process_and_stopcm_grp(fplog_, &vcm_, *mdAtoms_->mdatoms(), x, v);
}
}
-template<ComputeGlobalsAlgorithm algorithm>
-CheckBondedInteractionsCallback ComputeGlobalsElement<algorithm>::getCheckNumberOfBondedInteractionsCallback()
-{
- return [this]() { needToCheckNumberOfBondedInteractions(); };
-}
-
-template<ComputeGlobalsAlgorithm algorithm>
-void ComputeGlobalsElement<algorithm>::needToCheckNumberOfBondedInteractions()
-{
- shouldCheckNumberOfBondedInteractions_ = true;
-}
-
template<ComputeGlobalsAlgorithm algorithm>
void ComputeGlobalsElement<algorithm>::setTopology(const gmx_localtop_t* top)
{
legacySimulatorData->top_global,
legacySimulatorData->constr));
- // TODO: Remove this when DD can reduce bonded interactions independently (#3421)
- auto* castedElement = static_cast<ComputeGlobalsElement<ComputeGlobalsAlgorithm::LeapFrog>*>(element);
- globalCommunicationHelper->setCheckBondedInteractionsCallback(
- castedElement->getCheckNumberOfBondedInteractionsCallback());
-
return element;
}
simulator->fr,
simulator->top_global,
simulator->constr));
-
- // TODO: Remove this when DD can reduce bonded interactions independently (#3421)
- auto* castedElement =
- static_cast<ComputeGlobalsElement<ComputeGlobalsAlgorithm::VelocityVerlet>*>(
- vvComputeGlobalsElement);
- globalCommunicationHelper->setCheckBondedInteractionsCallback(
- castedElement->getCheckNumberOfBondedInteractionsCallback());
builderHelper->storeValue(key, vvComputeGlobalsElement);
return vvComputeGlobalsElement;
}
namespace gmx
{
-DomDecHelper::DomDecHelper(bool isVerbose,
- int verbosePrintInterval,
- StatePropagatorData* statePropagatorData,
- FreeEnergyPerturbationData* freeEnergyPerturbationData,
- TopologyHolder* topologyHolder,
- CheckBondedInteractionsCallback checkBondedInteractionsCallback,
- int nstglobalcomm,
- FILE* fplog,
- t_commrec* cr,
- const MDLogger& mdlog,
- Constraints* constr,
- const t_inputrec* inputrec,
- MDAtoms* mdAtoms,
- t_nrnb* nrnb,
- gmx_wallcycle* wcycle,
- t_forcerec* fr,
- VirtualSitesHandler* vsite,
- ImdSession* imdSession,
- pull_t* pull_work) :
+DomDecHelper::DomDecHelper(bool isVerbose,
+ int verbosePrintInterval,
+ StatePropagatorData* statePropagatorData,
+ FreeEnergyPerturbationData* freeEnergyPerturbationData,
+ TopologyHolder* topologyHolder,
+ int nstglobalcomm,
+ FILE* fplog,
+ t_commrec* cr,
+ const MDLogger& mdlog,
+ Constraints* constr,
+ const t_inputrec* inputrec,
+ MDAtoms* mdAtoms,
+ t_nrnb* nrnb,
+ gmx_wallcycle* wcycle,
+ t_forcerec* fr,
+ VirtualSitesHandler* vsite,
+ ImdSession* imdSession,
+ pull_t* pull_work) :
nextNSStep_(-1),
isVerbose_(isVerbose),
verbosePrintInterval_(verbosePrintInterval),
statePropagatorData_(statePropagatorData),
freeEnergyPerturbationData_(freeEnergyPerturbationData),
topologyHolder_(topologyHolder),
- checkBondedInteractionsCallback_(std::move(checkBondedInteractionsCallback)),
fplog_(fplog),
cr_(cr),
mdlog_(mdlog),
wcycle,
verbose);
topologyHolder_->updateLocalTopology();
- checkBondedInteractionsCallback_();
statePropagatorData_->setLocalState(std::move(localState));
if (freeEnergyPerturbationData_)
{
//! \addtogroup module_modularsimulator
//! \{
-//! The function type allowing to request a check of the number of bonded interactions
-typedef std::function<void()> CheckBondedInteractionsCallback;
-
/*! \internal
* \brief Infrastructure element responsible for domain decomposition
*
{
public:
//! Constructor
- DomDecHelper(bool isVerbose,
- int verbosePrintInterval,
- StatePropagatorData* statePropagatorData,
- FreeEnergyPerturbationData* freeEnergyPerturbationData,
- TopologyHolder* topologyHolder,
- CheckBondedInteractionsCallback checkBondedInteractionsCallback,
- int nstglobalcomm,
- FILE* fplog,
- t_commrec* cr,
- const MDLogger& mdlog,
- Constraints* constr,
- const t_inputrec* inputrec,
- MDAtoms* mdAtoms,
- t_nrnb* nrnb,
- gmx_wallcycle* wcycle,
- t_forcerec* fr,
- VirtualSitesHandler* vsite,
- ImdSession* imdSession,
- pull_t* pull_work);
+ DomDecHelper(bool isVerbose,
+ int verbosePrintInterval,
+ StatePropagatorData* statePropagatorData,
+ FreeEnergyPerturbationData* freeEnergyPerturbationData,
+ TopologyHolder* topologyHolder,
+ int nstglobalcomm,
+ FILE* fplog,
+ t_commrec* cr,
+ const MDLogger& mdlog,
+ Constraints* constr,
+ const t_inputrec* inputrec,
+ MDAtoms* mdAtoms,
+ t_nrnb* nrnb,
+ gmx_wallcycle* wcycle,
+ t_forcerec* fr,
+ VirtualSitesHandler* vsite,
+ ImdSession* imdSession,
+ pull_t* pull_work);
/*! \brief Run domain decomposition
*
FreeEnergyPerturbationData* freeEnergyPerturbationData_;
//! Pointer to the topology
TopologyHolder* topologyHolder_;
- //! Pointer to the ComputeGlobalsHelper object - to ask for # of bonded interaction checking
- CheckBondedInteractionsCallback checkBondedInteractionsCallback_;
//! Helper function unifying the DD partitioning calls in setup() and run()
void partitionSystem(bool verbose,
algorithm.statePropagatorData_.get(),
algorithm.freeEnergyPerturbationData_.get(),
algorithm.topologyHolder_.get(),
- globalCommunicationHelper_.moveCheckBondedInteractionsCallback(),
globalCommunicationHelper_.nstglobalcomm(),
legacySimulatorData_->fplog,
legacySimulatorData_->cr,
return simulationSignals_;
}
-void GlobalCommunicationHelper::setCheckBondedInteractionsCallback(CheckBondedInteractionsCallback callback)
-{
- checkBondedInteractionsCallback_ = std::move(callback);
-}
-
-CheckBondedInteractionsCallback GlobalCommunicationHelper::moveCheckBondedInteractionsCallback()
-{
- if (!checkBondedInteractionsCallback_)
- {
- throw SimulationAlgorithmSetupError(
- "Requested CheckBondedInteractionsCallback before it was set.");
- }
- return *checkBondedInteractionsCallback_;
-}
-
ModularSimulatorAlgorithmBuilderHelper::ModularSimulatorAlgorithmBuilderHelper(
ModularSimulatorAlgorithmBuilder* builder) :
builder_(builder)
//! Get a pointer to the signals vector
[[nodiscard]] SimulationSignals* simulationSignals();
- //! Set the callback to check the number of bonded interactions
- void setCheckBondedInteractionsCallback(CheckBondedInteractionsCallback callback);
- //! Move the callback to check the number of bonded interactions
- [[nodiscard]] CheckBondedInteractionsCallback moveCheckBondedInteractionsCallback();
-
private:
//! Compute globals communication period
const int nstglobalcomm_;
//! Signal vector (used by stop / reset / checkpointing signaller)
SimulationSignals* simulationSignals_;
- //! Callback to check the number of bonded interactions
- std::optional<CheckBondedInteractionsCallback> checkBondedInteractionsCallback_;
};
class ModularSimulatorAlgorithmBuilder;