From a272eaa06eef136f2153f60ec73904754f202490 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Tue, 1 Jun 2021 11:51:58 +0200 Subject: [PATCH] Make LocalTopologyChecker class and hide implementation details This allows capturing useful state that is only used when writing the error output, without leaking dependencies for implementation details to high-level code. Some minor improvements to const correctness of the error output. Also moved it into gmx namespace. Minor improvement to include order Removed unused forward declaration in domdec.h Refs #3887 --- src/gromacs/domdec/domdec.cpp | 14 +- src/gromacs/domdec/domdec.h | 12 +- src/gromacs/domdec/domdec_struct.h | 2 +- src/gromacs/domdec/localtopologychecker.cpp | 169 ++++++++++++------ src/gromacs/domdec/localtopologychecker.h | 116 ++++++------ src/gromacs/domdec/partition.cpp | 2 +- src/gromacs/mdlib/stat.cpp | 4 +- src/gromacs/mdlib/update_vv.cpp | 8 +- src/gromacs/mdlib/update_vv.h | 4 - src/gromacs/mdrun/md.cpp | 21 ++- src/gromacs/mdrun/mimic.cpp | 12 +- src/gromacs/mdrun/rerun.cpp | 12 +- .../computeglobalselement.cpp | 4 +- 13 files changed, 220 insertions(+), 160 deletions(-) diff --git a/src/gromacs/domdec/domdec.cpp b/src/gromacs/domdec/domdec.cpp index de3aaf1cb9..4aa94fa887 100644 --- a/src/gromacs/domdec/domdec.cpp +++ b/src/gromacs/domdec/domdec.cpp @@ -3022,8 +3022,8 @@ gmx_domdec_t* DomainDecompositionBuilder::Impl::build(LocalAtomSetManager* atomS dd->atomSets = atomSets; - dd->localTopologyChecker = - std::make_unique(mtop_, dd->comm->systemInfo.useUpdateGroups); + dd->localTopologyChecker = std::make_unique( + mdlog_, cr_, mtop_, dd->comm->systemInfo.useUpdateGroups); return dd; } @@ -3220,6 +3220,16 @@ void communicateGpuHaloForces(const t_commrec& cr, bool accumulateForces) } } +const gmx::LocalTopologyChecker& dd_localTopologyChecker(const gmx_domdec_t& dd) +{ + return *dd.localTopologyChecker; +} + +gmx::LocalTopologyChecker* dd_localTopologyChecker(gmx_domdec_t* dd) +{ + return dd->localTopologyChecker.get(); +} + void dd_init_local_state(const gmx_domdec_t& dd, const t_state* state_global, t_state* state_local) { std::array buf; diff --git a/src/gromacs/domdec/domdec.h b/src/gromacs/domdec/domdec.h index d35b02c539..20a7c69945 100644 --- a/src/gromacs/domdec/domdec.h +++ b/src/gromacs/domdec/domdec.h @@ -87,12 +87,12 @@ namespace gmx struct AtomInfoWithinMoleculeBlock; class DeviceStreamManager; class ForceWithShiftForces; +class LocalTopologyChecker; class MDLogger; class RangePartitioning; class VirtualSitesHandler; template class ArrayRef; -enum class DDBondedChecking : bool; } // namespace gmx /*! \brief Returns the global topology atom number belonging to local atom index i. @@ -239,7 +239,15 @@ void dd_move_x_and_v_vsites(const gmx_domdec_t& dd, const matrix box, rvec* x, r */ gmx::ArrayRef dd_constraints_nlocalatoms(const gmx_domdec_t* dd); -/* In domdec_top.c */ +/*! Const getter for the local topology checker + * + * \returns Const handle to local topology checker */ +const gmx::LocalTopologyChecker& dd_localTopologyChecker(const gmx_domdec_t& dd); + +/*! Getter for the local topology checker + * + * \returns Handle to local topology checker */ +gmx::LocalTopologyChecker* dd_localTopologyChecker(gmx_domdec_t* dd); /*! \brief Construct local state */ void dd_init_local_state(const gmx_domdec_t& dd, const t_state* state_global, t_state* local_state); diff --git a/src/gromacs/domdec/domdec_struct.h b/src/gromacs/domdec/domdec_struct.h index 98467b8f1a..613a62e466 100644 --- a/src/gromacs/domdec/domdec_struct.h +++ b/src/gromacs/domdec/domdec_struct.h @@ -78,7 +78,7 @@ namespace gmx template class HashedMap; class LocalAtomSetManager; -struct LocalTopologyChecker; +class LocalTopologyChecker; class GpuHaloExchange; } // namespace gmx diff --git a/src/gromacs/domdec/localtopologychecker.cpp b/src/gromacs/domdec/localtopologychecker.cpp index 0ffb8199de..c4af1d1d32 100644 --- a/src/gromacs/domdec/localtopologychecker.cpp +++ b/src/gromacs/domdec/localtopologychecker.cpp @@ -44,11 +44,12 @@ #include "gmxpre.h" +#include "gromacs/domdec/localtopologychecker.h" + +#include #include #include -#include "gromacs/domdec/localtopologychecker.h" - #include "gromacs/domdec/domdec_internal.h" #include "gromacs/domdec/reversetopology.h" #include "gromacs/gmxlib/network.h" @@ -64,8 +65,8 @@ #include "dump.h" -using gmx::ArrayRef; -using gmx::RVec; +namespace gmx +{ /*! \brief Checks whether interactions have been assigned for one function type * @@ -76,7 +77,7 @@ using gmx::RVec; static void flagInteractionsForType(const int ftype, const InteractionList& il, const reverse_ilist_t& ril, - const gmx::Range& atomRange, + const Range& atomRange, const int numAtomsPerMolecule, ArrayRef globalAtomIndices, ArrayRef isAssigned) @@ -140,19 +141,19 @@ static void flagInteractionsForType(const int ftype, * * \note This function needs to be called on all ranks (contains a global summation) */ -static std::string printMissingInteractionsMolblock(t_commrec* cr, +static std::string printMissingInteractionsMolblock(const t_commrec* cr, const gmx_reverse_top_t& rt, const char* moltypename, const reverse_ilist_t& ril, - const gmx::Range& atomRange, + const Range& atomRange, const int numAtomsPerMolecule, const int numMolecules, const InteractionDefinitions& idef) { - const int nril_mol = ril.index[numAtomsPerMolecule]; - std::vector isAssigned(numMolecules * nril_mol, 0); - gmx::StringOutputStream stream; - gmx::TextWriter log(&stream); + const int nril_mol = ril.index[numAtomsPerMolecule]; + std::vector isAssigned(numMolecules * nril_mol, 0); + StringOutputStream stream; + TextWriter log(&stream); for (int ftype = 0; ftype < F_NRE; ftype++) { @@ -220,8 +221,8 @@ static std::string printMissingInteractionsMolblock(t_commrec* cr, } /*! \brief Help print error output when interactions are missing */ -static void printMissingInteractionsAtoms(const gmx::MDLogger& mdlog, - t_commrec* cr, +static void printMissingInteractionsAtoms(const MDLogger& mdlog, + const t_commrec* cr, const gmx_mtop_t& mtop, const InteractionDefinitions& idef) { @@ -234,7 +235,7 @@ static void printMissingInteractionsAtoms(const gmx::MDLogger& mdlog, const gmx_moltype_t& moltype = mtop.moltype[molb.type]; const int a_start = a_end; a_end = a_start + molb.nmol * moltype.atoms.nr; - const gmx::Range atomRange(a_start, a_end); + const Range atomRange(a_start, a_end); auto warning = printMissingInteractionsMolblock( cr, @@ -251,8 +252,8 @@ static void printMissingInteractionsAtoms(const gmx::MDLogger& mdlog, } /*! \brief Print error output when interactions are missing */ -[[noreturn]] static void dd_print_missing_interactions(const gmx::MDLogger& mdlog, - t_commrec* cr, +[[noreturn]] static void dd_print_missing_interactions(const MDLogger& mdlog, + const t_commrec* cr, const int numBondedInteractionsOverAllDomains, const int expectedNumGlobalBondedInteractions, const gmx_mtop_t& top_global, @@ -330,7 +331,7 @@ static void printMissingInteractionsAtoms(const gmx::MDLogger& mdlog, } else { - errorMessage = gmx::formatString( + errorMessage = formatString( "%d of the %d bonded interactions could not be calculated because some atoms " "involved moved further apart than the multi-body cut-off distance (%g nm) or the " "two-body cut-off distance (%g nm), see option -rdd, for pairs and tabulated bonds " @@ -343,8 +344,50 @@ static void printMissingInteractionsAtoms(const gmx::MDLogger& mdlog, gmx_fatal_collective(FARGS, cr->mpi_comm_mygroup, MASTER(cr), "%s", errorMessage.c_str()); } -namespace gmx +/*! \brief Data to help check local 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. */ +class LocalTopologyChecker::Impl { +public: + //! Constructor + Impl(const MDLogger& mdlog, const t_commrec* cr, const gmx_mtop_t& mtop, bool useUpdateGroups); + + //! Objects used when reporting that interactions are missing + //! { + //! Logger + const MDLogger& mdlog_; + //! Communication record + const t_commrec* cr_; + //! Global system topology + const gmx_mtop_t& mtop_; + //! } + + /*! \brief Number of bonded interactions found in the local + * topology for this domain. */ + int numBondedInteractionsToReduce_ = 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 local 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 numBondedInteractionsOverAllDomains_; + //! The number of bonded interactions computed from the full system topology + int expectedNumGlobalBondedInteractions_ = 0; +}; + /*! \brief Compute the total bonded interaction count * @@ -366,74 +409,90 @@ static int computeExpectedNumGlobalBondedInteractions(const gmx_mtop_t& mtop, co return expectedNumGlobalBondedInteractions; } -LocalTopologyChecker::LocalTopologyChecker(const gmx_mtop_t& mtop, const bool useUpdateGroups) : - expectedNumGlobalBondedInteractions(computeExpectedNumGlobalBondedInteractions(mtop, useUpdateGroups)) +LocalTopologyChecker::Impl::Impl(const MDLogger& mdlog, + const t_commrec* cr, + const gmx_mtop_t& mtop, + const bool useUpdateGroups) : + mdlog_(mdlog), + cr_(cr), + mtop_(mtop), + expectedNumGlobalBondedInteractions_(computeExpectedNumGlobalBondedInteractions(mtop, useUpdateGroups)) { } -} // namespace gmx +LocalTopologyChecker::LocalTopologyChecker(const MDLogger& mdlog, + const t_commrec* cr, + const gmx_mtop_t& mtop, + const bool useUpdateGroups) : + impl_(std::make_unique(mdlog, cr, mtop, useUpdateGroups)) +{ +} + +LocalTopologyChecker::~LocalTopologyChecker() = default; -void scheduleCheckOfLocalTopology(gmx_domdec_t* dd, const int numBondedInteractionsToReduce) +LocalTopologyChecker::LocalTopologyChecker(LocalTopologyChecker&&) noexcept = default; + +LocalTopologyChecker& LocalTopologyChecker::operator=(LocalTopologyChecker&& other) noexcept { - dd->localTopologyChecker->numBondedInteractionsToReduce = numBondedInteractionsToReduce; + impl_ = std::move(other.impl_); + return *this; +} + +void LocalTopologyChecker::scheduleCheckOfLocalTopology(const int numBondedInteractionsToReduce) +{ + impl_->numBondedInteractionsToReduce_ = numBondedInteractionsToReduce; // 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->localTopologyChecker->shouldCheckNumberOfBondedInteractions = true; + impl_->shouldCheckNumberOfBondedInteractions_ = true; // Clear the old global value, which is now invalid - dd->localTopologyChecker->numBondedInteractionsOverAllDomains.reset(); + impl_->numBondedInteractionsOverAllDomains_.reset(); } -bool shouldCheckNumberOfBondedInteractions(const gmx_domdec_t& dd) +bool LocalTopologyChecker::shouldCheckNumberOfBondedInteractions() const { - return dd.localTopologyChecker->shouldCheckNumberOfBondedInteractions; + return impl_->shouldCheckNumberOfBondedInteractions_; } -int numBondedInteractions(const gmx_domdec_t& dd) +int LocalTopologyChecker::numBondedInteractions() const { - return dd.localTopologyChecker->numBondedInteractionsToReduce; + return impl_->numBondedInteractionsToReduce_; } -void setNumberOfBondedInteractionsOverAllDomains(gmx_domdec_t* dd, int newValue) +void LocalTopologyChecker::setNumberOfBondedInteractionsOverAllDomains(const int newValue) { - GMX_RELEASE_ASSERT(!dd->localTopologyChecker->numBondedInteractionsOverAllDomains.has_value(), + GMX_RELEASE_ASSERT(!impl_->numBondedInteractionsOverAllDomains_.has_value(), "Cannot set number of bonded interactions because it is already set"); - dd->localTopologyChecker->numBondedInteractionsOverAllDomains.emplace(newValue); + 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, - ArrayRef x, - const matrix box) +void LocalTopologyChecker::checkNumberOfBondedInteractions(const gmx_localtop_t* top_local, + ArrayRef 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->localTopologyChecker->shouldCheckNumberOfBondedInteractions) + if (impl_->shouldCheckNumberOfBondedInteractions_) { - GMX_RELEASE_ASSERT(cr->dd->localTopologyChecker->numBondedInteractionsOverAllDomains.has_value(), + GMX_RELEASE_ASSERT(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->localTopologyChecker->numBondedInteractionsOverAllDomains.value() - != cr->dd->localTopologyChecker->expectedNumGlobalBondedInteractions) + if (impl_->numBondedInteractionsOverAllDomains_.value() != impl_->expectedNumGlobalBondedInteractions_) { - dd_print_missing_interactions( - mdlog, - cr, - cr->dd->localTopologyChecker->numBondedInteractionsOverAllDomains.value(), - cr->dd->localTopologyChecker->expectedNumGlobalBondedInteractions, - top_global, - top_local, - x, - box); // Does not return + dd_print_missing_interactions(impl_->mdlog_, + impl_->cr_, + impl_->numBondedInteractionsOverAllDomains_.value(), + impl_->expectedNumGlobalBondedInteractions_, + impl_->mtop_, + 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->localTopologyChecker->shouldCheckNumberOfBondedInteractions = false; + impl_->shouldCheckNumberOfBondedInteractions_ = false; } } + +} // namespace gmx diff --git a/src/gromacs/domdec/localtopologychecker.h b/src/gromacs/domdec/localtopologychecker.h index 69b3a2e3bd..49766aa35e 100644 --- a/src/gromacs/domdec/localtopologychecker.h +++ b/src/gromacs/domdec/localtopologychecker.h @@ -44,11 +44,10 @@ #ifndef GMX_DOMDEC_LOCALTOPOLOGYCHECKER_H #define GMX_DOMDEC_LOCALTOPOLOGYCHECKER_H -#include +#include #include "gromacs/math/vectypes.h" -struct gmx_domdec_t; struct gmx_localtop_t; struct gmx_mtop_t; struct t_commrec; @@ -59,79 +58,70 @@ namespace gmx class MDLogger; template class ArrayRef; -enum class DDBondedChecking : bool; } // namespace gmx namespace gmx { -struct LocalTopologyChecker +/*! \brief Has responsibility for checking that the local topology + * distributed across domains describes a total number of bonded + * interactions that matches the system topology + * + * Because this check is not urgent, the communication that it + * requires is done at the next opportunity, rather than requiring + * extra communication. If the check fails, a fatal error stops + * execution. In principle, if there was a bug, GROMACS might crash in + * the meantime because of the wrong forces. However as a bug is + * unlikely, we optimize by avoiding creating extra overhead from + * communication. + */ +class LocalTopologyChecker { public: - //! Constructor - LocalTopologyChecker(const gmx_mtop_t& mtop, bool useUpdateGroups); - /*! \brief Data to help check local 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 local - * topology for this domain. */ - int numBondedInteractionsToReduce = 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 local 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 numBondedInteractionsOverAllDomains; - //! The number of bonded interactions computed from the full system topology - int expectedNumGlobalBondedInteractions = 0; - /*! \} */ -}; + /*! \brief Constructor + * \param[in] mdlog Logger + * \param[in] cr Communication object + * \param[in] mtop Global system topology + * \param[in] useUpdateGroups Whether update groups are in use + */ + LocalTopologyChecker(const MDLogger& mdlog, const t_commrec* cr, const gmx_mtop_t& mtop, bool useUpdateGroups); + //! Destructor + ~LocalTopologyChecker(); + //! Move constructor + LocalTopologyChecker(LocalTopologyChecker&& other) noexcept; + //! Move assignment + LocalTopologyChecker& operator=(LocalTopologyChecker&& other) noexcept; -} // namespace gmx + /*! \brief Set that the local topology should be checked via + * observables reduction whenever that reduction is required by + * another module. */ + void scheduleCheckOfLocalTopology(int numBondedInteractionsToReduce); -//! Set that the local topology should be checked via observables reduction -void scheduleCheckOfLocalTopology(gmx_domdec_t* dd, int numBondedInteractionsToReduce); + /*! \brief Return whether the total bonded interaction count across + * domains should be checked in observables reduction this step. */ + bool shouldCheckNumberOfBondedInteractions() const; -/*! \brief Return whether the total bonded interaction count across - * domains should be checked in observables reduction. */ -bool shouldCheckNumberOfBondedInteractions(const gmx_domdec_t& dd); + //! Return the number of bonded interactions in this domain. + int numBondedInteractions() const; -//! 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(int newValue); -/*! \brief Set total bonded interaction count across domains. */ -void setNumberOfBondedInteractionsOverAllDomains(gmx_domdec_t* dd, int newValue); + /*! \brief Check whether bonded interactions are missing from the reverse topology + * produced by domain decomposition. + * + * \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_localtop_t* top_local, + ArrayRef x, + const matrix box); -/*! \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 x, - const matrix box); +private: + class Impl; + std::unique_ptr impl_; +}; +} // namespace gmx #endif diff --git a/src/gromacs/domdec/partition.cpp b/src/gromacs/domdec/partition.cpp index 46cef19234..7dca75dc80 100644 --- a/src/gromacs/domdec/partition.cpp +++ b/src/gromacs/domdec/partition.cpp @@ -3208,7 +3208,7 @@ void dd_partition_system(FILE* fplog, state_local->x, top_global, top_local); - scheduleCheckOfLocalTopology(dd, numBondedInteractionsToReduce); + dd->localTopologyChecker->scheduleCheckOfLocalTopology(numBondedInteractionsToReduce); wallcycle_sub_stop(wcycle, WallCycleSubCounter::DDMakeTop); diff --git a/src/gromacs/mdlib/stat.cpp b/src/gromacs/mdlib/stat.cpp index 83ff1665da..c7e47c267f 100644 --- a/src/gromacs/mdlib/stat.cpp +++ b/src/gromacs/mdlib/stat.cpp @@ -276,7 +276,7 @@ void global_stat(const gmx_global_stat& gs, GMX_RELEASE_ASSERT(DOMAINDECOMP(cr), "No need to check number of bonded interactions when not using domain " "decomposition"); - nb = numBondedInteractions(*cr->dd); + nb = cr->dd->localTopologyChecker->numBondedInteractions(); inb = add_bind(rb, 1, &nb); } if (!sig.empty()) @@ -374,7 +374,7 @@ void global_stat(const gmx_global_stat& gs, GMX_RELEASE_ASSERT(DOMAINDECOMP(cr), "No need to check number of bonded interactions when not using domain " "decomposition"); - setNumberOfBondedInteractionsOverAllDomains(cr->dd, gmx::roundToInt(nb)); + cr->dd->localTopologyChecker->setNumberOfBondedInteractionsOverAllDomains(gmx::roundToInt(nb)); } if (!sig.empty()) diff --git a/src/gromacs/mdlib/update_vv.cpp b/src/gromacs/mdlib/update_vv.cpp index e1738b5285..f29eabb926 100644 --- a/src/gromacs/mdlib/update_vv.cpp +++ b/src/gromacs/mdlib/update_vv.cpp @@ -82,7 +82,6 @@ void integrateVVFirstStep(int64_t step, 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, @@ -109,7 +108,6 @@ void integrateVVFirstStep(int64_t step, gmx::SimulationSignaller* nullSignaller, gmx::EnumerationArray> trotter_seq, t_nrnb* nrnb, - const gmx::MDLogger& mdlog, FILE* fplog, gmx_wallcycle* wcycle) { @@ -192,7 +190,7 @@ void integrateVVFirstStep(int64_t step, ((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)) + if (DOMAINDECOMP(cr) && dd_localTopologyChecker(*cr->dd).shouldCheckNumberOfBondedInteractions()) { cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS; } @@ -227,8 +225,8 @@ void integrateVVFirstStep(int64_t step, EkinAveVel because it's needed for the pressure */ if (DOMAINDECOMP(cr)) { - checkNumberOfBondedInteractions( - mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box); + dd_localTopologyChecker(cr->dd)->checkNumberOfBondedInteractions( + &top, makeConstArrayRef(state->x), state->box); } if (bStopCM) { diff --git a/src/gromacs/mdlib/update_vv.h b/src/gromacs/mdlib/update_vv.h index f900c470ab..50ebbda78f 100644 --- a/src/gromacs/mdlib/update_vv.h +++ b/src/gromacs/mdlib/update_vv.h @@ -89,7 +89,6 @@ enum class StartingBehavior : int; * \param[in] fcdata Force calculation data. * \param[in] MassQ Mass/pressure data. * \param[in] vcm Center of mass motion removal. - * \param[in] top_global Global topology. * \param[in] top Local topology. * \param[in] enerd Energy data. * \param[in] ekind Kinetic energy data. @@ -116,7 +115,6 @@ enum class StartingBehavior : int; * \param[in] nullSignaller Simulation signaller. * \param[in] trotter_seq NPT variables. * \param[in] nrnb Cycle counters. - * \param[in] mdlog Logger. * \param[in] fplog Another logger. * \param[in] wcycle Wall-clock cycle counter. */ @@ -133,7 +131,6 @@ void integrateVVFirstStep(int64_t step, 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, @@ -160,7 +157,6 @@ void integrateVVFirstStep(int64_t step, gmx::SimulationSignaller* nullSignaller, gmx::EnumerationArray> trotter_seq, t_nrnb* nrnb, - const gmx::MDLogger& mdlog, FILE* fplog, gmx_wallcycle* wcycle); diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index a7d344c4a0..80a820784d 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -662,7 +662,8 @@ void gmx::LegacySimulator::do_md() cglo_flags_iteration |= CGLO_STOPCM; cglo_flags_iteration &= ~CGLO_TEMPERATURE; } - if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd) && cgloIteration == 0) + if (DOMAINDECOMP(cr) && dd_localTopologyChecker(*cr->dd).shouldCheckNumberOfBondedInteractions() + && cgloIteration == 0) { cglo_flags_iteration |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS; } @@ -702,8 +703,8 @@ void gmx::LegacySimulator::do_md() } if (DOMAINDECOMP(cr)) { - checkNumberOfBondedInteractions( - mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box); + dd_localTopologyChecker(cr->dd)->checkNumberOfBondedInteractions( + &top, makeConstArrayRef(state->x), state->box); } if (ir->eI == IntegrationAlgorithm::VVAK) { @@ -1057,7 +1058,7 @@ void gmx::LegacySimulator::do_md() * 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)) + if (DOMAINDECOMP(cr) && dd_localTopologyChecker(*cr->dd).shouldCheckNumberOfBondedInteractions()) { cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS; } @@ -1085,8 +1086,8 @@ void gmx::LegacySimulator::do_md() cglo_flags); if (DOMAINDECOMP(cr)) { - checkNumberOfBondedInteractions( - mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box); + dd_localTopologyChecker(cr->dd)->checkNumberOfBondedInteractions( + &top, makeConstArrayRef(state->x), state->box); } } clear_mat(force_vir); @@ -1237,7 +1238,6 @@ void gmx::LegacySimulator::do_md() fcdata, &MassQ, &vcm, - top_global, top, enerd, ekind, @@ -1264,7 +1264,6 @@ void gmx::LegacySimulator::do_md() &nullSignaller, trotter_seq, nrnb, - mdlog, fplog, wcycle); if (vsite != nullptr && needVirtualVelocitiesThisStep) @@ -1718,13 +1717,13 @@ void gmx::LegacySimulator::do_md() | (!EI_VV(ir->eI) && bStopCM ? CGLO_STOPCM : 0) | (!EI_VV(ir->eI) ? CGLO_TEMPERATURE : 0) | (!EI_VV(ir->eI) ? CGLO_PRESSURE : 0) | CGLO_CONSTRAINT - | (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd) + | (DOMAINDECOMP(cr) && dd_localTopologyChecker(*cr->dd).shouldCheckNumberOfBondedInteractions() ? CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS : 0)); if (DOMAINDECOMP(cr)) { - checkNumberOfBondedInteractions( - mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box); + dd_localTopologyChecker(cr->dd)->checkNumberOfBondedInteractions( + &top, makeConstArrayRef(state->x), state->box); } if (!EI_VV(ir->eI) && bStopCM) { diff --git a/src/gromacs/mdrun/mimic.cpp b/src/gromacs/mdrun/mimic.cpp index b55f3cf550..5c6fa4debb 100644 --- a/src/gromacs/mdrun/mimic.cpp +++ b/src/gromacs/mdrun/mimic.cpp @@ -342,7 +342,7 @@ void gmx::LegacySimulator::do_mimic() { int cglo_flags = CGLO_GSTAT; - if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd)) + if (DOMAINDECOMP(cr) && dd_localTopologyChecker(*cr->dd).shouldCheckNumberOfBondedInteractions()) { cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS; } @@ -372,8 +372,8 @@ void gmx::LegacySimulator::do_mimic() cglo_flags); if (DOMAINDECOMP(cr)) { - checkNumberOfBondedInteractions( - mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box); + dd_localTopologyChecker(cr->dd)->checkNumberOfBondedInteractions( + &top, makeConstArrayRef(state->x), state->box); } } @@ -631,7 +631,7 @@ void gmx::LegacySimulator::do_mimic() SimulationSignaller signaller(&signals, cr, ms, doInterSimSignal, doIntraSimSignal); int cglo_flags = CGLO_GSTAT | CGLO_ENERGY; - if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd)) + if (DOMAINDECOMP(cr) && dd_localTopologyChecker(*cr->dd).shouldCheckNumberOfBondedInteractions()) { cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS; } @@ -659,8 +659,8 @@ void gmx::LegacySimulator::do_mimic() cglo_flags); if (DOMAINDECOMP(cr)) { - checkNumberOfBondedInteractions( - mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box); + dd_localTopologyChecker(cr->dd)->checkNumberOfBondedInteractions( + &top, makeConstArrayRef(state->x), state->box); } } diff --git a/src/gromacs/mdrun/rerun.cpp b/src/gromacs/mdrun/rerun.cpp index d0783eb775..407c0190f6 100644 --- a/src/gromacs/mdrun/rerun.cpp +++ b/src/gromacs/mdrun/rerun.cpp @@ -387,7 +387,7 @@ void gmx::LegacySimulator::do_rerun() { int cglo_flags = CGLO_GSTAT; - if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd)) + if (DOMAINDECOMP(cr) && dd_localTopologyChecker(*cr->dd).shouldCheckNumberOfBondedInteractions()) { cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS; } @@ -417,8 +417,8 @@ void gmx::LegacySimulator::do_rerun() cglo_flags); if (DOMAINDECOMP(cr)) { - checkNumberOfBondedInteractions( - mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box); + dd_localTopologyChecker(cr->dd)->checkNumberOfBondedInteractions( + &top, makeConstArrayRef(state->x), state->box); } } @@ -742,7 +742,7 @@ void gmx::LegacySimulator::do_rerun() SimulationSignaller signaller(&signals, cr, ms, doInterSimSignal, doIntraSimSignal); int cglo_flags = CGLO_GSTAT | CGLO_ENERGY; - if (DOMAINDECOMP(cr) && shouldCheckNumberOfBondedInteractions(*cr->dd)) + if (DOMAINDECOMP(cr) && dd_localTopologyChecker(*cr->dd).shouldCheckNumberOfBondedInteractions()) { cglo_flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS; } @@ -770,8 +770,8 @@ void gmx::LegacySimulator::do_rerun() cglo_flags); if (DOMAINDECOMP(cr)) { - checkNumberOfBondedInteractions( - mdlog, cr, top_global, &top, makeConstArrayRef(state->x), state->box); + dd_localTopologyChecker(cr->dd)->checkNumberOfBondedInteractions( + &top, makeConstArrayRef(state->x), state->box); } } diff --git a/src/gromacs/modularsimulator/computeglobalselement.cpp b/src/gromacs/modularsimulator/computeglobalselement.cpp index abfa5b3770..bd1d75a1c3 100644 --- a/src/gromacs/modularsimulator/computeglobalselement.cpp +++ b/src/gromacs/modularsimulator/computeglobalselement.cpp @@ -282,7 +282,7 @@ void ComputeGlobalsElement::compute(gmx::Step step, const auto* lastbox = useLastBox ? statePropagatorData_->constPreviousBox() : statePropagatorData_->constBox(); - if (DOMAINDECOMP(cr_) && shouldCheckNumberOfBondedInteractions(*cr_->dd)) + if (DOMAINDECOMP(cr_) && dd_localTopologyChecker(*cr_->dd).shouldCheckNumberOfBondedInteractions()) { flags |= CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS; } @@ -311,7 +311,7 @@ void ComputeGlobalsElement::compute(gmx::Step step, flags); if (DOMAINDECOMP(cr_)) { - checkNumberOfBondedInteractions(mdlog_, cr_, top_global_, localTopology_, x, box); + dd_localTopologyChecker(cr_->dd)->checkNumberOfBondedInteractions(localTopology_, x, box); } if (flags & CGLO_STOPCM && !isInit) { -- 2.22.0