From: Mark Abraham Date: Mon, 31 May 2021 10:14:22 +0000 (+0000) Subject: Move total bonded count to LocalTopologyChecker X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=0cb43a20aacdcc194c8f096c5f56f0b589e51356;p=alexxy%2Fgromacs.git Move total bonded count to LocalTopologyChecker --- diff --git a/src/gromacs/domdec/domdec.cpp b/src/gromacs/domdec/domdec.cpp index 2c648b83d4..b3532bd189 100644 --- a/src/gromacs/domdec/domdec.cpp +++ b/src/gromacs/domdec/domdec.cpp @@ -3020,7 +3020,8 @@ gmx_domdec_t* DomainDecompositionBuilder::Impl::build(LocalAtomSetManager* atomS dd->atomSets = atomSets; - dd->localTopologyChecker = std::make_unique(); + dd->localTopologyChecker = + std::make_unique(mtop_, dd->comm->systemInfo.useUpdateGroups); return dd; } diff --git a/src/gromacs/domdec/localtopologychecker.cpp b/src/gromacs/domdec/localtopologychecker.cpp index 15f7b4900a..0ffb8199de 100644 --- a/src/gromacs/domdec/localtopologychecker.cpp +++ b/src/gromacs/domdec/localtopologychecker.cpp @@ -253,7 +253,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, - int numBondedInteractionsOverAllDomains, + const int numBondedInteractionsOverAllDomains, + const int expectedNumGlobalBondedInteractions, const gmx_mtop_t& top_global, const gmx_localtop_t* top_local, ArrayRef x, @@ -267,8 +268,7 @@ static void printMissingInteractionsAtoms(const gmx::MDLogger& mdlog, "Not all bonded interactions have been properly assigned to the domain " "decomposition cells"); - const int ndiff_tot = numBondedInteractionsOverAllDomains - - dd->reverse_top->expectedNumGlobalBondedInteractions(); + const int ndiff_tot = numBondedInteractionsOverAllDomains - expectedNumGlobalBondedInteractions; for (int ftype = 0; ftype < F_NRE; ftype++) { @@ -281,7 +281,7 @@ static void printMissingInteractionsAtoms(const gmx::MDLogger& mdlog, if (DDMASTER(dd)) { GMX_LOG(mdlog.warning).appendText("A list of missing interactions:"); - int rest_global = dd->reverse_top->expectedNumGlobalBondedInteractions(); + int rest_global = expectedNumGlobalBondedInteractions; int rest = numBondedInteractionsOverAllDomains; for (int ftype = 0; ftype < F_NRE; ftype++) { @@ -336,13 +336,42 @@ static void printMissingInteractionsAtoms(const gmx::MDLogger& mdlog, "two-body cut-off distance (%g nm), see option -rdd, for pairs and tabulated bonds " "also see option -ddcheck", -ndiff_tot, - dd->reverse_top->expectedNumGlobalBondedInteractions(), + expectedNumGlobalBondedInteractions, dd_cutoff_multibody(dd), dd_cutoff_twobody(dd)); } gmx_fatal_collective(FARGS, cr->mpi_comm_mygroup, MASTER(cr), "%s", errorMessage.c_str()); } +namespace gmx +{ + +/*! \brief Compute the total bonded interaction count + * + * \param[in] mtop The global system topology + * \param[in] useUpdateGroups Whether update groups are in use + * + * When using domain decomposition without update groups, + * constraint-type interactions can be split across domains, and so we + * do not consider them in this correctness check. Otherwise, we + * include them. + */ +static int computeExpectedNumGlobalBondedInteractions(const gmx_mtop_t& mtop, const bool useUpdateGroups) +{ + int expectedNumGlobalBondedInteractions = gmx_mtop_interaction_count(mtop, IF_BOND); + if (useUpdateGroups) + { + expectedNumGlobalBondedInteractions += gmx_mtop_interaction_count(mtop, IF_CONSTRAINT); + } + return expectedNumGlobalBondedInteractions; +} + +LocalTopologyChecker::LocalTopologyChecker(const gmx_mtop_t& mtop, const bool useUpdateGroups) : + expectedNumGlobalBondedInteractions(computeExpectedNumGlobalBondedInteractions(mtop, useUpdateGroups)) +{ +} + +} // namespace gmx void scheduleCheckOfLocalTopology(gmx_domdec_t* dd, const int numBondedInteractionsToReduce) { @@ -390,12 +419,13 @@ void checkNumberOfBondedInteractions(const gmx::MDLogger& mdlog, "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->reverse_top->expectedNumGlobalBondedInteractions()) + != cr->dd->localTopologyChecker->expectedNumGlobalBondedInteractions) { dd_print_missing_interactions( mdlog, cr, cr->dd->localTopologyChecker->numBondedInteractionsOverAllDomains.value(), + cr->dd->localTopologyChecker->expectedNumGlobalBondedInteractions, top_global, top_local, x, diff --git a/src/gromacs/domdec/localtopologychecker.h b/src/gromacs/domdec/localtopologychecker.h index d202622223..69b3a2e3bd 100644 --- a/src/gromacs/domdec/localtopologychecker.h +++ b/src/gromacs/domdec/localtopologychecker.h @@ -68,6 +68,8 @@ namespace gmx struct 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. @@ -93,6 +95,8 @@ public: * 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; /*! \} */ }; diff --git a/src/gromacs/domdec/reversetopology.cpp b/src/gromacs/domdec/reversetopology.cpp index 0601c441f7..f733d6ad53 100644 --- a/src/gromacs/domdec/reversetopology.cpp +++ b/src/gromacs/domdec/reversetopology.cpp @@ -97,9 +97,6 @@ struct gmx_reverse_top_t::Impl //! \brief Intermolecular reverse ilist reverse_ilist_t ril_intermol; - //! 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 std::vector th_work; @@ -299,11 +296,6 @@ const reverse_ilist_t& gmx_reverse_top_t::interactionListForMoleculeType(int mol return impl_->ril_mt[moleculeType]; } -int gmx_reverse_top_t::expectedNumGlobalBondedInteractions() const -{ - return impl_->expectedNumGlobalBondedInteractions; -} - ArrayRef gmx_reverse_top_t::molblockIndices() const { return impl_->mbi; @@ -339,45 +331,13 @@ bool gmx_reverse_top_t::doSorting() const return impl_->ilsort != ilsortNO_FE; } -/*! \brief Compute the total bonded interaction count - * - * \param[in] mtop The global system topology - * \param[in] includeConstraints Whether constraint interactions are included in the count - * \param[in] includeSettles Whether settle interactions are included in the count - * - * When using domain decomposition without update groups, - * constraint-type interactions can be split across domains, and so we - * do not consider them in this correctness check. Otherwise, we - * include them. - */ -static int computeExpectedNumGlobalBondedInteractions(const gmx_mtop_t& mtop, - const bool includeConstraints, - const bool includeSettles) -{ - int expectedNumGlobalBondedInteractions = gmx_mtop_interaction_count(mtop, IF_BOND); - if (includeConstraints) - { - expectedNumGlobalBondedInteractions += - gmx_mtop_ftype_count(mtop, F_CONSTR) + gmx_mtop_ftype_count(mtop, F_CONSTRNC); - } - if (includeSettles) - { - expectedNumGlobalBondedInteractions += gmx_mtop_ftype_count(mtop, F_SETTLE); - } - return expectedNumGlobalBondedInteractions; -} - /*! \brief Generate the reverse topology */ gmx_reverse_top_t::Impl::Impl(const gmx_mtop_t& mtop, const bool useFreeEnergy, const ReverseTopOptions& reverseTopOptions) : options(reverseTopOptions), hasPositionRestraints(gmx_mtop_ftype_count(mtop, F_POSRES) + gmx_mtop_ftype_count(mtop, F_FBPOSRES) > 0), - bInterAtomicInteractions(mtop.bIntermolecularInteractions), - expectedNumGlobalBondedInteractions( - computeExpectedNumGlobalBondedInteractions(mtop, - reverseTopOptions.includeConstraints, - reverseTopOptions.includeSettles)) + bInterAtomicInteractions(mtop.bIntermolecularInteractions) { bInterAtomicInteractions = mtop.bIntermolecularInteractions; ril_mt.resize(mtop.moltype.size()); diff --git a/src/gromacs/domdec/reversetopology.h b/src/gromacs/domdec/reversetopology.h index 6e3b7c1f54..278a69f77a 100644 --- a/src/gromacs/domdec/reversetopology.h +++ b/src/gromacs/domdec/reversetopology.h @@ -140,9 +140,6 @@ public: //! Gets the interaction list for the given molecule type const reverse_ilist_t& interactionListForMoleculeType(int moleculeType) const; - //! Returns the total count of bonded interactions, used for checking partitioning - int expectedNumGlobalBondedInteractions() const; - //! Returns the molecule block indices gmx::ArrayRef molblockIndices() const; //! Returns whether the reverse topology describes intermolecular interactions