Unite the post-DD-partition update of the local topology
authorMark Abraham <mark.j.abraham@gmail.com>
Mon, 7 Jun 2021 13:35:19 +0000 (15:35 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 8 Jun 2021 06:06:30 +0000 (08:06 +0200)
Also simplify and clarify the implementation of doSorting

Removed ilsortFE_UNSORTED now that it is unused

Refs #4004

src/gromacs/domdec/localtopology.cpp
src/gromacs/domdec/localtopology.h
src/gromacs/domdec/mdsetup.cpp
src/gromacs/domdec/partition.cpp
src/gromacs/domdec/reversetopology.cpp
src/gromacs/domdec/reversetopology.h
src/gromacs/topology/idef.h

index dfe8f85703c616f54d8686bda76fa4e9dbfe7df1..0b8c76f659413ef4a481269849d899bb083ac1c6 100644 (file)
@@ -921,16 +921,17 @@ static int make_local_bondeds_excls(gmx_domdec_t*           dd,
     return numBondedInteractions;
 }
 
-int dd_make_local_top(gmx_domdec_t*        dd,
-                      gmx_domdec_zones_t*  zones,
-                      int                  npbcdim,
-                      matrix               box,
-                      rvec                 cellsize_min,
-                      const ivec           npulse,
-                      t_forcerec*          fr,
-                      ArrayRef<const RVec> coordinates,
-                      const gmx_mtop_t&    mtop,
-                      gmx_localtop_t*      ltop)
+int dd_make_local_top(gmx_domdec_t*                dd,
+                      gmx_domdec_zones_t*          zones,
+                      int                          npbcdim,
+                      matrix                       box,
+                      rvec                         cellsize_min,
+                      const ivec                   npulse,
+                      t_forcerec*                  fr,
+                      ArrayRef<const RVec>         coordinates,
+                      const gmx_mtop_t&            mtop,
+                      gmx::ArrayRef<const int64_t> atomInfo,
+                      gmx_localtop_t*              ltop)
 {
     real  rc = -1;
     ivec  rcheck;
@@ -1011,17 +1012,7 @@ int dd_make_local_top(gmx_domdec_t*        dd,
                                                                  &ltop->idef,
                                                                  &ltop->excls);
 
-    /* The ilist is not sorted yet,
-     * we can only do this when we have the charge arrays.
-     */
-    ltop->idef.ilsort = ilsortUNKNOWN;
-
-    return numBondedInteractionsToReduce;
-}
-
-void dd_sort_local_top(const gmx_domdec_t& dd, gmx::ArrayRef<const int64_t> atomInfo, gmx_localtop_t* ltop)
-{
-    if (dd.reverse_top->doSorting())
+    if (dd->reverse_top->doListedForcesSorting())
     {
         gmx_sort_ilist_fe(&ltop->idef, atomInfo);
     }
@@ -1029,4 +1020,6 @@ void dd_sort_local_top(const gmx_domdec_t& dd, gmx::ArrayRef<const int64_t> atom
     {
         ltop->idef.ilsort = ilsortNO_FE;
     }
+
+    return numBondedInteractionsToReduce;
 }
index 8a66ea43ed84515092fdfb51ac88521f5ef14bc6..14ca253442733b7f96409f7ae75c4876bdde0429 100644 (file)
@@ -71,9 +71,7 @@ int dd_make_local_top(struct gmx_domdec_t*           dd,
                       t_forcerec*                    fr,
                       gmx::ArrayRef<const gmx::RVec> coordinates,
                       const gmx_mtop_t&              top,
+                      gmx::ArrayRef<const int64_t>   atomInfo,
                       gmx_localtop_t*                ltop);
 
-/*! \brief Sort ltop->ilist when we are doing free energy. */
-void dd_sort_local_top(const gmx_domdec_t& dd, gmx::ArrayRef<const int64_t> atomInfo, gmx_localtop_t* ltop);
-
 #endif
index 1176ddb4e178650b9697c3a366fc38576cc20b5e..7ff47990f7dfd68d355cf33ce4e4fdb8af0d78c9 100644 (file)
@@ -108,11 +108,7 @@ void mdAlgorithmsSetupAtomData(const t_commrec*     cr,
              mdAtoms);
 
     t_mdatoms* mdatoms = mdAtoms->mdatoms();
-    if (usingDomDec)
-    {
-        dd_sort_local_top(*cr->dd, fr->atomInfo, top);
-    }
-    else
+    if (!usingDomDec)
     {
         gmx_mtop_generate_local_top(top_global, top, inputrec.efep != FreeEnergyPerturbationType::No);
     }
index 7dca75dc80ad03aa7315a1a9c56cb97fbc5c99c6..4ec9098b9385f9022e9aba90a717e0249be4a4dd 100644 (file)
@@ -3207,6 +3207,7 @@ void dd_partition_system(FILE*                     fplog,
                                                           fr,
                                                           state_local->x,
                                                           top_global,
+                                                          fr->atomInfo,
                                                           top_local);
     dd->localTopologyChecker->scheduleCheckOfLocalTopology(numBondedInteractionsToReduce);
 
index f733d6ad5395588792753f191a3c208d46a517e3..30ca66aa2dbb1ab431c9e34c180c7bcfc6bf4fc3 100644 (file)
@@ -87,8 +87,8 @@ struct gmx_reverse_top_t::Impl
     std::vector<reverse_ilist_t> ril_mt;
     //! \brief The size of ril_mt[?].index summed over all entries
     int ril_mt_tot_size = 0;
-    //! \brief The sorting state of bondeds for free energy
-    int ilsort = ilsortUNKNOWN;
+    //! \brief Whether listed-force interaction lists should be sorted for free energy
+    bool doListedForcesSorting;
     //! \brief molblock to global atom index for quick lookup of molblocks on atom index
     std::vector<MolblockIndices> mbi;
 
@@ -326,9 +326,9 @@ ArrayRef<thread_work_t> gmx_reverse_top_t::threadWorkObjects() const
     return impl_->th_work;
 }
 
-bool gmx_reverse_top_t::doSorting() const
+bool gmx_reverse_top_t::doListedForcesSorting() const
 {
-    return impl_->ilsort != ilsortNO_FE;
+    return impl_->doListedForcesSorting;
 }
 
 /*! \brief Generate the reverse topology */
@@ -376,14 +376,7 @@ gmx_reverse_top_t::Impl::Impl(const gmx_mtop_t&        mtop,
                 *mtop.intermolecular_ilist, &atoms_global, options, AtomLinkRule::FirstAtom, &ril_intermol);
     }
 
-    if (useFreeEnergy && gmx_mtop_bondeds_free_energy(&mtop))
-    {
-        ilsort = ilsortFE_UNSORTED;
-    }
-    else
-    {
-        ilsort = ilsortNO_FE;
-    }
+    doListedForcesSorting = useFreeEnergy && gmx_mtop_bondeds_free_energy(&mtop);
 
     /* Make a molblock index for fast searching */
     int i = 0;
index 278a69f77ae710f7447fdea1fa888bd839aced01..9cb998b259b2bc908d539e7bb11a6732d1fdf706 100644 (file)
@@ -152,8 +152,8 @@ public:
     bool hasPositionRestraints() const;
     //! Returns the per-thread working structures for making the local topology
     gmx::ArrayRef<thread_work_t> threadWorkObjects() const;
-    //! Returns whether the local topology interactions should be sorted
-    bool doSorting() const;
+    //! Returns whether the local topology listed-forces interactions should be sorted
+    bool doListedForcesSorting() const;
 
     //! Private implementation definition
     struct Impl;
index 84ba6e8a5839986204d001524b3464cdd773a253..7c68e2c606b629d4b5d540efde9f89bd1a8d71f4 100644 (file)
@@ -360,7 +360,6 @@ enum
 {
     ilsortUNKNOWN,
     ilsortNO_FE,
-    ilsortFE_UNSORTED,
     ilsortFE_SORTED
 };