Break up dd_init_bondeds
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 5 May 2021 08:55:48 +0000 (08:55 +0000)
committerJoe Jordan <ejjordan12@gmail.com>
Wed, 5 May 2021 08:55:48 +0000 (08:55 +0000)
admin/lsan-suppressions.txt
src/gromacs/domdec/domdec.cpp
src/gromacs/domdec/domdec.h
src/gromacs/domdec/domdec_topology.cpp
src/gromacs/mdrun/runner.cpp

index 14b6453d2418ac604eba3325c5e3185dbaf05df8..d064c4cbeaedddb363057db33aa245170bf70f49 100644 (file)
@@ -4,7 +4,8 @@ leak:add_to_list
 leak:atoms_to_constraints
 leak:atoms_to_settles
 leak:balance_fep_lists
-leak:dd_init_bondeds
+leak:dd_make_reverse_top
+leak:makeBondedLinks
 leak:dd_make_local_constraints
 leak:dd_move_f
 leak:dd_partition_system
index d684d8057e27002fe6b638bb87eddb725e42b0c8..346a09bf6df9bc03d3b1a80e8f800ca1bbe3f139 100644 (file)
@@ -2491,30 +2491,6 @@ static void set_dd_limits(const gmx::MDLogger& mdlog,
     }
 }
 
-void dd_init_bondeds(FILE*                           fplog,
-                     gmx_domdec_t*                   dd,
-                     const gmx_mtop_t&               mtop,
-                     const gmx::VirtualSitesHandler* vsite,
-                     const t_inputrec&               inputrec,
-                     const gmx::DDBondedChecking     ddBondedChecking,
-                     gmx::ArrayRef<cginfo_mb_t>      cginfo_mb)
-{
-    dd_make_reverse_top(fplog, dd, mtop, vsite, inputrec, ddBondedChecking);
-
-    gmx_domdec_comm_t* comm = dd->comm;
-
-    if (comm->systemInfo.filterBondedCommunication)
-    {
-        /* Communicate atoms beyond the cut-off for bonded interactions */
-        comm->bondedLinks = makeBondedLinks(mtop, cginfo_mb);
-    }
-    else
-    {
-        /* Only communicate atoms based on cut-off */
-        comm->bondedLinks = nullptr;
-    }
-}
-
 static void writeSettings(gmx::TextWriter*   log,
                           gmx_domdec_t*      dd,
                           const gmx_mtop_t&  mtop,
index 42883d1598c210fff34f9209c0ebbaaa09e3d845..f60c429b6ad1a09507663246f81fd3e5bc2d08ee 100644 (file)
@@ -72,8 +72,6 @@ struct gmx_ddbox_t;
 struct gmx_domdec_zones_t;
 struct gmx_localtop_t;
 struct gmx_mtop_t;
-struct t_block;
-struct t_blocka;
 struct t_commrec;
 struct t_forcerec;
 struct t_inputrec;
@@ -157,15 +155,6 @@ bool ddMayHaveSplitConstraints(const gmx_domdec_t& dd);
 /*! \brief Return whether update groups are used */
 bool ddUsesUpdateGroups(const gmx_domdec_t& dd);
 
-/*! \brief Initialize data structures for bonded interactions */
-void dd_init_bondeds(FILE*                           fplog,
-                     gmx_domdec_t*                   dd,
-                     const gmx_mtop_t&               mtop,
-                     const gmx::VirtualSitesHandler* vsite,
-                     const t_inputrec&               inputrec,
-                     gmx::DDBondedChecking           ddBondedChecking,
-                     gmx::ArrayRef<cginfo_mb_t>      cginfo_mb);
-
 /*! \brief Returns whether molecules are always whole, i.e. not broken by PBC */
 bool dd_moleculesAreAlwaysWhole(const gmx_domdec_t& dd);
 
@@ -326,7 +315,7 @@ void dd_init_local_state(const gmx_domdec_t& dd, const t_state* state_global, t_
  *
  * Also stores whether atoms are linked in \p cginfo_mb.
  */
-t_blocka* makeBondedLinks(const gmx_mtop_t& mtop, gmx::ArrayRef<cginfo_mb_t> cginfo_mb);
+void makeBondedLinks(gmx_domdec_t* dd, const gmx_mtop_t& mtop, gmx::ArrayRef<cginfo_mb_t> cginfo_mb);
 
 /*! \brief Calculate the maximum distance involved in 2-body and multi-body bonded interactions */
 void dd_bonded_cg_distance(const gmx::MDLogger&           mdlog,
index 5bacabd878df49d2723d1e25a6e98a1599272214..3a9f715cf40f11011599982dfeb40facdc0392e4 100644 (file)
@@ -1898,8 +1898,16 @@ static void check_link(t_blocka* link, int cg_gl, int cg_gl_j)
     }
 }
 
-t_blocka* makeBondedLinks(const gmx_mtop_t& mtop, gmx::ArrayRef<cginfo_mb_t> cginfo_mb)
+void makeBondedLinks(gmx_domdec_t* dd, const gmx_mtop_t& mtop, gmx::ArrayRef<cginfo_mb_t> cginfo_mb)
 {
+
+    if (!dd->comm->systemInfo.filterBondedCommunication)
+    {
+        /* Only communicate atoms based on cut-off */
+        dd->comm->bondedLinks = nullptr;
+        return;
+    }
+
     t_blocka* link = nullptr;
 
     /* For each atom make a list of other atoms in the system
@@ -2046,7 +2054,7 @@ t_blocka* makeBondedLinks(const gmx_mtop_t& mtop, gmx::ArrayRef<cginfo_mb_t> cgi
         fprintf(debug, "Of the %d atoms %d are linked via bonded interactions\n", mtop.natoms, ncgi);
     }
 
-    return link;
+    dd->comm->bondedLinks = link;
 }
 
 typedef struct
index e4c8c1ea787da1e3af5a07fe0aa8e904ce6d37c2..40c538a60a39753a425de922ac0f5f54fdf3bc0e 100644 (file)
@@ -1754,6 +1754,11 @@ int Mdrunner::mdrunner()
                 constructVirtualSitesGlobal(mtop, globalState->x);
             }
         }
+        // Make the DD reverse topology, now that any vsites that are present are available
+        if (DOMAINDECOMP(cr))
+        {
+            dd_make_reverse_top(fplog, cr->dd, mtop, vsite.get(), *inputrec, domdecOptions.ddBondedChecking);
+        }
 
         if (EEL_PME(fr->ic->eeltype) || EVDW_PME(fr->ic->vdwtype))
         {
@@ -1971,11 +1976,10 @@ int Mdrunner::mdrunner()
         if (DOMAINDECOMP(cr))
         {
             GMX_RELEASE_ASSERT(fr, "fr was NULL while cr->duty was DUTY_PP");
-            /* This call is not included in init_domain_decomposition mainly
+            /* This call is not included in init_domain_decomposition
              * because fr->cginfo_mb is set later.
              */
-            dd_init_bondeds(
-                    fplog, cr->dd, mtop, vsite.get(), *inputrec, domdecOptions.ddBondedChecking, fr->cginfo_mb);
+            makeBondedLinks(cr->dd, mtop, fr->cginfo_mb);
         }
 
         if (runScheduleWork.simulationWork.useGpuBufferOps)