Local atom set handling during simulations.
authorChristian Blau <cblau@gwdg.de>
Thu, 21 Jul 2016 11:45:30 +0000 (13:45 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 17 Jul 2018 13:12:56 +0000 (15:12 +0200)
Initializes and updates local atom sets in the do_md loop.

An instance of local atom sets manager is set up in do_md. Domain
decomposition triggers update to local atom indices.

Change-Id: I361ce33220c423cbce2e6af617dbc5164291ce0a

src/gromacs/domdec/domdec.cpp
src/gromacs/domdec/domdec.h
src/gromacs/domdec/domdec_struct.h
src/gromacs/mdrun/runner.cpp

index 60e6c0cb10aa6d23916171cd91285cf62b2e07b2..5e085bd240f5fb37cbebdf54e9ba4a303e5b0f0a 100644 (file)
@@ -54,6 +54,7 @@
 #include "gromacs/domdec/dlbtiming.h"
 #include "gromacs/domdec/domdec_network.h"
 #include "gromacs/domdec/ga2la.h"
+#include "gromacs/domdec/localatomsetmanager.h"
 #include "gromacs/ewald/pme.h"
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/fileio/pdbio.h"
@@ -4392,7 +4393,8 @@ gmx_domdec_t *init_domain_decomposition(FILE *fplog, t_commrec *cr,
                                         const gmx_mtop_t *mtop,
                                         const t_inputrec *ir,
                                         const matrix box,
-                                        gmx::ArrayRef<const gmx::RVec> xGlobal)
+                                        gmx::ArrayRef<const gmx::RVec> xGlobal,
+                                        gmx::LocalAtomSetManager *atomSets)
 {
     gmx_domdec_t      *dd;
 
@@ -4432,6 +4434,8 @@ gmx_domdec_t *init_domain_decomposition(FILE *fplog, t_commrec *cr,
 
     clear_dd_cycle_counts(dd);
 
+    dd->atomSets = atomSets;
+
     return dd;
 }
 
@@ -6821,6 +6825,12 @@ void dd_partition_system(FILE                *fplog,
         dd_make_local_swap_groups(dd, ir->swap);
     }
 
+    if (dd->atomSets != nullptr)
+    {
+        /* Update the local atom sets */
+        dd->atomSets->setIndicesInDomainDecomposition(*(dd->ga2la));
+    }
+
     /* Update the local atoms to be communicated via the IMD protocol if bIMD is TRUE. */
     dd_make_local_IMD_atoms(ir->bIMD, dd, ir->imd);
 
index 7e26ed2078ac362622c4957a000b481f90419fe3..927e5ea66056ef73016817515ef48ba2b2431335 100644 (file)
@@ -88,6 +88,7 @@ namespace gmx
 {
 class Constraints;
 class MDAtoms;
+class LocalAtomSetManager;
 } // namespace
 
 /*! \brief Returns the global topology atom number belonging to local atom index i.
@@ -210,7 +211,8 @@ init_domain_decomposition(FILE                           *fplog,
                           const gmx_mtop_t               *mtop,
                           const t_inputrec               *ir,
                           const matrix                    box,
-                          gmx::ArrayRef<const gmx::RVec>  xGlobal);
+                          gmx::ArrayRef<const gmx::RVec>  xGlobal,
+                          gmx::LocalAtomSetManager       *atomSets);
 
 /*! \brief Initialize data structures for bonded interactions */
 void dd_init_bondeds(FILE              *fplog,
index 453aab5e54426f626bc26fd982e209cbea4761a4..46acb3312629278360b47fe88d1690888e6926bc 100644 (file)
@@ -72,6 +72,11 @@ struct gmx_hash_t;
 struct gmx_pme_comm_n_box_t;
 struct gmx_reverse_top_t;
 
+namespace gmx
+{
+class LocalAtomSetManager;
+}
+
 typedef struct {
     int  j0;     /* j-zone start               */
     int  j1;     /* j-zone end                 */
@@ -206,6 +211,8 @@ struct gmx_domdec_t {
     /* The partioning count, to keep track of the state */
     gmx_int64_t ddp_count;
 
+    /* The managed atom sets that are updated in domain decomposition */
+    gmx::LocalAtomSetManager * atomSets;
 
     /* gmx_pme_recv_f buffer */
     int   pme_recv_f_alloc = 0;
index b8533410badc058d273f30e7f4a0343cd3a1d3f4..f03491ce3493ec9b060d52c36d3d5fa323e259d4 100644 (file)
@@ -57,6 +57,7 @@
 #include "gromacs/commandline/filenm.h"
 #include "gromacs/domdec/domdec.h"
 #include "gromacs/domdec/domdec_struct.h"
+#include "gromacs/domdec/localatomsetmanager.h"
 #include "gromacs/ewald/ewald-utils.h"
 #include "gromacs/ewald/pme.h"
 #include "gromacs/ewald/pme-gpu-program.h"
@@ -814,13 +815,15 @@ int Mdrunner::mdrunner()
                               useGpuForNonbonded || (emulateGpuNonbonded == EmulateGpuNonbonded::Yes), *hwinfo->cpuInfo);
     }
 
-    /* Initalize the domain decomposition */
+    LocalAtomSetManager atomSets;
+
     if (PAR(cr) && !(EI_TPI(inputrec->eI) ||
                      inputrec->eI == eiNM))
     {
         cr->dd = init_domain_decomposition(fplog, cr, domdecOptions, mdrunOptions,
                                            &mtop, inputrec,
-                                           box, positionsFromStatePointer(globalState.get()));
+                                           box, positionsFromStatePointer(globalState.get()),
+                                           &atomSets);
         // Note that local state still does not exist yet.
     }
     else