Replace DOMAINDECOMP macro by a renamed function
authorBerk Hess <hess@kth.se>
Sat, 25 Sep 2021 13:13:11 +0000 (13:13 +0000)
committerMark Abraham <mark.j.abraham@gmail.com>
Sat, 25 Sep 2021 13:13:11 +0000 (13:13 +0000)
45 files changed:
src/gromacs/domdec/mdsetup.cpp
src/gromacs/ewald/pme.cpp
src/gromacs/ewald/pme_load_balancing.cpp
src/gromacs/ewald/pme_redistribute.cpp
src/gromacs/imd/imd.cpp
src/gromacs/listed_forces/disre.cpp
src/gromacs/mdlib/constr.cpp
src/gromacs/mdlib/coupling.cpp
src/gromacs/mdlib/force.cpp
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/lincs.cpp
src/gromacs/mdlib/mdoutf.cpp
src/gromacs/mdlib/resethandler.cpp
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdlib/simulationsignal.cpp
src/gromacs/mdlib/update.cpp
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/mimic.cpp
src/gromacs/mdrun/minimize.cpp
src/gromacs/mdrun/replicaexchange.cpp
src/gromacs/mdrun/rerun.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrun/shellfc.cpp
src/gromacs/mdtypes/commrec.h
src/gromacs/modularsimulator/andersentemperaturecoupling.cpp
src/gromacs/modularsimulator/domdechelper.cpp
src/gromacs/modularsimulator/expandedensembleelement.cpp
src/gromacs/modularsimulator/firstorderpressurecoupling.cpp
src/gromacs/modularsimulator/forceelement.cpp
src/gromacs/modularsimulator/freeenergyperturbationdata.cpp
src/gromacs/modularsimulator/mttk.cpp
src/gromacs/modularsimulator/nosehooverchains.cpp
src/gromacs/modularsimulator/parrinellorahmanbarostat.cpp
src/gromacs/modularsimulator/simulatoralgorithm.cpp
src/gromacs/modularsimulator/statepropagatordata.cpp
src/gromacs/modularsimulator/topologyholder.cpp
src/gromacs/modularsimulator/velocityscalingtemperaturecoupling.cpp
src/gromacs/nbnxm/nbnxm_setup.cpp
src/gromacs/nbnxm/pairlist_tuning.cpp
src/gromacs/pulling/pull.cpp
src/gromacs/pulling/pull_rotation.cpp
src/gromacs/pulling/pullutil.cpp
src/gromacs/restraint/restraintmdmodule.cpp
src/gromacs/restraint/restraintmdmodule_impl.h
src/gromacs/swap/swapcoords.cpp

index f6799a6c23dc81ec6b83e1f546638783bd1653ed..9aedfc1b830d8e697aa7744ef5e72901c9ab0ffc 100644 (file)
@@ -77,7 +77,7 @@ void mdAlgorithmsSetupAtomData(const t_commrec*     cr,
                                VirtualSitesHandler* vsite,
                                gmx_shellfc_t*       shellfc)
 {
-    bool usingDomDec = DOMAINDECOMP(cr);
+    bool usingDomDec = haveDDAtomOrdering(*cr);
 
     int numAtomIndex;
     int numHomeAtoms;
index 4260cac22ce5ea242dc28c3fa128e59d3f5a34df..7438077d0b26031ecaf055243eea06eb928dc27a 100644 (file)
@@ -1581,7 +1581,7 @@ int gmx_pme_do(struct gmx_pme_t*              pme,
             {
                 forcesRef = pme->atc[d + 1].f;
             }
-            if (DOMAINDECOMP(cr))
+            if (haveDDAtomOrdering(*cr))
             {
                 dd_pmeredist_f(pme, &pme->atc[d], forcesRef, d == pme->ndecompdim - 1 && pme->bPPnode);
             }
index 52aaeb98621fec1c374449e8d60aa92cf1072448..3292d9b0b344aa09d0b699d33de88339fdd42be5 100644 (file)
@@ -306,7 +306,7 @@ void pme_loadbal_init(pme_load_balancing_t**     pme_lb_p,
     pme_lb->cycles_n = 0;
     pme_lb->cycles_c = 0;
     // only master ranks do timing
-    if (!PAR(cr) || (DOMAINDECOMP(cr) && DDMASTER(cr->dd)))
+    if (!PAR(cr) || (haveDDAtomOrdering(*cr) && DDMASTER(cr->dd)))
     {
         pme_lb->startTime = gmx_gettime();
     }
@@ -335,7 +335,7 @@ void pme_loadbal_init(pme_load_balancing_t**     pme_lb_p,
     pme_lb->step_rel_stop = PMETunePeriod * ir.nstlist;
 
     /* Delay DD load balancing when GPUs are used */
-    if (pme_lb->bActive && DOMAINDECOMP(cr) && cr->dd->nnodes > 1 && bUseGPU)
+    if (pme_lb->bActive && haveDDAtomOrdering(*cr) && cr->dd->nnodes > 1 && bUseGPU)
     {
         /* Lock DLB=auto to off (does nothing when DLB=yes/no.
          * With GPUs and separate PME nodes, we want to first
@@ -651,7 +651,7 @@ static void pme_load_balance(pme_load_balancing_t*          pme_lb,
     {
         pme_lb->fastest = pme_lb->cur;
 
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             /* We found a new fastest setting, ensure that with subsequent
              * shorter cut-off's the dynamic load balancing does not make
@@ -726,7 +726,7 @@ static void pme_load_balance(pme_load_balancing_t*          pme_lb,
             {
                 pme_lb->cur++;
 
-                if (DOMAINDECOMP(cr))
+                if (haveDDAtomOrdering(*cr))
                 {
                     OK = change_dd_cutoff(cr, box, x, pme_lb->setup[pme_lb->cur].rlistOuter);
                     if (!OK)
@@ -793,7 +793,7 @@ static void pme_load_balance(pme_load_balancing_t*          pme_lb,
         }
     }
 
-    if (DOMAINDECOMP(cr) && pme_lb->stage > 0)
+    if (haveDDAtomOrdering(*cr) && pme_lb->stage > 0)
     {
         OK = change_dd_cutoff(cr, box, x, pme_lb->setup[pme_lb->cur].rlistOuter);
         if (!OK)
@@ -960,11 +960,11 @@ void pme_loadbal_do(pme_load_balancing_t*          pme_lb,
      * We also want to skip a number of steps and seconds while
      * the CPU and GPU, when used, performance stabilizes.
      */
-    if (!PAR(cr) || (DOMAINDECOMP(cr) && DDMASTER(cr->dd)))
+    if (!PAR(cr) || (haveDDAtomOrdering(*cr) && DDMASTER(cr->dd)))
     {
         pme_lb->startupTimeDelayElapsed = (gmx_gettime() - pme_lb->startTime < c_startupTimeDelay);
     }
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_bcast(cr->dd, sizeof(bool), &pme_lb->startupTimeDelayElapsed);
     }
@@ -997,7 +997,7 @@ void pme_loadbal_do(pme_load_balancing_t*          pme_lb,
          */
         else if (step_rel >= c_numFirstTuningIntervalSkipWithSepPme * ir.nstlist)
         {
-            GMX_ASSERT(DOMAINDECOMP(cr), "Domain decomposition should be active here");
+            GMX_ASSERT(haveDDAtomOrdering(*cr), "Domain decomposition should be active here");
             if (DDMASTER(cr->dd))
             {
                 /* If PME rank load is too high, start tuning. If
@@ -1027,7 +1027,7 @@ void pme_loadbal_do(pme_load_balancing_t*          pme_lb,
     {
         pme_lb->bBalance = FALSE;
 
-        if (DOMAINDECOMP(cr) && dd_dlb_is_locked(cr->dd))
+        if (haveDDAtomOrdering(*cr) && dd_dlb_is_locked(cr->dd))
         {
             /* Unlock the DLB=auto, DLB is allowed to activate */
             dd_dlb_unlock(cr->dd);
@@ -1048,7 +1048,7 @@ void pme_loadbal_do(pme_load_balancing_t*          pme_lb,
             pme_lb->bActive = FALSE;
         }
 
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             /* Set the cut-off limit to the final selected cut-off,
              * so we don't have artificial DLB limits.
@@ -1096,7 +1096,7 @@ void pme_loadbal_do(pme_load_balancing_t*          pme_lb,
         pme_lb->bActive = FALSE;
     }
 
-    if (!(pme_lb->bActive) && DOMAINDECOMP(cr) && dd_dlb_is_locked(cr->dd))
+    if (!(pme_lb->bActive) && haveDDAtomOrdering(*cr) && dd_dlb_is_locked(cr->dd))
     {
         /* Make sure DLB is allowed when we deactivate PME tuning */
         dd_dlb_unlock(cr->dd);
index 9fdea71a55f7cf84e3257e5d2c8e4936c1763759..96c994b578733cf89f0bfb82e18e4f20d40ea95f 100644 (file)
@@ -497,7 +497,7 @@ void do_redist_pos_coeffs(struct gmx_pme_t*              pme,
         atc.pd.resize(xRef.size());
         pme_calc_pidx_wrapper(xRef, pme->recipbox, &atc);
         /* Redistribute x (only once) and qA/c6A or qB/c6B */
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             dd_pmeredist_pos_coeffs(pme, bFirst, xRef, param_d, &atc);
         }
index 7d0cef345cc04697934f42cdbd15d35524d1b2dc..41a999c414a8cbcb584e50bad8ad4c640af0c1a7 100644 (file)
@@ -1268,7 +1268,7 @@ void ImdSession::Impl::prepareForPositionAssembly(const t_commrec* cr, gmx::Arra
         }
     }
 
-    if (!DOMAINDECOMP(cr))
+    if (!haveDDAtomOrdering(*cr))
     {
         nat_loc = nat;
         ind_loc = ind;
index 34a2627bd0b1ead3aa3e0d9afcb75afb035d9cfa..5091d16f57d69364e6a8cb10c10cbf97f011d13a 100644 (file)
@@ -378,7 +378,7 @@ void calc_disres_R_6(const t_commrec*      cr,
     }
 
     /* NOTE: Rt_6 and Rtav_6 are stored consecutively in memory */
-    if (cr && DOMAINDECOMP(cr))
+    if (cr && haveDDAtomOrdering(*cr))
     {
         gmx_sum(2 * dd->nres, dd->Rt_6, cr);
     }
@@ -397,7 +397,7 @@ void calc_disres_R_6(const t_commrec*      cr,
         GMX_ASSERT(cr != nullptr && ms != nullptr, "We need multisim with nsystems>1");
         gmx_sum_sim(2 * dd->nres, dd->Rt_6, ms);
 
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             gmx_bcast(2 * dd->nres, dd->Rt_6, cr->mpi_comm_mygroup);
         }
index 255dfb77a3528121ad8fa4a17f6cb018155e445f..798f4f12f1f7860a4f129556d5f0139e7a2bdc6e 100644 (file)
@@ -269,7 +269,7 @@ static void write_constr_pdb(const char*          fn,
     const char *  anm, *resnm;
 
     dd = nullptr;
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd = cr->dd;
         dd_get_constraint_range(*dd, &dd_ac0, &dd_ac1);
@@ -479,7 +479,8 @@ bool Constraints::Impl::apply(bool                      bLog,
          * by the constraint coordinate communication routine,
          * so that here we can use normal pbc.
          */
-        pbc_null = set_pbc_dd(&pbc, ir.pbcType, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, FALSE, box);
+        pbc_null = set_pbc_dd(
+                &pbc, ir.pbcType, haveDDAtomOrdering(*cr) ? cr->dd->numCells : nullptr, FALSE, box);
     }
     else
     {
@@ -1157,7 +1158,7 @@ Constraints::Impl::Impl(const gmx_mtop_t&     mtop_p,
         // When there are multiple PP domains and update groups are
         // not in use, the constraints might be split across the
         // domains, needing particular handling.
-        const bool mayHaveSplitConstraints = DOMAINDECOMP(cr) && !useUpdateGroups;
+        const bool mayHaveSplitConstraints = haveDDAtomOrdering(*cr) && !useUpdateGroups;
 
         if (ir.eConstrAlg == ConstraintAlgorithm::Lincs)
         {
index f280129898c0f783df8954a9201a58fb7cb55c63..a9ed66d6ac9fa5bdc77e4a8764aaf692ef0d5668 100644 (file)
@@ -1278,11 +1278,11 @@ void andersen_tcoupl(const t_inputrec*                   ir,
                      const std::vector<bool>&            randomize,
                      gmx::ArrayRef<const real>           boltzfac)
 {
-    const int*           gatindex = (DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr);
-    int                  i;
-    int                  gc = 0;
-    gmx::ThreeFry2x64<0> rng(ir->andersen_seed, gmx::RandomDomain::Thermostat);
-    gmx::UniformRealDistribution<real>         uniformDist;
+    const int* gatindex = (haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr);
+    int        i;
+    int        gc = 0;
+    gmx::ThreeFry2x64<0>               rng(ir->andersen_seed, gmx::RandomDomain::Thermostat);
+    gmx::UniformRealDistribution<real> uniformDist;
     gmx::TabulatedNormalDistribution<real, 14> normalDist;
 
     /* randomize the velocities of the selected particles */
index 4507dbc7bca45a9505946dd10a929cf75b36f4df..325d96e7cc7b088f3c453ebc60669278a6a3c329 100644 (file)
@@ -275,8 +275,8 @@ void CpuPpLongRangeNonbondeds::calculate(gmx_pme_t*                     pmedata,
                             sigmaB_,
                             box,
                             commrec,
-                            DOMAINDECOMP(commrec) ? dd_pme_maxshift_x(*commrec->dd) : 0,
-                            DOMAINDECOMP(commrec) ? dd_pme_maxshift_y(*commrec->dd) : 0,
+                            haveDDAtomOrdering(*commrec) ? dd_pme_maxshift_x(*commrec->dd) : 0,
+                            haveDDAtomOrdering(*commrec) ? dd_pme_maxshift_y(*commrec->dd) : 0,
                             nrnb_,
                             wcycle_,
                             ewaldOutput.vir_q,
index 166ff0860388875a83d9d114ce26b522ff7c07c9..4ed9daa5e1c293a4e77220dd201e4c3a63f0c322 100644 (file)
@@ -739,14 +739,15 @@ void init_forcerec(FILE*                            fplog,
     }
     else
     {
-        forcerec->bMolPBC = (!DOMAINDECOMP(commrec) || dd_bonded_molpbc(*commrec->dd, forcerec->pbcType));
+        forcerec->bMolPBC =
+                (!haveDDAtomOrdering(*commrec) || dd_bonded_molpbc(*commrec->dd, forcerec->pbcType));
 
         // Check and set up PBC for Ewald surface corrections or orientation restraints
         const bool useEwaldSurfaceCorrection =
                 (EEL_PME_EWALD(inputrec.coulombtype) && inputrec.epsilon_surface != 0);
         const bool haveOrientationRestraints = (gmx_mtop_ftype_count(mtop, F_ORIRES) > 0);
         const bool moleculesAreAlwaysWhole =
-                (DOMAINDECOMP(commrec) && dd_moleculesAreAlwaysWhole(*commrec->dd));
+                (haveDDAtomOrdering(*commrec) && dd_moleculesAreAlwaysWhole(*commrec->dd));
         // WholeMoleculeTransform is only supported with a single PP rank
         if (!moleculesAreAlwaysWhole && !havePPDomainDecomposition(commrec)
             && (useEwaldSurfaceCorrection || haveOrientationRestraints))
@@ -761,10 +762,11 @@ void init_forcerec(FILE*                            fplog,
             }
 
             forcerec->wholeMoleculeTransform = std::make_unique<gmx::WholeMoleculeTransform>(
-                    mtop, inputrec.pbcType, DOMAINDECOMP(commrec));
+                    mtop, inputrec.pbcType, haveDDAtomOrdering(*commrec));
         }
 
-        forcerec->bMolPBC = !DOMAINDECOMP(commrec) || dd_bonded_molpbc(*commrec->dd, forcerec->pbcType);
+        forcerec->bMolPBC =
+                !haveDDAtomOrdering(*commrec) || dd_bonded_molpbc(*commrec->dd, forcerec->pbcType);
 
         if (useEwaldSurfaceCorrection)
         {
@@ -1051,12 +1053,12 @@ void init_forcerec(FILE*                            fplog,
 
     /* Set all the static charge group info */
     forcerec->atomInfoForEachMoleculeBlock = makeAtomInfoForEachMoleculeBlock(mtop, forcerec);
-    if (!DOMAINDECOMP(commrec))
+    if (!haveDDAtomOrdering(*commrec))
     {
         forcerec->atomInfo = expandAtomInfo(mtop.molblock.size(), forcerec->atomInfoForEachMoleculeBlock);
     }
 
-    if (!DOMAINDECOMP(commrec))
+    if (!haveDDAtomOrdering(*commrec))
     {
         forcerec_set_ranges(forcerec, mtop.natoms, mtop.natoms, mtop.natoms);
     }
index a6ff2e0477b85831b66ae08caf92b51593bebfe9..bc476f1d7d2f16be0635db1e6218ce6d1129b156 100644 (file)
@@ -1099,13 +1099,13 @@ static void do_lincs(ArrayRefWithPadding<const RVec> xPadded,
 
     for (int iter = 0; iter < lincsd->nIter; iter++)
     {
-        if ((lincsd->bCommIter && DOMAINDECOMP(cr) && cr->dd->constraints))
+        if ((lincsd->bCommIter && haveDDAtomOrdering(*cr) && cr->dd->constraints))
         {
 #pragma omp barrier
 #pragma omp master
             {
                 /* Communicate the corrected non-local coordinates */
-                if (DOMAINDECOMP(cr))
+                if (haveDDAtomOrdering(*cr))
                 {
                     dd_move_x_constraints(cr->dd, box, xpPadded.unpaddedArrayRef(), ArrayRef<RVec>(), FALSE);
                 }
@@ -1894,7 +1894,7 @@ void set_lincs(const InteractionDefinitions& idef,
     }
 
     int natoms;
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         if (cr->dd->constraints)
         {
@@ -1928,7 +1928,7 @@ void set_lincs(const InteractionDefinitions& idef,
     li->blnr.resize(numEntries + 1);
     li->bllen.resize(numEntries);
     li->tmpv.resizeWithPadding(numEntries);
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         li->nlocat.resize(numEntries);
     }
@@ -2078,7 +2078,7 @@ void set_lincs(const InteractionDefinitions& idef,
     /* Without DD we order the blbnb matrix to optimize memory access.
      * With DD the overhead of sorting is more than the gain during access.
      */
-    bSortMatrix = !DOMAINDECOMP(cr);
+    bSortMatrix = !haveDDAtomOrdering(*cr);
 
     li->blbnb.resize(li->ncc);
 
index 3e0cc76354f6917ef06da9022d97d2c97f7b2845..ecf83d907e7e1780f1b009454f4bafd1cb06aa47 100644 (file)
@@ -235,7 +235,7 @@ gmx_mdoutf_t init_mdoutf(FILE*                          fplog,
             }
         }
 
-        if (ir->nstfout && DOMAINDECOMP(cr))
+        if (ir->nstfout && haveDDAtomOrdering(*cr))
         {
             snew(of->f_global, top_global.natoms);
         }
@@ -306,7 +306,7 @@ static void write_checkpoint(const char*                     fn,
     char      buf[1024], suffix[5 + STEPSTRSIZE], sbuf[STEPSTRSIZE];
     t_fileio* ret;
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         npmenodes = cr->npmenodes;
     }
@@ -387,7 +387,7 @@ static void write_checkpoint(const char*                     fn,
     std::strcpy(headerContents.version, gmx_version());
     std::strcpy(headerContents.fprog, gmx::getProgramContext().fullBinaryPath());
     std::strcpy(headerContents.ftime, timebuf.c_str());
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         copy_ivec(domdecCells, headerContents.dd_nc);
     }
@@ -512,8 +512,8 @@ void mdoutf_write_checkpoint(gmx_mdoutf_t                    of,
                      of->bKeepAndNumCPT,
                      fplog,
                      cr,
-                     DOMAINDECOMP(cr) ? cr->dd->numCells : one_ivec,
-                     DOMAINDECOMP(cr) ? cr->dd->nnodes : cr->nnodes,
+                     haveDDAtomOrdering(*cr) ? cr->dd->numCells : one_ivec,
+                     haveDDAtomOrdering(*cr) ? cr->dd->nnodes : cr->nnodes,
                      of->eIntegrator,
                      of->simulation_part,
                      of->bExpanded,
@@ -543,7 +543,7 @@ void mdoutf_write_to_trajectory_files(FILE*                           fplog,
 {
     const rvec* f_global;
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         if (mdof_flags & MDOF_CPT)
         {
index be4d76eea5d6f85fe300c36418934a8a7c601915..0a21d89c85af7d53255ca479e7d8358be2d406d1 100644 (file)
@@ -193,7 +193,7 @@ bool ResetHandler::resetCountersImpl(int64_t                     step,
 
         wallcycle_stop(wcycle, WallCycleCounter::Run);
         wallcycle_reset_all(wcycle);
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             reset_dd_statistics_counters(cr->dd);
         }
index 429b91c6b14497d44c9a9f760267047f3f912a0f..3882768ada0e9dcb72ec7ed6284fdaacc3bfbb0b 100644 (file)
@@ -1277,7 +1277,7 @@ void do_force(FILE*                               fplog,
         }
 
         const bool fillGrid = (stepWork.doNeighborSearch && stepWork.stateChanged);
-        const bool calcCGCM = (fillGrid && !DOMAINDECOMP(cr));
+        const bool calcCGCM = (fillGrid && !haveDDAtomOrdering(*cr));
         if (calcCGCM)
         {
             put_atoms_in_box_omp(fr->pbcType,
@@ -1394,7 +1394,7 @@ void do_force(FILE*                               fplog,
         }
 
         wallcycle_start(wcycle, WallCycleCounter::NS);
-        if (!DOMAINDECOMP(cr))
+        if (!haveDDAtomOrdering(*cr))
         {
             const rvec vzero       = { 0.0_real, 0.0_real, 0.0_real };
             const rvec boxDiagonal = { box[XX][XX], box[YY][YY], box[ZZ][ZZ] };
@@ -1704,7 +1704,7 @@ void do_force(FILE*                               fplog,
     /* Reset energies */
     reset_enerdata(enerd);
 
-    if (DOMAINDECOMP(cr) && simulationWork.haveSeparatePmeRank)
+    if (haveDDAtomOrdering(*cr) && simulationWork.haveSeparatePmeRank)
     {
         wallcycle_start(wcycle, WallCycleCounter::PpDuringPme);
         dd_force_flop_start(cr->dd, nrnb);
@@ -1911,7 +1911,7 @@ void do_force(FILE*                               fplog,
             /* Since all atoms are in the rectangular or triclinic unit-cell,
              * only single box vector shifts (2 in x) are required.
              */
-            set_pbc_dd(&pbc, fr->pbcType, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, TRUE, box);
+            set_pbc_dd(&pbc, fr->pbcType, haveDDAtomOrdering(*cr) ? cr->dd->numCells : nullptr, TRUE, box);
         }
 
         for (int mtsIndex = 0; mtsIndex < (simulationWork.useMts && stepWork.computeSlowForces ? 2 : 1);
@@ -1935,7 +1935,7 @@ void do_force(FILE*                               fplog,
                                    nrnb,
                                    lambda,
                                    mdatoms,
-                                   DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr,
+                                   haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr,
                                    stepWork);
         }
     }
@@ -2197,7 +2197,7 @@ void do_force(FILE*                               fplog,
                      enerd,
                      stepWork,
                      InteractionLocality::Local,
-                     DOMAINDECOMP(cr) ? enbvClearFNo : enbvClearFYes,
+                     haveDDAtomOrdering(*cr) ? enbvClearFNo : enbvClearFYes,
                      step,
                      nrnb,
                      wcycle);
@@ -2264,7 +2264,7 @@ void do_force(FILE*                               fplog,
             // NOTE: If there are virtual sites, the forces are modified on host after this D2H copy. Hence,
             //       they should not be copied in do_md(...) for the output.
             if (!simulationWork.useGpuUpdate
-                || (simulationWork.useGpuUpdate && DOMAINDECOMP(cr) && simulationWork.useCpuPmePpCommunication)
+                || (simulationWork.useGpuUpdate && haveDDAtomOrdering(*cr) && simulationWork.useCpuPmePpCommunication)
                 || vsite)
             {
                 stateGpu->copyForcesFromGpu(forceWithShift, AtomLocality::Local);
@@ -2281,7 +2281,7 @@ void do_force(FILE*                               fplog,
     launchGpuEndOfStepTasks(
             nbv, fr->listedForcesGpu.get(), fr->pmedata, enerd, *runScheduleWork, step, wcycle);
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_force_flop_stop(cr->dd, nrnb);
     }
index db0aec861c0a3d8350afa55dda6190e7d23f8f9d..fe0879e6d07ef0eb5dacd45245984b781e450625 100644 (file)
@@ -109,7 +109,7 @@ void SimulationSignaller::signalInterSim()
         // Communicate the signals between the simulations.
         gmx_sum_sim(eglsNR, mpiBuffer_.data(), ms_);
     }
-    if (DOMAINDECOMP(cr_))
+    if (haveDDAtomOrdering(*cr_))
     {
         // Communicate the signals from the master to the others.
         gmx_bcast(eglsNR * sizeof(mpiBuffer_[0]), mpiBuffer_.data(), cr_->mpi_comm_mygroup);
index 7bcbc656875d08056349498716ccf2ce5c64e033..800d68aa1d830587c6add17129fed533a4eb181c 100644 (file)
@@ -1176,22 +1176,23 @@ static void do_update_sd(int                                 start,
     }
     else
     {
-        doSDUpdateGeneral<SDUpdate::Combined>(sd,
-                                              start,
-                                              nrend,
-                                              dt,
-                                              nFreeze,
-                                              invmass,
-                                              ptype,
-                                              cFREEZE,
-                                              cTC,
-                                              x,
-                                              xprime,
-                                              v,
-                                              f,
-                                              step,
-                                              seed,
-                                              DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr);
+        doSDUpdateGeneral<SDUpdate::Combined>(
+                sd,
+                start,
+                nrend,
+                dt,
+                nFreeze,
+                invmass,
+                ptype,
+                cFREEZE,
+                cTC,
+                x,
+                xprime,
+                v,
+                f,
+                step,
+                seed,
+                haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr);
     }
 }
 
@@ -1431,7 +1432,7 @@ void Update::Impl::update_sd_second_half(const t_inputrec&                 input
                         nullptr,
                         step,
                         inputRecord.ld_seed,
-                        DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr);
+                        haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr);
             }
             GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
         }
@@ -1625,7 +1626,7 @@ void Update::Impl::update_coords(const t_inputrec&                 inputRecord,
                                  inputRecord.bd_fric,
                                  sd_.bd_rf.data(),
                                  inputRecord.ld_seed,
-                                 DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr);
+                                 haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr);
                     break;
                 case (IntegrationAlgorithm::VV):
                 case (IntegrationAlgorithm::VVAK):
index 3870f0fb92f79cb7e524ec2536e6a672fd419676..7a649b7b4a085e4c8b94e279649167b3939e31dc 100644 (file)
@@ -346,7 +346,7 @@ void gmx::LegacySimulator::do_md()
                                  top_global,
                                  constr ? constr->numFlexibleConstraints() : 0,
                                  ir->nstcalcenergy,
-                                 DOMAINDECOMP(cr),
+                                 haveDDAtomOrdering(*cr),
                                  useGpuForPme);
 
     {
@@ -364,7 +364,7 @@ void gmx::LegacySimulator::do_md()
                                ? PinningPolicy::PinnedIfSupported
                                : PinningPolicy::CannotBePinned);
     const t_mdatoms* md = mdAtoms->mdatoms();
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         // Local state only becomes valid now.
         dd_init_local_state(*cr->dd, state_global, state);
@@ -420,8 +420,8 @@ void gmx::LegacySimulator::do_md()
     // TODO: the assertions below should be handled by UpdateConstraintsBuilder.
     if (useGpuForUpdate)
     {
-        GMX_RELEASE_ASSERT(!DOMAINDECOMP(cr) || ddUsesUpdateGroups(*cr->dd) || constr == nullptr
-                                   || constr->numConstraintsTotal() == 0,
+        GMX_RELEASE_ASSERT(!haveDDAtomOrdering(*cr) || ddUsesUpdateGroups(*cr->dd)
+                                   || constr == nullptr || constr->numConstraintsTotal() == 0,
                            "Constraints in domain decomposition are only supported with update "
                            "groups if using GPU update.\n");
         GMX_RELEASE_ASSERT(ir->eConstrAlg != ConstraintAlgorithm::Shake || constr == nullptr
@@ -971,12 +971,12 @@ void gmx::LegacySimulator::do_md()
                     }
                 }
             }
-            if (DOMAINDECOMP(cr) && bMasterState)
+            if (haveDDAtomOrdering(*cr) && bMasterState)
             {
                 dd_collect_state(cr->dd, state, state_global);
             }
 
-            if (DOMAINDECOMP(cr))
+            if (haveDDAtomOrdering(*cr))
             {
                 /* Repartition the domain decomposition */
                 dd_partition_system(fplog,
@@ -1492,7 +1492,7 @@ void gmx::LegacySimulator::do_md()
         {
             if (useGpuForUpdate)
             {
-                if (bNS && (bFirstStep || DOMAINDECOMP(cr)))
+                if (bNS && (bFirstStep || haveDDAtomOrdering(*cr)))
                 {
                     integrator->set(stateGpu->getCoordinates(),
                                     stateGpu->getVelocities(),
@@ -1919,7 +1919,7 @@ void gmx::LegacySimulator::do_md()
                                              MASTER(cr) && mdrunOptions.verbose,
                                              bRerunMD);
 
-            if (bNeedRepartition && DOMAINDECOMP(cr))
+            if (bNeedRepartition && haveDDAtomOrdering(*cr))
             {
                 dd_collect_state(cr->dd, state, state_global);
             }
@@ -1932,7 +1932,7 @@ void gmx::LegacySimulator::do_md()
             bExchanged = replica_exchange(fplog, cr, ms, repl_ex, state_global, enerd, state, step, t);
         }
 
-        if ((bExchanged || bNeedRepartition) && DOMAINDECOMP(cr))
+        if ((bExchanged || bNeedRepartition) && haveDDAtomOrdering(*cr))
         {
             dd_partition_system(fplog,
                                 mdlog,
@@ -1987,7 +1987,7 @@ void gmx::LegacySimulator::do_md()
         }
 
         cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
-        if (DOMAINDECOMP(cr) && wcycle)
+        if (haveDDAtomOrdering(*cr) && wcycle)
         {
             dd_cycles_add(cr->dd, cycles, ddCyclStep);
         }
index 91b1d1794008c9266b834bd090cdbbf1e81dec41..82f4bf7465d23982bcd900034ced501b2194d573 100644 (file)
@@ -218,7 +218,7 @@ void gmx::LegacySimulator::do_mimic()
         auto* nonConstInputrec   = const_cast<t_inputrec*>(inputrec);
         nonConstInputrec->nsteps = MimicCommunicator::getStepNumber();
     }
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         // TODO: Avoid changing inputrec (#3854)
         auto* nonConstInputrec = const_cast<t_inputrec*>(inputrec);
@@ -273,7 +273,7 @@ void gmx::LegacySimulator::do_mimic()
                                  top_global,
                                  constr ? constr->numFlexibleConstraints() : 0,
                                  ir->nstcalcenergy,
-                                 DOMAINDECOMP(cr),
+                                 haveDDAtomOrdering(*cr),
                                  runScheduleWork->simulationWork.useGpuPme);
 
     {
@@ -284,7 +284,7 @@ void gmx::LegacySimulator::do_mimic()
         }
     }
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         // Local state only becomes valid now.
         dd_init_local_state(*cr->dd, state_global, state);
@@ -447,7 +447,7 @@ void gmx::LegacySimulator::do_mimic()
         if (MASTER(cr))
         {
             const bool constructVsites = ((vsite != nullptr) && mdrunOptions.rerunConstructVsites);
-            if (constructVsites && DOMAINDECOMP(cr))
+            if (constructVsites && haveDDAtomOrdering(*cr))
             {
                 gmx_fatal(FARGS,
                           "Vsite recalculation with -rerun is not implemented with domain "
@@ -462,7 +462,7 @@ void gmx::LegacySimulator::do_mimic()
             }
         }
 
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             /* Repartition the domain decomposition */
             const bool bMasterState = true;
@@ -653,7 +653,7 @@ void gmx::LegacySimulator::do_mimic()
             gmx::HostVector<gmx::RVec>     fglobal(top_global.natoms);
             gmx::ArrayRef<gmx::RVec>       ftemp;
             gmx::ArrayRef<const gmx::RVec> flocal = f.view().force();
-            if (DOMAINDECOMP(cr))
+            if (haveDDAtomOrdering(*cr))
             {
                 ftemp = gmx::makeArrayRef(fglobal);
                 dd_collect_vec(cr->dd, state->ddp_count, state->ddp_count_cg_gl, state->cg_gl, flocal, ftemp);
@@ -744,7 +744,7 @@ void gmx::LegacySimulator::do_mimic()
         }
 
         cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
-        if (DOMAINDECOMP(cr) && wcycle)
+        if (haveDDAtomOrdering(*cr) && wcycle)
         {
             dd_cycles_add(cr->dd, cycles, ddCyclStep);
         }
index 7513e11df3841b6734d8b536dbaf7c9baa7e60cc..e3ade12b7dfb88358927952877700a203503aee4 100644 (file)
@@ -315,7 +315,7 @@ static void get_f_norm_max(const t_commrec*               cr,
         }
     }
 
-    if (la_max >= 0 && DOMAINDECOMP(cr))
+    if (la_max >= 0 && haveDDAtomOrdering(*cr))
     {
         a_max = cr->dd->globalAtomIndices[la_max];
     }
@@ -414,7 +414,7 @@ static void init_em(FILE*                fplog,
                                       top_global,
                                       constr ? constr->numFlexibleConstraints() : 0,
                                       ir->nstcalcenergy,
-                                      DOMAINDECOMP(cr),
+                                      haveDDAtomOrdering(*cr),
                                       thisRankHasDuty(cr, DUTY_PME));
     }
     else
@@ -432,7 +432,7 @@ static void init_em(FILE*                fplog,
         }
     }
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         // Local state only becomes valid now.
         dd_init_local_state(*cr->dd, state_global, &ems->s);
@@ -596,7 +596,7 @@ static void write_em_traj(FILE*               fplog,
 
     if (confout != nullptr)
     {
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             /* If bX=true, x was collected to state_global in the call above */
             if (!bX)
@@ -614,7 +614,7 @@ static void write_em_traj(FILE*               fplog,
 
         if (MASTER(cr))
         {
-            if (ir->pbcType != PbcType::No && !ir->bPeriodicMols && DOMAINDECOMP(cr))
+            if (ir->pbcType != PbcType::No && !ir->bPeriodicMols && haveDDAtomOrdering(*cr))
             {
                 /* Make molecules whole only for confout writing */
                 do_pbc_mtop(ir->pbcType, state->s.box, &top_global, state_global->x.rvec_array());
@@ -655,7 +655,7 @@ static bool do_em_step(const t_commrec*                          cr,
     s1 = &ems1->s;
     s2 = &ems2->s;
 
-    if (DOMAINDECOMP(cr) && s1->ddp_count != cr->dd->ddp_count)
+    if (haveDDAtomOrdering(*cr) && s1->ddp_count != cr->dd->ddp_count)
     {
         gmx_incons("state mismatch in do_em_step");
     }
@@ -667,7 +667,7 @@ static bool do_em_step(const t_commrec*                          cr,
         state_change_natoms(s2, s1->natoms);
         ems2->f.resize(s2->natoms);
     }
-    if (DOMAINDECOMP(cr) && s2->cg_gl.size() != s1->cg_gl.size())
+    if (haveDDAtomOrdering(*cr) && s2->cg_gl.size() != s1->cg_gl.size())
     {
         s2->cg_gl.resize(s1->cg_gl.size());
     }
@@ -725,7 +725,7 @@ static bool do_em_step(const t_commrec*                          cr,
             }
         }
 
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             /* OpenMP does not supported unsigned loop variables */
 #pragma omp for schedule(static) nowait
@@ -736,7 +736,7 @@ static bool do_em_step(const t_commrec*                          cr,
         }
     }
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         s2->ddp_count       = s1->ddp_count;
         s2->ddp_count_cg_gl = s1->ddp_count_cg_gl;
@@ -967,7 +967,7 @@ void EnergyEvaluator::run(em_state_t* ems, rvec mu_tot, tensor vir, tensor pres,
     // Compute the buffer size of the pair list
     const real bufferSize = inputrec->rlist - std::max(inputrec->rcoulomb, inputrec->rvdw);
 
-    if (bFirst || bufferSize <= 0 || (DOMAINDECOMP(cr) && ems->s.ddp_count != ddpCountPairSearch))
+    if (bFirst || bufferSize <= 0 || (haveDDAtomOrdering(*cr) && ems->s.ddp_count != ddpCountPairSearch))
     {
         /* This is the first state or an old state used before the last ns */
         bNS = TRUE;
@@ -981,7 +981,7 @@ void EnergyEvaluator::run(em_state_t* ems, rvec mu_tot, tensor vir, tensor pres,
               > bufferSize;
     }
 
-    if (DOMAINDECOMP(cr) && bNS)
+    if (haveDDAtomOrdering(*cr) && bNS)
     {
         /* Repartition the domain decomposition */
         em_dd_partition_system(
@@ -1202,7 +1202,7 @@ static real pr_beta(const t_commrec*  cr,
      * and might have to sum it in parallel runs.
      */
 
-    if (!DOMAINDECOMP(cr)
+    if (!haveDDAtomOrdering(*cr)
         || (s_min->s.ddp_count == cr->dd->ddp_count && s_b->s.ddp_count == cr->dd->ddp_count))
     {
         auto fm = s_min->f.view().force();
@@ -1548,7 +1548,7 @@ void LegacySimulator::do_cg()
         a         = 0.0;
         c         = a + stepsize; /* reference position along line is zero */
 
-        if (DOMAINDECOMP(cr) && s_min->s.ddp_count < cr->dd->ddp_count)
+        if (haveDDAtomOrdering(*cr) && s_min->s.ddp_count < cr->dd->ddp_count)
         {
             em_dd_partition_system(fplog,
                                    mdlog,
@@ -1663,7 +1663,7 @@ void LegacySimulator::do_cg()
                     b = 0.5 * (a + c);
                 }
 
-                if (DOMAINDECOMP(cr) && s_min->s.ddp_count != cr->dd->ddp_count)
+                if (haveDDAtomOrdering(*cr) && s_min->s.ddp_count != cr->dd->ddp_count)
                 {
                     /* Reload the old state */
                     em_dd_partition_system(fplog,
@@ -1978,7 +1978,7 @@ void LegacySimulator::do_lbfgs()
                     "be available in a different form in a future version of GROMACS, "
                     "e.g. gmx minimize and an .mdp option.");
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         gmx_fatal(FARGS, "L_BFGS is currently not supported");
     }
@@ -3017,7 +3017,7 @@ void LegacySimulator::do_steep()
             /* If energy is not smaller make the step smaller...  */
             ustep *= 0.5;
 
-            if (DOMAINDECOMP(cr) && s_min->s.ddp_count != cr->dd->ddp_count)
+            if (haveDDAtomOrdering(*cr) && s_min->s.ddp_count != cr->dd->ddp_count)
             {
                 /* Reload the old state */
                 em_dd_partition_system(fplog,
index 5ec63824c2adfd63b4aee20995e869fd241e89d0..d569a3077cfeded1379d3532acb1d5e594fe3303 100644 (file)
@@ -235,7 +235,7 @@ gmx_repl_ex_t init_replica_exchange(FILE*                            fplog,
          * is true!
          *
          * Since we are using a dynamical integrator, the only
-         * decomposition is DD, so PAR(cr) and DOMAINDECOMP(cr) are
+         * decomposition is DD, so PAR(cr) and haveDDAtomOrdering(*cr) are
          * synonymous. The only way for cr->nnodes > 1 to be true is
          * if we are using DD. */
     }
@@ -1286,7 +1286,7 @@ gmx_bool replica_exchange(FILE*                 fplog,
      * each simulation know whether they need to participate in
      * collecting the state. Otherwise, they might as well get on with
      * the next thing to do. */
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
 #if GMX_MPI
         MPI_Bcast(&bThisReplicaExchanged, sizeof(gmx_bool), MPI_BYTE, MASTERRANK(cr), cr->mpi_comm_mygroup);
@@ -1297,7 +1297,7 @@ gmx_bool replica_exchange(FILE*                 fplog,
     {
         /* Exchange the states */
         /* Collect the global state on the master node */
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             dd_collect_state(cr->dd, state_local, state);
         }
@@ -1338,7 +1338,7 @@ gmx_bool replica_exchange(FILE*                 fplog,
         }
 
         /* With domain decomposition the global state is distributed later */
-        if (!DOMAINDECOMP(cr))
+        if (!haveDDAtomOrdering(*cr))
         {
             /* Copy the global state to the local state data structure */
             copy_state_serial(state, state_local);
index 48372cebfd7a687a6f29ff7238eed14cd19eea20..14eb21ffad675179f26ea0bbdef019b48d140b4d 100644 (file)
@@ -319,7 +319,7 @@ void gmx::LegacySimulator::do_rerun()
                                  top_global,
                                  constr ? constr->numFlexibleConstraints() : 0,
                                  ir->nstcalcenergy,
-                                 DOMAINDECOMP(cr),
+                                 haveDDAtomOrdering(*cr),
                                  runScheduleWork->simulationWork.useGpuPme);
 
     {
@@ -330,7 +330,7 @@ void gmx::LegacySimulator::do_rerun()
         }
     }
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         // Local state only becomes valid now.
         dd_init_local_state(*cr->dd, state_global, state);
@@ -565,7 +565,7 @@ void gmx::LegacySimulator::do_rerun()
         if (MASTER(cr))
         {
             const bool constructVsites = ((vsite != nullptr) && mdrunOptions.rerunConstructVsites);
-            if (constructVsites && DOMAINDECOMP(cr))
+            if (constructVsites && haveDDAtomOrdering(*cr))
             {
                 gmx_fatal(FARGS,
                           "Vsite recalculation with -rerun is not implemented with domain "
@@ -577,7 +577,7 @@ void gmx::LegacySimulator::do_rerun()
 
         isLastStep = isLastStep || stopHandler->stoppingAfterCurrentStep(bNS);
 
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             /* Repartition the domain decomposition */
             const bool bMasterState = true;
@@ -867,7 +867,7 @@ void gmx::LegacySimulator::do_rerun()
         }
 
         cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
-        if (DOMAINDECOMP(cr) && wcycle)
+        if (haveDDAtomOrdering(*cr) && wcycle)
         {
             dd_cycles_add(cr->dd, cycles, ddCyclStep);
         }
index d409b82136c434a6951334d5bf55d53fed9a49a7..5daf1606ca1256a9585148cc4367272b11aceaa8 100644 (file)
@@ -739,7 +739,7 @@ static void finish_run(FILE*                     fplog,
         print_flop(fplog, nrnb_tot, &nbfs, &mflop);
     }
 
-    if (thisRankHasDuty(cr, DUTY_PP) && DOMAINDECOMP(cr))
+    if (thisRankHasDuty(cr, DUTY_PP) && haveDDAtomOrdering(*cr))
     {
         print_dd_statistics(cr, inputrec, fplog);
     }
@@ -1113,7 +1113,7 @@ int Mdrunner::mdrunner()
             globalState = std::make_unique<t_state>();
         }
         broadcastStateWithoutDynamics(
-                cr->mpiDefaultCommunicator, DOMAINDECOMP(cr), PAR(cr), globalState.get());
+                cr->mpiDefaultCommunicator, haveDDAtomOrdering(*cr), PAR(cr), globalState.get());
     }
 
     /* A parallel command line option consistency check that we can
@@ -1595,7 +1595,7 @@ int Mdrunner::mdrunner()
     // Enable Peer access between GPUs where available
     // Only for DD, only master PP rank needs to perform setup, and only if thread MPI plus
     // any of the GPU communication features are active.
-    if (DOMAINDECOMP(cr) && MASTER(cr) && thisRankHasDuty(cr, DUTY_PP) && GMX_THREAD_MPI
+    if (haveDDAtomOrdering(*cr) && MASTER(cr) && thisRankHasDuty(cr, DUTY_PP) && GMX_THREAD_MPI
         && (runScheduleWork.simulationWork.useGpuHaloExchange
             || runScheduleWork.simulationWork.useGpuPmePpCommunication))
     {
@@ -1788,7 +1788,7 @@ int Mdrunner::mdrunner()
             }
         }
         // Make the DD reverse topology, now that any vsites that are present are available
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             dd_make_reverse_top(fplog, cr->dd, mtop, vsite.get(), *inputrec, domdecOptions.ddBondedChecking);
         }
@@ -2006,7 +2006,7 @@ int Mdrunner::mdrunner()
                                          mdrunOptions.imdOptions,
                                          startingBehavior);
 
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             GMX_RELEASE_ASSERT(fr, "fr was NULL while cr->duty was DUTY_PP");
             /* This call is not included in init_domain_decomposition
index 7f15b180bc8bbe9d811eb54b6d7ced370665eebf..2f4c2d6e935ed38f02fcdd7b38bb6952e423e928 100644 (file)
@@ -540,7 +540,7 @@ void gmx::make_local_shells(const t_commrec* cr, const t_mdatoms& md, gmx_shellf
     int           a0, a1;
     gmx_domdec_t* dd = nullptr;
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd = cr->dd;
         a0 = 0;
@@ -833,7 +833,7 @@ static void init_adir(gmx_shellfc_t*            shfc,
     double dt, w_dt;
     int    n, d;
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         n = dd_ac1;
     }
@@ -983,7 +983,7 @@ void relax_shell_flexcon(FILE*                         fplog,
     ArrayRef<t_shell> shells       = shfc->shells;
     const int         nflexcon     = shfc->nflexcon;
 
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         nat = dd_natoms_vsite(*cr->dd);
         if (nflexcon > 0)
@@ -1019,7 +1019,7 @@ void relax_shell_flexcon(FILE*                         fplog,
     ArrayRef<RVec> x = xPadded.unpaddedArrayRef();
     ArrayRef<RVec> v = vPadded.unpaddedArrayRef();
 
-    if (bDoNS && inputrec->pbcType != PbcType::No && !DOMAINDECOMP(cr))
+    if (bDoNS && inputrec->pbcType != PbcType::No && !haveDDAtomOrdering(*cr))
     {
         /* This is the only time where the coordinates are used
          * before do_force is called, which normally puts all
index 0307de3d5f7a315ad8301a36c4aedd266ce27c6f..69ed6a2c9d6f8f93d352d5e22d0389c88a640c64 100644 (file)
@@ -158,16 +158,22 @@ inline bool thisRankHasDuty(const t_commrec* cr, int duty)
 //! The node id for the master
 #define MASTERRANK(cr) (0)
 
-/*! \brief Returns whether the domain decomposition machinery is active
+/*! \brief Returns whether the domain decomposition machinery is active and reorders atoms
+ *
+ * This tells whether atoms are reordered at pair search steps. When the return value
+ * is true, atoms are not in the order of the input and mtop.
  *
  * Note that when the return value is true, there are not necessarily
  * multiple domains. The domain decomposition machinery is also active and
  * reorders the atoms also with a single MPI rank, or 1 PP and 1 PME rank,
  * with most integrators. Only a few special non-integrator "integrators"
  * do not (yet) support the domain decomposition machinery and therefore
- * this macro is still needed.
+ * this function is still needed.
  */
-#define DOMAINDECOMP(cr) ((cr)->dd != nullptr)
+static bool inline haveDDAtomOrdering(const t_commrec& cr)
+{
+    return cr.dd != nullptr;
+}
 
 /*! \brief Returns whether we have actual domain decomposition for the particle-particle interactions
  *
index cf5743bc40f1a4f1659b8414c173ae1cadd3da20..5db8ff614111224c50ff860ba26634388c864577 100644 (file)
@@ -100,7 +100,7 @@ void AndersenTemperatureCoupling::apply(Step step)
     UniformRealDistribution<real>         uniformDist;
     TabulatedNormalDistribution<real, 14> normalDist;
 
-    const bool doDomainDecomposition = DOMAINDECOMP(cr_);
+    const bool atomOrderingIsDD = haveDDAtomOrdering(*cr_);
 
     auto velocities = statePropagatorData_->velocitiesView().unpaddedArrayRef();
 
@@ -112,7 +112,7 @@ void AndersenTemperatureCoupling::apply(Step step)
             continue;
         }
 
-        const int globalAtomIdx = doDomainDecomposition ? cr_->dd->globalAtomIndices[atomIdx] : atomIdx;
+        const int globalAtomIdx = atomOrderingIsDD ? cr_->dd->globalAtomIndices[atomIdx] : atomIdx;
         rng.restart(step, globalAtomIdx);
 
         // For massive Andersen, this function is only called periodically, but we apply each time
index 30d3d4ea15e118582ce448b25160205f4c646adf..4ee3524cc34785b13b7c9328a97802ff313dd53b 100644 (file)
@@ -94,7 +94,8 @@ DomDecHelper::DomDecHelper(bool                          isVerbose,
     imdSession_(imdSession),
     pull_work_(pull_work)
 {
-    GMX_ASSERT(DOMAINDECOMP(cr), "Domain decomposition Helper constructed in non-DD simulation");
+    GMX_ASSERT(haveDDAtomOrdering(*cr),
+               "Domain decomposition Helper constructed in non-DD simulation");
 }
 
 void DomDecHelper::setup()
index 17ec878ebc8e45b3e43840a4f795e6b824af5761..5a76dbe67dd39a514db3e409b9f7569d17646327 100644 (file)
@@ -155,7 +155,7 @@ void ExpandedEnsembleElement::restoreCheckpointState(std::optional<ReadCheckpoin
     {
         doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
     }
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_distribute_dfhist(cr->dd, dfhist_.get());
     }
index ed9363d8ec5e05e8781acff8eff514ff21d6e3ae..4499d6ed472ffcb4b1b884a9e37036efac07e79f 100644 (file)
@@ -187,7 +187,7 @@ void FirstOrderPressureCoupling::restoreCheckpointState(std::optional<ReadCheckp
     {
         doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
     }
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_bcast(cr->dd, sizeof(conservedEnergyContribution_), &conservedEnergyContribution_);
         dd_bcast(cr->dd, sizeof(conservedEnergyContributionStep_), &conservedEnergyContributionStep_);
index 3e4c0f414ece6a7a5d02f113911d68ff27743045..b41fdca27a6c278c75297ccbdc12ae24768c20eb 100644 (file)
@@ -95,7 +95,7 @@ ForceElement::ForceElement(StatePropagatorData*        statePropagatorData,
                                 globalTopology,
                                 constr ? constr->numFlexibleConstraints() : 0,
                                 inputrec->nstcalcenergy,
-                                DOMAINDECOMP(cr),
+                                haveDDAtomOrdering(*cr),
                                 runScheduleWork->simulationWork.useGpuPme)),
     doShellFC_(shellfc_ != nullptr),
     nextNSStep_(-1),
@@ -137,7 +137,7 @@ ForceElement::ForceElement(StatePropagatorData*        statePropagatorData,
 {
     std::fill(lambda_.begin(), lambda_.end(), 0);
 
-    if (doShellFC_ && !DOMAINDECOMP(cr))
+    if (doShellFC_ && !haveDDAtomOrdering(*cr))
     {
         // This was done in mdAlgorithmsSetupAtomData(), but shellfc
         // won't be available outside this element.
@@ -178,7 +178,7 @@ void ForceElement::run(Step step, Time time, unsigned int flags)
     gmx_multisim_t* ms = nullptr;
 
 
-    if (!DOMAINDECOMP(cr_) && (flags & GMX_FORCE_NS) && inputrecDynamicBox(inputrec_))
+    if (!haveDDAtomOrdering(*cr_) && (flags & GMX_FORCE_NS) && inputrecDynamicBox(inputrec_))
     {
         // TODO: Correcting the box is done in DomDecHelper (if using DD) or here (non-DD simulations).
         //       Think about unifying this responsibility, could this be done in one place?
index 544660f5770e638a303bb9d5bda82eb2c61eb4c0..ce268aac30a81c5fe6b9047ae5a29ec795fc0800 100644 (file)
@@ -229,7 +229,7 @@ void FreeEnergyPerturbationData::Element::restoreCheckpointState(std::optional<R
                 &checkpointData.value());
         doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
     }
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_bcast(cr->dd, sizeof(int), &freeEnergyPerturbationData_->currentFEPState_);
         dd_bcast(cr->dd,
index 22517e52380c4c22f3b43646c9f5255a7037684a..ba5f0c92193a4b869b749da7b4547f8b98960c88 100644 (file)
@@ -79,7 +79,7 @@ void MttkData::build(LegacySimulatorData*                    legacySimulatorData
     // When using domain decomposition, statePropagatorData might not have the initial
     // box yet, so we get it from the legacy state_global instead.
     // TODO: Make sure we have a valid state in statePropagatorData at all times (#3421)
-    if (DOMAINDECOMP(legacySimulatorData->cr))
+    if (haveDDAtomOrdering(*legacySimulatorData->cr))
     {
         if (MASTER(legacySimulatorData->cr))
         {
@@ -307,7 +307,7 @@ void MttkData::restoreCheckpointState(std::optional<ReadCheckpointData> checkpoi
     {
         doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
     }
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_bcast(cr->dd, int(sizeof(real)), &etaVelocity_);
         dd_bcast(cr->dd, int(sizeof(real)), &invMass_);
index 60826edc88255339eef54fd8a6de0caef34b1e42..3abb8028f8ab87972e30eb0a131aa5b9e1b27bc8 100644 (file)
@@ -429,7 +429,7 @@ void NoseHooverChainsData::restoreCheckpointState(std::optional<ReadCheckpointDa
     }
     for (auto& group : noseHooverGroups_)
     {
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             group.broadcastCheckpointValues(cr->dd);
         }
index d38f669fb55ddaee51b1ff198a8801aa4cd4fbbc..2f10b3285eb58c0201a10d25e1d7deda76d67fc8 100644 (file)
@@ -303,7 +303,7 @@ void ParrinelloRahmanBarostat::restoreCheckpointState(std::optional<ReadCheckpoi
     {
         doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
     }
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_bcast(cr->dd, sizeof(boxVelocity_), boxVelocity_);
         dd_bcast(cr->dd, sizeof(boxRel_), boxRel_);
index 2d127f41ef9fa84ca24c66cf03911ac515892ad9..5d07cc83aad163637f366749704de2e30e9ae487 100644 (file)
@@ -303,7 +303,7 @@ void ModularSimulatorAlgorithm::postStep(Step step, Time gmx_unused time)
     }
 
     double cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
-    if (DOMAINDECOMP(cr) && wcycle)
+    if (haveDDAtomOrdering(*cr) && wcycle)
     {
         dd_cycles_add(cr->dd, static_cast<float>(cycles), ddCyclStep);
     }
@@ -588,7 +588,7 @@ ModularSimulatorAlgorithm ModularSimulatorAlgorithmBuilder::build()
     registerWithInfrastructureAndSignallers(trajectoryElement.get());
 
     // Build domdec helper (free energy element is a client, so keep this after it is built)
-    if (DOMAINDECOMP(legacySimulatorData_->cr))
+    if (haveDDAtomOrdering(*legacySimulatorData_->cr))
     {
         algorithm.domDecHelper_ =
                 domDecHelperBuilder_.build(legacySimulatorData_->mdrunOptions.verbose,
index c57ec7c0611573a01bb91da23c93fdded517c9d4..b19ca468bbc97e397beef83baea852475086b8c9 100644 (file)
@@ -179,7 +179,7 @@ StatePropagatorData::StatePropagatorData(int                numAtoms,
 {
     bool stateHasVelocities;
     // Local state only becomes valid now.
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_init_local_state(*cr->dd, globalState, localState);
         stateHasVelocities = ((localState->flags & enumValueToBitMask(StateEntry::V)) != 0);
@@ -203,7 +203,7 @@ StatePropagatorData::StatePropagatorData(int                numAtoms,
         changePinningPolicy(&x_, gmx::PinningPolicy::PinnedIfSupported);
     }
 
-    if (DOMAINDECOMP(cr) && MASTER(cr))
+    if (haveDDAtomOrdering(*cr) && MASTER(cr))
     {
         xGlobal_.resizeWithPadding(totalNumAtoms_);
         previousXGlobal_.resizeWithPadding(totalNumAtoms_);
@@ -605,7 +605,7 @@ void StatePropagatorData::doCheckpointData(CheckpointData<operation>* checkpoint
 void StatePropagatorData::Element::saveCheckpointState(std::optional<WriteCheckpointData> checkpointData,
                                                        const t_commrec*                   cr)
 {
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         // Collect state from all ranks into global vectors
         dd_collect_vec(cr->dd,
@@ -670,7 +670,7 @@ void StatePropagatorData::Element::restoreCheckpointState(std::optional<ReadChec
     }
 
     // Copy data to global state to be distributed by DD at setup stage
-    if (DOMAINDECOMP(cr) && MASTER(cr))
+    if (haveDDAtomOrdering(*cr) && MASTER(cr))
     {
         updateGlobalState(statePropagatorData_->globalState_,
                           statePropagatorData_->xGlobal_,
@@ -681,7 +681,7 @@ void StatePropagatorData::Element::restoreCheckpointState(std::optional<ReadChec
                           statePropagatorData_->cgGl_);
     }
     // Everything is local - copy global vectors to local ones
-    if (!DOMAINDECOMP(cr))
+    if (!haveDDAtomOrdering(*cr))
     {
         statePropagatorData_->x_.resizeWithPadding(statePropagatorData_->totalNumAtoms_);
         statePropagatorData_->v_.resizeWithPadding(statePropagatorData_->totalNumAtoms_);
@@ -712,7 +712,7 @@ void StatePropagatorData::Element::trajectoryWriterTeardown(gmx_mdoutf* gmx_unus
     GMX_ASSERT(localStateBackupValid_, "Final trajectory writing called, but no state saved.");
 
     wallcycle_start(mdoutf_get_wcycle(outf), WallCycleCounter::Traj);
-    if (DOMAINDECOMP(cr_))
+    if (haveDDAtomOrdering(*cr_))
     {
         auto globalXRef =
                 MASTER(cr_) ? statePropagatorData_->globalState_->x : gmx::ArrayRef<gmx::RVec>();
index d697a2c96b36f86d18fa6aa8afaa2e9f2b47b203..d96fea554d19db0da3bf3885713d2cf845a42ffd 100644 (file)
@@ -61,7 +61,7 @@ TopologyHolder::TopologyHolder(std::vector<ITopologyHolderClient*> clients,
                                VirtualSitesHandler*                vsite) :
     globalTopology_(globalTopology), localTopology_(localTopology), clients_(std::move(clients))
 {
-    if (!DOMAINDECOMP(cr))
+    if (!haveDDAtomOrdering(*cr))
     {
         // Generate and initialize new topology
         // Note that most of the data needed for the constructor is used here -
index 47df3fc82abcca8a7ebef784aa7aa5800650c1dd..5caeafae33a283420c26251e06469a80017a11fa 100644 (file)
@@ -452,7 +452,7 @@ public:
         {
             doCheckpointData(&checkpointData.value());
         }
-        if (DOMAINDECOMP(cr))
+        if (haveDDAtomOrdering(*cr))
         {
             dd_bcast(cr->dd, xi_.size() * sizeof(real), xi_.data());
             dd_bcast(cr->dd, xiVelocities_.size() * sizeof(real), xiVelocities_.data());
@@ -702,7 +702,7 @@ void VelocityScalingTemperatureCoupling::restoreCheckpointState(std::optional<Re
     {
         doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
     }
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         dd_bcast(cr->dd,
                  ssize(temperatureCouplingIntegral_) * int(sizeof(double)),
index 42e3511853eea9fb265adbb91a468805dadc9bd6..b279596730bb9f142cefbc613ceff9937736865c 100644 (file)
@@ -223,7 +223,7 @@ const char* lookup_kernel_name(const KernelType kernelType)
         case KernelType::Cpu4xN_Simd_2xNN:
 #if GMX_SIMD
             return "SIMD";
-#else // GMX_SIMD
+#else  // GMX_SIMD
             return "not available";
 #endif // GMX_SIMD
         case KernelType::Gpu8x8x8: return "GPU";
@@ -458,15 +458,15 @@ std::unique_ptr<nonbonded_verlet_t> init_nb_verlet(const gmx::MDLogger& mdlog,
     auto pairlistSets = std::make_unique<PairlistSets>(
             pairlistParams, haveMultipleDomains, minimumIlistCountForGpuBalancing);
 
-    auto pairSearch =
-            std::make_unique<PairSearch>(inputrec.pbcType,
-                                         EI_TPI(inputrec.eI),
-                                         DOMAINDECOMP(commrec) ? &commrec->dd->numCells : nullptr,
-                                         DOMAINDECOMP(commrec) ? domdec_zones(commrec->dd) : nullptr,
-                                         pairlistParams.pairlistType,
-                                         bFEP_NonBonded,
-                                         gmx_omp_nthreads_get(ModuleMultiThread::Pairsearch),
-                                         pinPolicy);
+    auto pairSearch = std::make_unique<PairSearch>(
+            inputrec.pbcType,
+            EI_TPI(inputrec.eI),
+            haveDDAtomOrdering(*commrec) ? &commrec->dd->numCells : nullptr,
+            haveDDAtomOrdering(*commrec) ? domdec_zones(commrec->dd) : nullptr,
+            pairlistParams.pairlistType,
+            bFEP_NonBonded,
+            gmx_omp_nthreads_get(ModuleMultiThread::Pairsearch),
+            pinPolicy);
 
     return std::make_unique<nonbonded_verlet_t>(
             std::move(pairlistSets), std::move(pairSearch), std::move(nbat), kernelSetup, gpu_nbv, wcycle);
index 48f409254af3ccad12d19ae8b6021fa5bbde3c41..548a0747b2182cfe2b264849fdf4976375f966e2 100644 (file)
@@ -280,12 +280,12 @@ void increaseNstlist(FILE*               fp,
         /* Does rlist fit in the box? */
         bBox = (gmx::square(rlist_new) < max_cutoff2(ir->pbcType, box));
         bDD  = true;
-        if (bBox && DOMAINDECOMP(cr))
+        if (bBox && haveDDAtomOrdering(*cr))
         {
             /* Currently (as of July 2020), the code in this if clause is never executed.
              * increaseNstlist(...) is only called from prepare_verlet_scheme, which in turns
-             * gets called by the runner _before_ setting up DD. DOMAINDECOMP(cr) will therefore
-             * always be false here. See #3334.
+             * gets called by the runner _before_ setting up DD. haveDDAtomOrdering(*cr) will
+             * therefore always be false here. See #3334.
              */
             /* Check if rlist fits in the domain decomposition */
             if (inputrec2nboundeddim(ir) < DIM)
index 106861bb68bd19ca5ddcd8cd73102132135407b6..cbef32a4029f512b7aa07b905fef558820837ee7 100644 (file)
@@ -2048,7 +2048,7 @@ struct pull_t* init_pull(FILE*                     fplog,
                                  maxNumThreads);
     }
 
-    if (cr != nullptr && DOMAINDECOMP(cr))
+    if (cr != nullptr && haveDDAtomOrdering(*cr))
     {
         /* Set up the global to local atom mapping for PBC atoms */
         for (pull_group_work_t& group : pull->group)
@@ -2398,7 +2398,7 @@ struct pull_t* init_pull(FILE*                     fplog,
      * when we have an external pull potential, since then the external
      * potential provider expects each rank to have the coordinate.
      */
-    comm->bParticipateAll = (cr == nullptr || !DOMAINDECOMP(cr) || cr->dd->nnodes <= 32
+    comm->bParticipateAll = (cr == nullptr || !haveDDAtomOrdering(*cr) || cr->dd->nnodes <= 32
                              || pull->numCoordinatesWithExternalPotential > 0
                              || getenv("GMX_PULL_PARTICIPATE_ALL") != nullptr);
     /* This sub-commicator is not used with comm->bParticipateAll,
index 325c3f65b92a6a8fa8d7f7e80df5ad5fdcc0b63c..bcea9f3db18ef1138cbdc1f773dc4fe10b593855 100644 (file)
@@ -3980,7 +3980,7 @@ void do_rotation(const t_commrec*               cr,
 
     /**************************************************************************/
     /* Done communicating, we can start to count cycles for the load balancing now ... */
-    if (DOMAINDECOMP(cr))
+    if (haveDDAtomOrdering(*cr))
     {
         ddReopenBalanceRegionCpu(cr->dd);
     }
index b4cf5f3c0f2d82cff003410880cd8fb36ad43969..cf7a9778ecf57694a5cce484d56f2fe4d3779947 100644 (file)
@@ -542,7 +542,7 @@ void pull_calc_coms(const t_commrec*     cr,
     {
         pull_set_pbcatoms(cr, pull, x, comm->pbcAtomBuffer);
 
-        if (cr != nullptr && DOMAINDECOMP(cr))
+        if (cr != nullptr && haveDDAtomOrdering(*cr))
         {
             /* We can keep these PBC reference coordinates fixed for nstlist
              * steps, since atoms won't jump over PBC.
index bc4233cba39a8a5ece58c8a455e28b38ebb1e819..4e988dbd335c0231913d00d0e4408944e2e0318b 100644 (file)
@@ -115,7 +115,7 @@ void RestraintForceProvider::calculateForces(const ForceProviderInput& forceProv
     }
     // All ranks wait for the update to finish.
     // tMPI ranks are depending on structures that may have just been updated.
-    if (DOMAINDECOMP(&cr))
+    if (haveDDAtomOrdering(cr))
     {
         // Note: this assumes that all ranks are hitting this line, which is not generally true.
         // I need to find the right subcommunicator. What I really want is a _scoped_ communicator...
index 8cfab33f45706d09565f230dfa1a59ffc367b4c4..bc22320e5a64c93b8ab52028d7218930dcf1b647 100644 (file)
@@ -132,7 +132,7 @@ public:
         // Center of mass to return for the site. Currently the only form of site
         // implemented is as a global atomic coordinate.
         gmx::RVec r = { 0, 0, 0 };
-        if (DOMAINDECOMP(&cr)) // Domain decomposition
+        if (haveDDAtomOrdering(cr)) // Domain decomposition
         {
             // Get global-to-local indexing structure
             auto* crossRef = cr.dd->ga2la;
index 172d4024a04564bbf0a7fbad675d3ab00adae171..e8213aa095edffd74b5ce8d0abf8d1d5d4e9fd76 100644 (file)
@@ -1555,7 +1555,7 @@ t_swap* init_swapcoords(FILE*                       fplog,
     swapstateIons_t* gs;
     swaphistory_t*   swapstate = nullptr;
 
-    if ((PAR(cr)) && !DOMAINDECOMP(cr))
+    if ((PAR(cr)) && !haveDDAtomOrdering(*cr))
     {
         gmx_fatal(FARGS, "Position swapping is only implemented for domain decomposition!");
     }