Centralize more MD/force shedule flags
authorSzilárd Páll <pall.szilard@gmail.com>
Thu, 20 Jun 2019 18:54:01 +0000 (20:54 +0200)
committerPaul Bauer <paul.bauer.q@gmail.com>
Wed, 4 Sep 2019 08:36:23 +0000 (10:36 +0200)
This change creates an MdScheduleWorkload top-level class to store
information related to per-step, per search-phase, or per run schedule
information and moving the previous PpForceWorkload call into it.

This change also migrates force flags bitmask into a new class
stored in the MdWorkload class.

Change-Id: I142a76d9515e82b16b9a4100ffb00469d7f3d3c2

19 files changed:
src/gromacs/listed_forces/gpubonded.h
src/gromacs/listed_forces/gpubonded_impl.cpp
src/gromacs/listed_forces/gpubondedkernels.cu
src/gromacs/mdlib/force.h
src/gromacs/mdlib/ppforceworkload.h
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdrun/isimulator.h
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/mimic.cpp
src/gromacs/mdrun/minimize.cpp
src/gromacs/mdrun/rerun.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrun/shellfc.cpp
src/gromacs/mdrun/shellfc.h
src/gromacs/mdrun/simulatorbuilder.h
src/gromacs/mdrun/tpi.cpp
src/gromacs/nbnxm/cuda/nbnxm_cuda_data_mgmt.cu
src/gromacs/nbnxm/gpu_data_mgmt.h
src/gromacs/nbnxm/opencl/nbnxm_ocl_data_mgmt.cpp

index 6ea5541f3ee580f021d4c187ba9d51912b2c1027..b7a13fcae28d3f42e10a55e3c2d5a990244cf28f 100644 (file)
@@ -61,12 +61,15 @@ struct t_idef;
 struct t_inputrec;
 struct gmx_wallcycle;
 
-/*! \brief The number on bonded function types supported on GPUs */
-static constexpr int numFTypesOnGpu = 8;
 
 namespace gmx
 {
 
+class ForceFlags;
+
+/*! \brief The number on bonded function types supported on GPUs */
+static constexpr int numFTypesOnGpu = 8;
+
 /*! \brief List of all bonded function types supported on GPUs
  *
  * \note This list should be in sync with the actual GPU code.
@@ -134,9 +137,9 @@ class GpuBonded
          * assigned to the GPU */
         bool haveInteractions() const;
         /*! \brief Launches bonded kernel on a GPU */
-        void launchKernel(const t_forcerec *fr,
-                          int               forceFlags,
-                          const matrix      box);
+        void launchKernel(const t_forcerec      *fr,
+                          const gmx::ForceFlags &forceFlags,
+                          const matrix           box);
         /*! \brief Launches the transfer of computed bonded energies. */
         void launchEnergyTransfer();
         /*! \brief Waits on the energy transfer, and accumulates bonded energies to \c enerd. */
index 178d241a59c700322e3c6f7faad9b672e2165035..3de01e305524cc426ceed8964d4f73cef37c4c43 100644 (file)
@@ -189,8 +189,8 @@ GpuBonded::haveInteractions() const
 }
 
 void
-GpuBonded::launchKernel(const t_forcerec * /* fr */,
-                        int            /* forceFlags */,
+GpuBonded::launchKernel(const t_forcerec           * /* fr */,
+                        const gmx::ForceFlags      & /* forceFlags */,
                         const matrix   /* box */)
 {
 }
index 93157160ba9b72300e6fabfcca8825546d56d5ed..709d99cc9afa892536ba32c8ab78ae40464e413e 100644 (file)
@@ -57,6 +57,7 @@
 #include "gromacs/listed_forces/gpubonded.h"
 #include "gromacs/math/units.h"
 #include "gromacs/mdlib/force_flags.h"
+#include "gromacs/mdlib/ppforceworkload.h"
 #include "gromacs/mdtypes/forcerec.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/pbcutil/pbc_aiuc_cuda.cuh"
@@ -861,17 +862,17 @@ GpuBonded::Impl::launchKernel(const t_forcerec *fr,
 }
 
 void
-GpuBonded::launchKernel(const t_forcerec *fr,
-                        int               forceFlags,
-                        const matrix      box)
+GpuBonded::launchKernel(const t_forcerec      *fr,
+                        const gmx::ForceFlags &forceFlags,
+                        const matrix           box)
 {
-    if (forceFlags & GMX_FORCE_ENERGY)
+    if (forceFlags.computeEnergy)
     {
         // When we need the energy, we also need the virial
         impl_->launchKernel<true, true>
             (fr, box);
     }
-    else if (forceFlags & GMX_FORCE_VIRIAL)
+    else if (forceFlags.computeVirial)
     {
         impl_->launchKernel<true, false>
             (fr, box);
index 41e674ebb549f2074af0003124aa83899dad5b40..88c8b15ee45a4585a5856e832b4d2f63a57966bd 100644 (file)
@@ -68,7 +68,7 @@ namespace gmx
 class Awh;
 class ForceWithVirial;
 class ImdSession;
-class PpForceWorkload;
+class MdScheduleWorkload;
 class MDLogger;
 }
 
@@ -95,7 +95,7 @@ void do_force(FILE                                     *log,
               gmx::ArrayRef<real>                       lambda,
               t_graph                                  *graph,
               t_forcerec                               *fr,
-              gmx::PpForceWorkload                     *ppForceWorkload,
+              gmx::MdScheduleWorkload                  *mdScheduleWork,
               const gmx_vsite_t                        *vsite,
               rvec                                      mu_tot,
               double                                    t,
index a494ce57f327c30aa16084e62bfb07856726b3d8..43769c66bb6505da8faa68543a0126723ce6fd06 100644 (file)
 namespace gmx
 {
 
+/*! \libinternal
+ * \brief Data structure to map force flags to booleans that have the role of
+ *  directing per-step tasks undertaken by a PP rank.
+ *
+ * Note that the contents of this class have a lifetime of a single step and
+ * are expected to be set every step.
+ *
+ */
+class ForceFlags
+{
+    public:
+        //! Whether the state has changed, always set unless TPI is used.
+        bool stateChanged = false;
+        //! Whether the box might have changed
+        bool haveDynamicBox = false;
+        //! Whether neighbor searching needs to be done this step
+        bool doNeighborSearch = false;
+        //! Whether virial needs to be computed this step
+        bool computeVirial = false;
+        //! Whether energies need to be computed this step this step
+        bool computeEnergy = false;
+        //! Whether (any) forces need to be computed this step, not only energies
+        bool computeForces = false;
+        //! Whether nonbonded forces need to be computed this step
+        bool computeNonbondedForces = false;
+        //! Whether listed forces need to be computed this step
+        bool computeListedForces = false;
+};
+
 /*! \libinternal
  * \brief Manage what force calculation work is required each step.
  *
@@ -60,7 +89,10 @@ namespace gmx
  * \todo Add more responsibilities, including whether GPUs are in use,
  * whether there is PME work, whether DD is active, whether NB
  * local/nonlocal regions have work, whether forces/virial/energy are
- * required. */
+ * required.
+ *
+ * TODO rename
+ */
 class PpForceWorkload
 {
     public:
@@ -68,7 +100,7 @@ class PpForceWorkload
         bool haveGpuBondedWork = false;
         //! Whether this MD step has bonded work to run on he CPU.
         bool haveCpuBondedWork = false;
-        //! Whether this MD step has listed forces bonded work to run on he CPU.
+        //! Whether this MD step has restraints work to run on he CPU.
         bool haveRestraintsWork = false;
         //! Whether this MD step has listed forces work to run on he CPU.
         //  Note: currently this is haveCpuBondedWork | haveRestraintsWork
@@ -77,6 +109,15 @@ class PpForceWorkload
         bool haveSpecialForces = false;
 };
 
+class MdScheduleWorkload
+{
+    public:
+        //! Force schedule workload descriptor constant for an nstlist range
+        gmx::PpForceWorkload forceWork;
+        //! Force flags changing per-step
+        gmx::ForceFlags      forceFlags;
+};
+
 } // namespace gmx
 
 #endif
index 3a87eefb0ab0b7018f87f3d0ac49f146a08139a5..171675e914a17f138bcba337c7a8ff673985514e 100644 (file)
 #include "gromacs/ewald/pme.h"
 #include "gromacs/gmxlib/chargegroup.h"
 #include "gromacs/gmxlib/network.h"
-#include "gromacs/gmxlib/nrnb.h"
 #include "gromacs/gmxlib/nonbonded/nb_free_energy.h"
 #include "gromacs/gmxlib/nonbonded/nb_kernel.h"
 #include "gromacs/gmxlib/nonbonded/nonbonded.h"
 #include "gromacs/gpu_utils/gpu_utils.h"
 #include "gromacs/imd/imd.h"
-#include "gromacs/listed_forces/bonded.h"
 #include "gromacs/listed_forces/disre.h"
 #include "gromacs/listed_forces/gpubonded.h"
 #include "gromacs/listed_forces/listed_forces.h"
@@ -255,20 +253,20 @@ static void print_large_forces(FILE            *fp,
     }
 }
 
-static void post_process_forces(const t_commrec           *cr,
-                                int64_t                    step,
-                                t_nrnb                    *nrnb,
-                                gmx_wallcycle_t            wcycle,
-                                const gmx_localtop_t      *top,
-                                const matrix               box,
-                                const rvec                 x[],
-                                ForceOutputs              *forceOutputs,
-                                tensor                     vir_force,
-                                const t_mdatoms           *mdatoms,
-                                const t_graph             *graph,
-                                const t_forcerec          *fr,
-                                const gmx_vsite_t         *vsite,
-                                int                        flags)
+static void post_process_forces(const t_commrec       *cr,
+                                int64_t                step,
+                                t_nrnb                *nrnb,
+                                gmx_wallcycle_t        wcycle,
+                                const gmx_localtop_t  *top,
+                                const matrix           box,
+                                const rvec             x[],
+                                ForceOutputs          *forceOutputs,
+                                tensor                 vir_force,
+                                const t_mdatoms       *mdatoms,
+                                const t_graph         *graph,
+                                const t_forcerec      *fr,
+                                const gmx_vsite_t     *vsite,
+                                const gmx::ForceFlags &forceFlags)
 {
     rvec *f = as_rvec_array(forceOutputs->forceWithShiftForces().force().data());
 
@@ -285,13 +283,13 @@ static void post_process_forces(const t_commrec           *cr,
              */
             matrix virial = { { 0 } };
             spread_vsite_f(vsite, x, fDirectVir, nullptr,
-                           (flags & GMX_FORCE_VIRIAL) != 0, virial,
+                           forceFlags.computeVirial, virial,
                            nrnb,
                            &top->idef, fr->ePBC, fr->bMolPBC, graph, box, cr, wcycle);
             forceWithVirial.addVirialContribution(virial);
         }
 
-        if (flags & GMX_FORCE_VIRIAL)
+        if (forceFlags.computeVirial)
         {
             /* Now add the forces, this is local */
             sum_forces(f, forceWithVirial.force_);
@@ -474,10 +472,9 @@ static bool
 haveSpecialForces(const t_inputrec              *inputrec,
                   ForceProviders                *forceProviders,
                   const pull_t                  *pull_work,
-                  int                            forceFlags,
+                  const bool                     computeForces,
                   const gmx_edsam               *ed)
 {
-    const bool computeForces = (forceFlags & GMX_FORCE_FORCES) != 0;
 
     return
         ((computeForces && forceProviders->hasForceProvider()) ||         // forceProviders
@@ -512,13 +509,13 @@ haveSpecialForces(const t_inputrec              *inputrec,
  * \param[in]     x                The coordinates
  * \param[in]     mdatoms          Per atom properties
  * \param[in]     lambda           Array of free-energy lambda values
- * \param[in]     forceFlags       Flags that tell whether we should compute forces/energies/virial
+ * \param[in]     forceFlags       Force schedule flags
  * \param[in,out] forceWithVirial  Force and virial buffers
  * \param[in,out] enerd            Energy buffer
  * \param[in,out] ed               Essential dynamics pointer
- * \param[in]     bNS              Tells if we did neighbor searching this step, used for ED sampling
+ * \param[in]     didNeighborSearch Tells if we did neighbor searching this step, used for ED sampling
  *
- * \todo Remove bNS, which is used incorrectly.
+ * \todo Remove didNeighborSearch, which is used incorrectly.
  * \todo Convert all other algorithms called here to ForceProviders.
  */
 static void
@@ -537,18 +534,16 @@ computeSpecialForces(FILE                          *fplog,
                      gmx::ArrayRef<const gmx::RVec> x,
                      const t_mdatoms               *mdatoms,
                      real                          *lambda,
-                     int                            forceFlags,
+                     const gmx::ForceFlags         &forceFlags,
                      gmx::ForceWithVirial          *forceWithVirial,
                      gmx_enerdata_t                *enerd,
                      gmx_edsam                     *ed,
-                     gmx_bool                       bNS)
+                     bool                           didNeighborSearch)
 {
-    const bool computeForces = (forceFlags & GMX_FORCE_FORCES) != 0;
-
     /* NOTE: Currently all ForceProviders only provide forces.
      *       When they also provide energies, remove this conditional.
      */
-    if (computeForces)
+    if (forceFlags.computeForces)
     {
         gmx::ForceProviderInput  forceProviderInput(x, *mdatoms, t, box, *cr);
         gmx::ForceProviderOutput forceProviderOutput(forceWithVirial, enerd);
@@ -590,11 +585,11 @@ computeSpecialForces(FILE                          *fplog,
          * Thus if no other algorithm (e.g. PME) requires it, the forces
          * here will contribute to the virial.
          */
-        do_flood(cr, inputrec, as_rvec_array(x.data()), f, ed, box, step, bNS);
+        do_flood(cr, inputrec, as_rvec_array(x.data()), f, ed, box, step, didNeighborSearch);
     }
 
     /* Add forces from interactive molecular dynamics (IMD), if any */
-    if (inputrec->bIMD && computeForces)
+    if (inputrec->bIMD && forceFlags.computeForces)
     {
         imdSession->applyForces(f);
     }
@@ -605,18 +600,18 @@ computeSpecialForces(FILE                          *fplog,
  * \param[in]  pmedata       The PME structure
  * \param[in]  box           The box matrix
  * \param[in]  x             Coordinate array
- * \param[in]  flags         Force flags
+ * \param[in]  forceFlags    Force schedule flags
  * \param[in]  pmeFlags      PME flags
  * \param[in]  wcycle        The wallcycle structure
  */
-static inline void launchPmeGpuSpread(gmx_pme_t      *pmedata,
-                                      const matrix    box,
-                                      const rvec      x[],
-                                      int             flags,
-                                      int             pmeFlags,
-                                      gmx_wallcycle_t wcycle)
+static inline void launchPmeGpuSpread(gmx_pme_t             *pmedata,
+                                      const matrix           box,
+                                      const rvec             x[],
+                                      const gmx::ForceFlags &forceFlags,
+                                      int                    pmeFlags,
+                                      gmx_wallcycle_t        wcycle)
 {
-    pme_gpu_prepare_computation(pmedata, (flags & GMX_FORCE_DYNAMICBOX) != 0, box, wcycle, pmeFlags);
+    pme_gpu_prepare_computation(pmedata, forceFlags.haveDynamicBox, box, wcycle, pmeFlags);
     pme_gpu_launch_spread(pmedata, x, wcycle);
 }
 
@@ -683,7 +678,7 @@ static void alternatePmeNbGpuWaitReduce(nonbonded_verlet_t                  *nbv
         {
             GpuTaskCompletion completionType = (isPmeGpuDone) ? GpuTaskCompletion::Wait : GpuTaskCompletion::Check;
             isNbGpuDone = Nbnxm::gpu_try_finish_task(nbv->gpu_nbv,
-                                                     flags,
+                                                     flags, // FIXME remove this
                                                      Nbnxm::AtomLocality::Local,
                                                      enerd->grpp.ener[egLJSR].data(),
                                                      enerd->grpp.ener[egCOULSR].data(),
@@ -704,8 +699,7 @@ static void alternatePmeNbGpuWaitReduce(nonbonded_verlet_t                  *nbv
  * \param[in] pull_work The pull work object.
  * \param[in] inputrec  input record
  * \param[in] force     force array
- * \param[in] bDoForces True if force are computed this step
- * \param[in] doVirial  True if virial is computed this step
+ * \param[in] forceFlags Force schedule flags
  * \param[out] wcycle   wallcycle recording structure
  *
  * \returns             Cleared force output structure
@@ -715,16 +709,15 @@ setupForceOutputs(t_forcerec                          *fr,
                   pull_t                              *pull_work,
                   const t_inputrec                    &inputrec,
                   gmx::ArrayRefWithPadding<gmx::RVec>  force,
-                  const bool                           bDoForces,
-                  const bool                           doVirial,
+                  const gmx::ForceFlags               &forceFlags,
                   gmx_wallcycle_t                      wcycle)
 {
     wallcycle_sub_start(wcycle, ewcsCLEAR_FORCE_BUFFER);
 
     /* NOTE: We assume fr->shiftForces is all zeros here */
-    gmx::ForceWithShiftForces forceWithShiftForces(force, doVirial, fr->shiftForces);
+    gmx::ForceWithShiftForces forceWithShiftForces(force, forceFlags.computeVirial, fr->shiftForces);
 
-    if (bDoForces)
+    if (forceFlags.computeForces)
     {
         /* Clear the short- and long-range forces */
         clear_rvecs_omp(fr->natoms_force_constr,
@@ -736,12 +729,12 @@ setupForceOutputs(t_forcerec                          *fr,
      * directly, such as PME. Otherwise, forceWithVirial uses the
      * the same force (f in legacy calls) buffer as other algorithms.
      */
-    const bool useSeparateForceWithVirialBuffer = (bDoForces && (doVirial && fr->haveDirectVirialContributions));
-
+    const bool useSeparateForceWithVirialBuffer = (forceFlags.computeForces &&
+                                                   (forceFlags.computeVirial && fr->haveDirectVirialContributions));
     /* forceWithVirial uses the local atom range only */
     gmx::ForceWithVirial forceWithVirial(useSeparateForceWithVirialBuffer ?
                                          fr->forceBufferForDirectVirialContributions : force.unpaddedArrayRef(),
-                                         doVirial);
+                                         forceFlags.computeVirial);
 
     if (useSeparateForceWithVirialBuffer)
     {
@@ -773,23 +766,44 @@ setupForceOutputs(t_forcerec                          *fr,
  *
  */
 static void
-setupForceWorkload(gmx::PpForceWorkload *forceWork,
-                   const t_inputrec     *inputrec,
-                   const t_forcerec     *fr,
-                   const pull_t         *pull_work,
-                   const gmx_edsam      *ed,
-                   const t_idef         &idef,
-                   const t_fcdata       *fcd,
-                   const int             forceFlags
+setupForceWorkload(gmx::PpForceWorkload  *forceWork,
+                   const t_inputrec      *inputrec,
+                   const t_forcerec      *fr,
+                   const pull_t          *pull_work,
+                   const gmx_edsam       *ed,
+                   const t_idef          &idef,
+                   const t_fcdata        *fcd,
+                   const gmx::ForceFlags &forceFlags
                    )
 {
-    forceWork->haveSpecialForces      = haveSpecialForces(inputrec, fr->forceProviders, pull_work, forceFlags, ed);
+    forceWork->haveSpecialForces      = haveSpecialForces(inputrec, fr->forceProviders, pull_work, forceFlags.computeForces, ed);
     forceWork->haveCpuBondedWork      = haveCpuBondeds(*fr);
     forceWork->haveGpuBondedWork      = ((fr->gpuBonded != nullptr) && fr->gpuBonded->haveInteractions());
     forceWork->haveRestraintsWork     = havePositionRestraints(idef, *fcd);
     forceWork->haveCpuListedForceWork = haveCpuListedForces(*fr, idef, *fcd);
 }
 
+/*! \brief Set up force flag stuct from the force bitmask.
+ *
+ * \param[out]     flags                Force schedule flags
+ * \param[in]      legacyFlags          Force bitmask flags used to construct the new flags
+ * \param[in]      isNonbondedOn        Global override, if false forces to turn off all nonbonded calculation.
+ */
+static void
+setupForceFlags(gmx::ForceFlags *flags,
+                const int        legacyFlags,
+                const bool       isNonbondedOn)
+{
+    flags->stateChanged           = ((legacyFlags & GMX_FORCE_STATECHANGED) != 0);
+    flags->haveDynamicBox         = ((legacyFlags & GMX_FORCE_DYNAMICBOX) != 0);
+    flags->doNeighborSearch       = ((legacyFlags & GMX_FORCE_NS) != 0);
+    flags->computeVirial          = ((legacyFlags & GMX_FORCE_VIRIAL) != 0);
+    flags->computeEnergy          = ((legacyFlags & GMX_FORCE_ENERGY) != 0);
+    flags->computeForces          = ((legacyFlags & GMX_FORCE_FORCES) != 0);
+    flags->computeListedForces    = ((legacyFlags & GMX_FORCE_LISTED) != 0);
+    flags->computeNonbondedForces = ((legacyFlags & GMX_FORCE_NONBONDED) != 0) && isNonbondedOn;
+}
+
 
 /* \brief Launch end-of-step GPU tasks: buffer clearing and rolling pruning.
  *
@@ -797,16 +811,15 @@ setupForceWorkload(gmx::PpForceWorkload *forceWork,
  * incorporated in PpForceWorkload.
  */
 static void
-launchGpuEndOfStepTasks(nonbonded_verlet_t         *nbv,
-                        gmx::GpuBonded             *gpuBonded,
-                        gmx_pme_t                  *pmedata,
-                        gmx_enerdata_t             *enerd,
-                        const gmx::PpForceWorkload &forceWorkload,
-                        bool                        useGpuNonbonded,
-                        bool                        useGpuPme,
-                        int64_t                     step,
-                        int                         flags,
-                        gmx_wallcycle_t             wcycle)
+launchGpuEndOfStepTasks(nonbonded_verlet_t            *nbv,
+                        gmx::GpuBonded                *gpuBonded,
+                        gmx_pme_t                     *pmedata,
+                        gmx_enerdata_t                *enerd,
+                        const gmx::MdScheduleWorkload &mdScheduleWork,
+                        bool                           useGpuNonbonded,
+                        bool                           useGpuPme,
+                        int64_t                        step,
+                        gmx_wallcycle_t                wcycle)
 {
     if (useGpuNonbonded)
     {
@@ -822,7 +835,7 @@ launchGpuEndOfStepTasks(nonbonded_verlet_t         *nbv,
         /* now clear the GPU outputs while we finish the step on the CPU */
         wallcycle_start_nocount(wcycle, ewcLAUNCH_GPU);
         wallcycle_sub_start_nocount(wcycle, ewcsLAUNCH_GPU_NONBONDED);
-        Nbnxm::gpu_clear_outputs(nbv->gpu_nbv, flags);
+        Nbnxm::gpu_clear_outputs(nbv->gpu_nbv, mdScheduleWork.forceFlags.computeVirial);
         wallcycle_sub_stop(wcycle, ewcsLAUNCH_GPU_NONBONDED);
         wallcycle_stop(wcycle, ewcLAUNCH_GPU);
     }
@@ -832,7 +845,7 @@ launchGpuEndOfStepTasks(nonbonded_verlet_t         *nbv,
         pme_gpu_reinit_computation(pmedata, wcycle);
     }
 
-    if (forceWorkload.haveGpuBondedWork && (flags & GMX_FORCE_ENERGY))
+    if (mdScheduleWork.forceWork.haveGpuBondedWork && mdScheduleWork.forceFlags.computeEnergy)
     {
         // in principle this should be included in the DD balancing region,
         // but generally it is infrequent so we'll omit it for the sake of
@@ -867,7 +880,7 @@ void do_force(FILE                                     *fplog,
               gmx::ArrayRef<real>                       lambda,
               t_graph                                  *graph,
               t_forcerec                               *fr,
-              gmx::PpForceWorkload                     *ppForceWorkload,
+              gmx::MdScheduleWorkload                  *mdScheduleWork,
               const gmx_vsite_t                        *vsite,
               rvec                                      mu_tot,
               double                                    t,
@@ -877,21 +890,23 @@ void do_force(FILE                                     *fplog,
 {
     int                  i, j;
     double               mu[2*DIM];
-    gmx_bool             bStateChanged, bNS, bFillGrid, bCalcCGCM;
-    gmx_bool             bDoForces, bUseGPU, bUseOrEmulGPU;
+    gmx_bool             bFillGrid, bCalcCGCM;
+    gmx_bool             bUseGPU, bUseOrEmulGPU;
     nonbonded_verlet_t  *nbv = fr->nbv.get();
     interaction_const_t *ic  = fr->ic;
 
+    // TODO remove the code below when the legacy flags are not in use anymore
     /* modify force flag if not doing nonbonded */
     if (!fr->bNonbonded)
     {
         flags &= ~GMX_FORCE_NONBONDED;
     }
-    bStateChanged = ((flags & GMX_FORCE_STATECHANGED) != 0);
-    bNS           = ((flags & GMX_FORCE_NS) != 0);
-    bFillGrid     = (bNS && bStateChanged);
+    setupForceFlags(&mdScheduleWork->forceFlags, flags, fr->bNonbonded);
+
+    const gmx::ForceFlags &forceFlags = mdScheduleWork->forceFlags;
+
+    bFillGrid     = (forceFlags.doNeighborSearch && forceFlags.stateChanged);
     bCalcCGCM     = (bFillGrid && !DOMAINDECOMP(cr));
-    bDoForces     = ((flags & GMX_FORCE_FORCES) != 0);
     bUseGPU       = fr->nbv->useGpu();
     bUseOrEmulGPU = bUseGPU || fr->nbv->emulateGpu();
 
@@ -900,9 +915,9 @@ void do_force(FILE                                     *fplog,
     const bool useGpuPme  = EEL_PME(fr->ic->eeltype) && thisRankHasDuty(cr, DUTY_PME) &&
         ((pmeRunMode == PmeRunMode::GPU) || (pmeRunMode == PmeRunMode::Mixed));
     const int  pmeFlags = GMX_PME_SPREAD | GMX_PME_SOLVE |
-        ((flags & GMX_FORCE_VIRIAL) ? GMX_PME_CALC_ENER_VIR : 0) |
-        ((flags & GMX_FORCE_ENERGY) ? GMX_PME_CALC_ENER_VIR : 0) |
-        ((flags & GMX_FORCE_FORCES) ? GMX_PME_CALC_F : 0);
+        (forceFlags.computeVirial   ? GMX_PME_CALC_ENER_VIR : 0) |
+        (forceFlags.computeEnergy ? GMX_PME_CALC_ENER_VIR : 0) |
+        (forceFlags.computeForces   ? GMX_PME_CALC_F : 0);
 
     // Switches on whether to use GPU for position and force buffer operations
     // TODO consider all possible combinations of triggers, and how to combine optimally in each case.
@@ -910,7 +925,7 @@ void do_force(FILE                                     *fplog,
         BufferOpsUseGpu::True : BufferOpsUseGpu::False;;
     // GPU Force buffer ops are disabled on virial steps, because the virial calc is not yet ported to GPU
     const BufferOpsUseGpu useGpuFBufOps = (c_enableGpuBufOps && bUseGPU && (GMX_GPU == GMX_GPU_CUDA))
-        && !(flags & (GMX_FORCE_VIRIAL | GMX_FORCE_ENERGY)) ?
+        && !(forceFlags.computeVirial || forceFlags.computeEnergy) ?
         BufferOpsUseGpu::True : BufferOpsUseGpu::False;
     // TODO: move / add this flag to the internal PME GPU data structures
     const bool useGpuFPmeReduction = (useGpuFBufOps == BufferOpsUseGpu::True) &&
@@ -920,7 +935,7 @@ void do_force(FILE                                     *fplog,
      * somewhere early inside the step after communication during domain
      * decomposition (and not during the previous step as usual).
      */
-    if (bNS)
+    if (forceFlags.doNeighborSearch)
     {
         ddBalanceRegionHandler.openBeforeForceComputationCpu(DdAllowBalanceRegionReopen::yes);
     }
@@ -930,7 +945,7 @@ void do_force(FILE                                     *fplog,
 
     clear_mat(vir_force);
 
-    if (bStateChanged)
+    if (forceFlags.stateChanged)
     {
         if (inputrecNeedMutot(inputrec))
         {
@@ -948,7 +963,7 @@ void do_force(FILE                                     *fplog,
         /* Compute shift vectors every step,
          * because of pressure coupling or box deformation!
          */
-        if ((flags & GMX_FORCE_DYNAMICBOX) && bStateChanged)
+        if (forceFlags.haveDynamicBox && forceFlags.stateChanged)
         {
             calc_shifts(box, fr->shift_vec);
         }
@@ -964,7 +979,7 @@ void do_force(FILE                                     *fplog,
         }
     }
 
-    nbnxn_atomdata_copy_shiftvec((flags & GMX_FORCE_DYNAMICBOX) != 0,
+    nbnxn_atomdata_copy_shiftvec(forceFlags.haveDynamicBox,
                                  fr->shift_vec, nbv->nbat.get());
 
 #if GMX_MPI
@@ -977,20 +992,20 @@ void do_force(FILE                                     *fplog,
          */
         gmx_pme_send_coordinates(cr, box, as_rvec_array(x.unpaddedArrayRef().data()),
                                  lambda[efptCOUL], lambda[efptVDW],
-                                 (flags & (GMX_FORCE_VIRIAL | GMX_FORCE_ENERGY)) != 0,
+                                 (forceFlags.computeVirial || forceFlags.computeEnergy),
                                  step, wcycle);
     }
 #endif /* GMX_MPI */
 
     if (useGpuPme)
     {
-        launchPmeGpuSpread(fr->pmedata, box, as_rvec_array(x.unpaddedArrayRef().data()), flags, pmeFlags, wcycle);
+        launchPmeGpuSpread(fr->pmedata, box, as_rvec_array(x.unpaddedArrayRef().data()), forceFlags, pmeFlags, wcycle);
     }
 
     /* do gridding for pair search */
-    if (bNS)
+    if (forceFlags.doNeighborSearch)
     {
-        if (graph && bStateChanged)
+        if (graph && forceFlags.stateChanged)
         {
             /* Calculate intramolecular shift vectors to make molecules whole */
             mk_mshift(fplog, graph, fr->ePBC, box, as_rvec_array(x.unpaddedArrayRef().data()));
@@ -1058,23 +1073,26 @@ void do_force(FILE                                     *fplog,
             }
             wallcycle_stop(wcycle, ewcLAUNCH_GPU);
         }
-
-        // Need to run after the GPU-offload bonded interaction lists
-        // are set up to be able to determine whether there is bonded work.
-        setupForceWorkload(ppForceWorkload,
-                           inputrec,
-                           fr,
-                           pull_work,
-                           ed,
-                           top->idef,
-                           fcd,
-                           flags);
     }
 
+    // Call it per-step as force-flags can change.
+    // Need to run after the GPU-offload bonded interaction lists
+    // are set up to be able to determine whether there is bonded work.
+    setupForceWorkload(&mdScheduleWork->forceWork,
+                       inputrec,
+                       fr,
+                       pull_work,
+                       ed,
+                       top->idef,
+                       fcd,
+                       forceFlags);
+
+    const gmx::PpForceWorkload &forceWork = mdScheduleWork->forceWork;
+
     /* do local pair search */
-    if (bNS)
+    if (forceFlags.doNeighborSearch)
     {
-        // TODO: fuse this branch with the above bNS block
+        // TODO: fuse this branch with the above forceFlags.doNeighborSearch block
         wallcycle_start_nocount(wcycle, ewcNS);
         wallcycle_sub_start(wcycle, ewcsNBS_SEARCH_LOCAL);
         /* Note that with a GPU the launch overhead of the list transfer is not timed separately */
@@ -1112,7 +1130,7 @@ void do_force(FILE                                     *fplog,
 
         wallcycle_sub_start(wcycle, ewcsLAUNCH_GPU_NONBONDED);
         Nbnxm::gpu_upload_shiftvec(nbv->gpu_nbv, nbv->nbat.get());
-        if (bNS || (useGpuXBufOps == BufferOpsUseGpu::False))
+        if (forceFlags.doNeighborSearch || (useGpuXBufOps == BufferOpsUseGpu::False))
         {
             Nbnxm::gpu_copy_xq_to_gpu(nbv->gpu_nbv, nbv->nbat.get(),
                                       Nbnxm::AtomLocality::Local);
@@ -1122,10 +1140,10 @@ void do_force(FILE                                     *fplog,
 
         // bonded work not split into separate local and non-local, so with DD
         // we can only launch the kernel after non-local coordinates have been received.
-        if (ppForceWorkload->haveGpuBondedWork && !havePPDomainDecomposition(cr))
+        if (forceWork.haveGpuBondedWork && !havePPDomainDecomposition(cr))
         {
             wallcycle_sub_start(wcycle, ewcsLAUNCH_GPU_BONDED);
-            fr->gpuBonded->launchKernel(fr, flags, box);
+            fr->gpuBonded->launchKernel(fr, forceFlags, box);
             wallcycle_sub_stop(wcycle, ewcsLAUNCH_GPU_BONDED);
         }
 
@@ -1150,9 +1168,9 @@ void do_force(FILE                                     *fplog,
        do non-local pair search */
     if (havePPDomainDecomposition(cr))
     {
-        if (bNS)
+        if (forceFlags.doNeighborSearch)
         {
-            // TODO: fuse this branch with the above large bNS block
+            // TODO: fuse this branch with the above large forceFlags.doNeighborSearch block
             wallcycle_start_nocount(wcycle, ewcNS);
             wallcycle_sub_start(wcycle, ewcsNBS_SEARCH_NONLOCAL);
             /* Note that with a GPU the launch overhead of the list transfer is not timed separately */
@@ -1176,7 +1194,7 @@ void do_force(FILE                                     *fplog,
         {
             wallcycle_start(wcycle, ewcLAUNCH_GPU);
 
-            if (bNS || (useGpuXBufOps == BufferOpsUseGpu::False))
+            if (forceFlags.doNeighborSearch || (useGpuXBufOps == BufferOpsUseGpu::False))
             {
                 wallcycle_sub_start(wcycle, ewcsLAUNCH_GPU_NONBONDED);
                 Nbnxm::gpu_copy_xq_to_gpu(nbv->gpu_nbv, nbv->nbat.get(),
@@ -1184,10 +1202,10 @@ void do_force(FILE                                     *fplog,
                 wallcycle_sub_stop(wcycle, ewcsLAUNCH_GPU_NONBONDED);
             }
 
-            if (ppForceWorkload->haveGpuBondedWork)
+            if (forceWork.haveGpuBondedWork)
             {
                 wallcycle_sub_start(wcycle, ewcsLAUNCH_GPU_BONDED);
-                fr->gpuBonded->launchKernel(fr, flags, box);
+                fr->gpuBonded->launchKernel(fr, forceFlags, box);
                 wallcycle_sub_stop(wcycle, ewcsLAUNCH_GPU_BONDED);
             }
 
@@ -1212,21 +1230,22 @@ void do_force(FILE                                     *fplog,
         if (havePPDomainDecomposition(cr))
         {
             Nbnxm::gpu_launch_cpyback(nbv->gpu_nbv, nbv->nbat.get(),
+                                      // FIXME
                                       flags, Nbnxm::AtomLocality::NonLocal, copyBackNbForce);
         }
         Nbnxm::gpu_launch_cpyback(nbv->gpu_nbv, nbv->nbat.get(),
+                                  // FIXME
                                   flags, Nbnxm::AtomLocality::Local, copyBackNbForce);
-
         wallcycle_sub_stop(wcycle, ewcsLAUNCH_GPU_NONBONDED);
 
-        if (ppForceWorkload->haveGpuBondedWork && (flags & GMX_FORCE_ENERGY))
+        if (forceWork.haveGpuBondedWork && forceFlags.computeEnergy)
         {
             fr->gpuBonded->launchEnergyTransfer();
         }
         wallcycle_stop(wcycle, ewcLAUNCH_GPU);
     }
 
-    if (bStateChanged && inputrecNeedMutot(inputrec))
+    if (forceFlags.stateChanged && inputrecNeedMutot(inputrec))
     {
         if (PAR(cr))
         {
@@ -1275,7 +1294,7 @@ void do_force(FILE                                     *fplog,
     if (inputrec->bRot)
     {
         wallcycle_start(wcycle, ewcROT);
-        do_rotation(cr, enforcedRotation, box, as_rvec_array(x.unpaddedArrayRef().data()), t, step, bNS);
+        do_rotation(cr, enforcedRotation, box, as_rvec_array(x.unpaddedArrayRef().data()), t, step, forceFlags.doNeighborSearch);
         wallcycle_stop(wcycle, ewcROT);
     }
 
@@ -1286,8 +1305,7 @@ void do_force(FILE                                     *fplog,
 
     // Set up and clear force outputs.
     // We use std::move to keep the compiler happy, it has no effect.
-    ForceOutputs forceOut = setupForceOutputs(fr, pull_work, *inputrec, std::move(force), bDoForces,
-                                              ((flags & GMX_FORCE_VIRIAL) != 0), wcycle);
+    ForceOutputs forceOut = setupForceOutputs(fr, pull_work, *inputrec, std::move(force), forceFlags, wcycle);
 
     /* We calculate the non-bonded forces, when done on the CPU, here.
      * We do this before calling do_force_lowlevel, because in that
@@ -1339,7 +1357,7 @@ void do_force(FILE                                     *fplog,
         wallcycle_start_nocount(wcycle, ewcFORCE);
 
         /* If there are multiple fshift output buffers we need to reduce them */
-        if (flags & GMX_FORCE_VIRIAL)
+        if (forceFlags.computeVirial)
         {
             /* This is not in a subcounter because it takes a
                negligible and constant-sized amount of time */
@@ -1367,11 +1385,11 @@ void do_force(FILE                                     *fplog,
     computeSpecialForces(fplog, cr, inputrec, awh, enforcedRotation,
                          imdSession, pull_work, step, t, wcycle,
                          fr->forceProviders, box, x.unpaddedArrayRef(), mdatoms, lambda.data(),
-                         flags, &forceOut.forceWithVirial(), enerd,
-                         ed, bNS);
+                         forceFlags, &forceOut.forceWithVirial(), enerd,
+                         ed, forceFlags.doNeighborSearch);
 
     bool                   useCpuFPmeReduction = thisRankHasDuty(cr, DUTY_PME) && !useGpuFPmeReduction;
-    bool                   haveCpuForces       = (ppForceWorkload->haveSpecialForces || ppForceWorkload->haveCpuListedForceWork || useCpuFPmeReduction);
+    bool                   haveCpuForces       = (forceWork.haveSpecialForces || forceWork.haveCpuListedForceWork || useCpuFPmeReduction);
 
     // Will store the amount of cycles spent waiting for the GPU that
     // will be later used in the DLB accounting.
@@ -1418,7 +1436,7 @@ void do_force(FILE                                     *fplog,
                 nbv->launch_copy_f_from_gpu(f, Nbnxm::AtomLocality::NonLocal);
             }
 
-            if (fr->nbv->emulateGpu() && (flags & GMX_FORCE_VIRIAL))
+            if (fr->nbv->emulateGpu() && forceFlags.computeVirial)
             {
                 nbnxn_atomdata_add_nbat_fshift_to_fshift(*nbv->nbat,
                                                          forceWithShiftForces.shiftForces());
@@ -1435,7 +1453,7 @@ void do_force(FILE                                     *fplog,
          */
         ddBalanceRegionHandler.closeAfterForceComputationCpu();
 
-        if (bDoForces)
+        if (forceFlags.computeForces)
         {
             if (useGpuFBufOps == BufferOpsUseGpu::True)
             {
@@ -1480,7 +1498,7 @@ void do_force(FILE                                     *fplog,
         if (ddBalanceRegionHandler.useBalancingRegion())
         {
             DdBalanceRegionWaitedForGpu waitedForGpu = DdBalanceRegionWaitedForGpu::yes;
-            if (bDoForces && waitCycles <= gpuWaitApiOverheadMargin)
+            if (forceFlags.computeForces &&  waitCycles <= gpuWaitApiOverheadMargin)
             {
                 /* We measured few cycles, it could be that the kernel
                  * and transfer finished earlier and there was no actual
@@ -1540,10 +1558,9 @@ void do_force(FILE                                     *fplog,
     }
 
     launchGpuEndOfStepTasks(nbv, fr->gpuBonded, fr->pmedata, enerd,
-                            *ppForceWorkload,
+                            *mdScheduleWork,
                             bUseGPU, useGpuPme,
                             step,
-                            flags,
                             wcycle);
 
     if (DOMAINDECOMP(cr))
@@ -1551,21 +1568,21 @@ void do_force(FILE                                     *fplog,
         dd_force_flop_stop(cr->dd, nrnb);
     }
 
-    if (bDoForces)
+    if (forceFlags.computeForces)
     {
         rvec *f = as_rvec_array(forceOut.forceWithShiftForces().force().data());
 
         /* If we have NoVirSum forces, but we do not calculate the virial,
          * we sum fr->f_novirsum=forceOut.f later.
          */
-        if (vsite && !(fr->haveDirectVirialContributions && !(flags & GMX_FORCE_VIRIAL)))
+        if (vsite && !(fr->haveDirectVirialContributions && !forceFlags.computeVirial))
         {
             rvec *fshift = as_rvec_array(forceOut.forceWithShiftForces().shiftForces().data());
             spread_vsite_f(vsite, as_rvec_array(x.unpaddedArrayRef().data()), f, fshift, FALSE, nullptr, nrnb,
                            &top->idef, fr->ePBC, fr->bMolPBC, graph, box, cr, wcycle);
         }
 
-        if (flags & GMX_FORCE_VIRIAL)
+        if (forceFlags.computeVirial)
         {
             /* Calculation of the virial must be done after vsites! */
             calc_virial(0, mdatoms->homenr, as_rvec_array(x.unpaddedArrayRef().data()),
@@ -1582,15 +1599,15 @@ void do_force(FILE                                     *fplog,
         pme_receive_force_ener(cr, &forceOut.forceWithVirial(), enerd, wcycle);
     }
 
-    if (bDoForces)
+    if (forceFlags.computeForces)
     {
         post_process_forces(cr, step, nrnb, wcycle,
                             top, box, as_rvec_array(x.unpaddedArrayRef().data()), &forceOut,
                             vir_force, mdatoms, graph, fr, vsite,
-                            flags);
+                            forceFlags);
     }
 
-    if (flags & GMX_FORCE_ENERGY)
+    if (forceFlags.computeEnergy)
     {
         /* Sum the potential energy terms from group contributions */
         sum_epot(&(enerd->grpp), enerd->term);
index a2b24a69df9060d96a105ffd7593c4304d8ea24a..86cd154c9c2955291667bf0f877dee9154b64a0e 100644 (file)
@@ -71,7 +71,7 @@ namespace gmx
 enum class StartingBehavior;
 class BoxDeformation;
 class Constraints;
-class PpForceWorkload;
+class MdScheduleWorkload;
 class IMDOutputProvider;
 struct MdModulesNotifier;
 class ImdSession;
@@ -129,7 +129,7 @@ class ISimulator
             t_forcerec                         *fr,
             gmx_enerdata_t                     *enerd,
             gmx_ekindata_t                     *ekind,
-            PpForceWorkload                    *ppForceWorkload,
+            MdScheduleWorkload                 *mdScheduleWork,
             const ReplicaExchangeParameters    &replExParams,
             gmx_membed_t                       *membed,
             gmx_walltime_accounting            *walltime_accounting,
@@ -164,7 +164,7 @@ class ISimulator
             fr(fr),
             enerd(enerd),
             ekind(ekind),
-            ppForceWorkload(ppForceWorkload),
+            mdScheduleWork(mdScheduleWork),
             replExParams(replExParams),
             membed(membed),
             walltime_accounting(walltime_accounting),
@@ -231,8 +231,8 @@ class ISimulator
         gmx_enerdata_t                     *enerd;
         //! Kinetic energy data.
         gmx_ekindata_t                     *ekind;
-        //! Schedule of force-calculation work each step for this task.
-        PpForceWorkload                    *ppForceWorkload;
+        //! Schedule of work for each MD step for this task.
+        MdScheduleWorkload                 *mdScheduleWork;
         //! Parameters for replica exchange algorihtms.
         const ReplicaExchangeParameters    &replExParams;
         //! Parameters for membrane embedding.
index 8c9184aff3995cdce200f1fe9d0775ad9b28c7b9..18dc39041dc83743567e2a93e8a0d559e4fe2b82 100644 (file)
@@ -906,7 +906,7 @@ void gmx::LegacySimulator::do_md()
                                 &state->hist,
                                 f.arrayRefWithPadding(), force_vir, mdatoms,
                                 nrnb, wcycle, graph,
-                                shellfc, fr, ppForceWorkload, t, mu_tot,
+                                shellfc, fr, mdScheduleWork, t, mu_tot,
                                 vsite,
                                 ddBalanceRegionHandler);
         }
@@ -936,7 +936,7 @@ void gmx::LegacySimulator::do_md()
                      state->box, state->x.arrayRefWithPadding(), &state->hist,
                      f.arrayRefWithPadding(), force_vir, mdatoms, enerd, fcd,
                      state->lambda, graph,
-                     fr, ppForceWorkload, vsite, mu_tot, t, ed ? ed->getLegacyED() : nullptr,
+                     fr, mdScheduleWork, vsite, mu_tot, t, ed ? ed->getLegacyED() : nullptr,
                      (bNS ? GMX_FORCE_NS : 0) | force_flags,
                      ddBalanceRegionHandler);
         }
index bc106870ba2bb524d42f2b30f3476a647778e481..bdc0da71758bbe5c6b90d4e7100935e10780a03a 100644 (file)
@@ -436,7 +436,7 @@ void gmx::LegacySimulator::do_mimic()
                                 &state->hist,
                                 f.arrayRefWithPadding(), force_vir, mdatoms,
                                 nrnb, wcycle, graph,
-                                shellfc, fr, ppForceWorkload, t, mu_tot,
+                                shellfc, fr, mdScheduleWork, t, mu_tot,
                                 vsite,
                                 ddBalanceRegionHandler);
         }
@@ -455,7 +455,7 @@ void gmx::LegacySimulator::do_mimic()
                      state->box, state->x.arrayRefWithPadding(), &state->hist,
                      f.arrayRefWithPadding(), force_vir, mdatoms, enerd, fcd,
                      state->lambda, graph,
-                     fr, ppForceWorkload, vsite, mu_tot, t, ed,
+                     fr, mdScheduleWork, vsite, mu_tot, t, ed,
                      GMX_FORCE_NS | force_flags,
                      ddBalanceRegionHandler);
         }
index e6d9148121f5df6cf41f328c341939be57e473a4..c83f1658063f7e85cb6c89383cb47aa28a509785 100644 (file)
@@ -754,45 +754,45 @@ class EnergyEvaluator
                  tensor vir, tensor pres,
                  int64_t count, gmx_bool bFirst);
         //! Handles logging (deprecated).
-        FILE                 *fplog;
+        FILE                    *fplog;
         //! Handles logging.
-        const gmx::MDLogger  &mdlog;
+        const gmx::MDLogger     &mdlog;
         //! Handles communication.
-        const t_commrec      *cr;
+        const t_commrec         *cr;
         //! Coordinates multi-simulations.
-        const gmx_multisim_t *ms;
+        const gmx_multisim_t    *ms;
         //! Holds the simulation topology.
-        gmx_mtop_t           *top_global;
+        gmx_mtop_t              *top_global;
         //! Holds the domain topology.
-        gmx_localtop_t       *top;
+        gmx_localtop_t          *top;
         //! User input options.
-        t_inputrec           *inputrec;
+        t_inputrec              *inputrec;
         //! The Interactive Molecular Dynamics session.
-        gmx::ImdSession      *imdSession;
+        gmx::ImdSession         *imdSession;
         //! The pull work object.
-        pull_t               *pull_work;
+        pull_t                  *pull_work;
         //! Manages flop accounting.
-        t_nrnb               *nrnb;
+        t_nrnb                  *nrnb;
         //! Manages wall cycle accounting.
-        gmx_wallcycle_t       wcycle;
+        gmx_wallcycle_t          wcycle;
         //! Coordinates global reduction.
-        gmx_global_stat_t     gstat;
+        gmx_global_stat_t        gstat;
         //! Handles virtual sites.
-        gmx_vsite_t          *vsite;
+        gmx_vsite_t             *vsite;
         //! Handles constraints.
-        gmx::Constraints     *constr;
+        gmx::Constraints        *constr;
         //! Handles strange things.
-        t_fcdata             *fcd;
+        t_fcdata                *fcd;
         //! Molecular graph for SHAKE.
-        t_graph              *graph;
+        t_graph                 *graph;
         //! Per-atom data for this domain.
-        gmx::MDAtoms         *mdAtoms;
+        gmx::MDAtoms            *mdAtoms;
         //! Handles how to calculate the forces.
-        t_forcerec           *fr;
+        t_forcerec              *fr;
         //! Schedule of force-calculation work each step for this task.
-        gmx::PpForceWorkload *ppForceWorkload;
+        gmx::MdScheduleWorkload *mdScheduleWork;
         //! Stores the computed energies.
-        gmx_enerdata_t       *enerd;
+        gmx_enerdata_t          *enerd;
 };
 
 void
@@ -849,7 +849,7 @@ EnergyEvaluator::run(em_state_t *ems, rvec mu_tot,
              count, nrnb, wcycle, top,
              ems->s.box, ems->s.x.arrayRefWithPadding(), &ems->s.hist,
              ems->f.arrayRefWithPadding(), force_vir, mdAtoms->mdatoms(), enerd, fcd,
-             ems->s.lambda, graph, fr, ppForceWorkload, vsite, mu_tot, t, nullptr,
+             ems->s.lambda, graph, fr, mdScheduleWork, vsite, mu_tot, t, nullptr,
              GMX_FORCE_STATECHANGED | GMX_FORCE_ALLFORCES |
              GMX_FORCE_VIRIAL | GMX_FORCE_ENERGY |
              (bNS ? GMX_FORCE_NS : 0),
@@ -1137,7 +1137,7 @@ LegacySimulator::do_cg()
         top_global, &top,
         inputrec, imdSession, pull_work, nrnb, wcycle, gstat,
         vsite, constr, fcd, graph,
-        mdAtoms, fr, ppForceWorkload, enerd
+        mdAtoms, fr, mdScheduleWork, enerd
     };
     /* Call the force routine and some auxiliary (neighboursearching etc.) */
     /* do_force always puts the charge groups in the box and shifts again
@@ -1817,7 +1817,7 @@ LegacySimulator::do_lbfgs()
         top_global, &top,
         inputrec, imdSession, pull_work, nrnb, wcycle, gstat,
         vsite, constr, fcd, graph,
-        mdAtoms, fr, ppForceWorkload, enerd
+        mdAtoms, fr, mdScheduleWork, enerd
     };
     energyEvaluator.run(&ems, mu_tot, vir, pres, -1, TRUE);
 
@@ -2477,7 +2477,7 @@ LegacySimulator::do_steep()
         top_global, &top,
         inputrec, imdSession, pull_work, nrnb, wcycle, gstat,
         vsite, constr, fcd, graph,
-        mdAtoms, fr, ppForceWorkload, enerd
+        mdAtoms, fr, mdScheduleWork, enerd
     };
 
     /**** HERE STARTS THE LOOP ****
@@ -2782,7 +2782,7 @@ LegacySimulator::do_nm()
         top_global, &top,
         inputrec, imdSession, pull_work, nrnb, wcycle, gstat,
         vsite, constr, fcd, graph,
-        mdAtoms, fr, ppForceWorkload, enerd
+        mdAtoms, fr, mdScheduleWork, enerd
     };
     energyEvaluator.run(&state_work, mu_tot, vir, pres, -1, TRUE);
     cr->nnodes = nnodes;
@@ -2869,7 +2869,7 @@ LegacySimulator::do_nm()
                                         graph,
                                         shellfc,
                                         fr,
-                                        ppForceWorkload,
+                                        mdScheduleWork,
                                         t,
                                         mu_tot,
                                         vsite,
index a4b40f4585c565af690330f568c27a80a18c3768..e722f39511cedc13bf049eba7692535715aa1e89 100644 (file)
@@ -558,7 +558,7 @@ void gmx::LegacySimulator::do_rerun()
                                 &state->hist,
                                 f.arrayRefWithPadding(), force_vir, mdatoms,
                                 nrnb, wcycle, graph,
-                                shellfc, fr, ppForceWorkload, t, mu_tot,
+                                shellfc, fr, mdScheduleWork, t, mu_tot,
                                 vsite,
                                 ddBalanceRegionHandler);
         }
@@ -577,7 +577,7 @@ void gmx::LegacySimulator::do_rerun()
                      state->box, state->x.arrayRefWithPadding(), &state->hist,
                      f.arrayRefWithPadding(), force_vir, mdatoms, enerd, fcd,
                      state->lambda, graph,
-                     fr, ppForceWorkload, vsite, mu_tot, t, ed,
+                     fr, mdScheduleWork, vsite, mu_tot, t, ed,
                      GMX_FORCE_NS | force_flags,
                      ddBalanceRegionHandler);
         }
index 6333756b1a0cfaa4e64372f1ebbbee31a1ab63d5..717c8c578c248167b5ad9c74e93e23ebe3b22c16 100644 (file)
@@ -1490,10 +1490,8 @@ int Mdrunner::mdrunner()
 
         // TODO This is not the right place to manage the lifetime of
         // this data structure, but currently it's the easiest way to
-        // make it work. Later, it should probably be made/updated
-        // after the workload for the lifetime of a PP domain is
-        // understood.
-        PpForceWorkload ppForceWorkload;
+        // make it work.
+        MdScheduleWorkload mdScheduleWork;
 
         GMX_ASSERT(stopHandlerBuilder_, "Runner must provide StopHandlerBuilder to simulator.");
         SimulatorBuilder simulatorBuilder;
@@ -1516,7 +1514,7 @@ int Mdrunner::mdrunner()
                     mdAtoms.get(), &nrnb, wcycle, fr,
                     &enerd,
                     &ekind,
-                    &ppForceWorkload,
+                    &mdScheduleWork,
                     replExParams,
                     membed,
                     walltime_accounting,
index 8c4e39a6e55c6b73ff0406339e326c51f666741f..501e4c843da7cba92277fce2eca422705a60525e 100644 (file)
@@ -998,7 +998,7 @@ void relax_shell_flexcon(FILE                                     *fplog,
                          t_graph                                  *graph,
                          gmx_shellfc_t                            *shfc,
                          t_forcerec                               *fr,
-                         gmx::PpForceWorkload                     *ppForceWorkload,
+                         gmx::MdScheduleWorkload                  *mdScheduleWork,
                          double                                    t,
                          rvec                                      mu_tot,
                          const gmx_vsite_t                        *vsite,
@@ -1134,7 +1134,7 @@ void relax_shell_flexcon(FILE                                     *fplog,
              box, x, hist,
              forceWithPadding[Min], force_vir, md, enerd, fcd,
              lambda, graph,
-             fr, ppForceWorkload, vsite, mu_tot, t, nullptr,
+             fr, mdScheduleWork, vsite, mu_tot, t, nullptr,
              (bDoNS ? GMX_FORCE_NS : 0) | shellfc_flags,
              ddBalanceRegionHandler);
 
@@ -1245,7 +1245,7 @@ void relax_shell_flexcon(FILE                                     *fplog,
                  top, box, posWithPadding[Try], hist,
                  forceWithPadding[Try], force_vir,
                  md, enerd, fcd, lambda, graph,
-                 fr, ppForceWorkload, vsite, mu_tot, t, nullptr,
+                 fr, mdScheduleWork, vsite, mu_tot, t, nullptr,
                  shellfc_flags,
                  ddBalanceRegionHandler);
         sum_epot(&(enerd->grpp), enerd->term);
index f886a6795c6131b1e1aee37ba003f5074ca8607d..d1e723fa6b4d53d6762550217f24a10bf691ee3f 100644 (file)
@@ -61,7 +61,7 @@ namespace gmx
 {
 class Constraints;
 class ImdSession;
-class PpForceWorkload;
+class MdScheduleWorkload;
 }
 
 /* Initialization function, also predicts the initial shell postions.
@@ -101,7 +101,7 @@ void relax_shell_flexcon(FILE                                     *log,
                          t_graph                                  *graph,
                          gmx_shellfc_t                            *shfc,
                          t_forcerec                               *fr,
-                         gmx::PpForceWorkload                     *ppForceWorkload,
+                         gmx::MdScheduleWorkload                  *mdScheduleWork,
                          double                                    t,
                          rvec                                      mu_tot,
                          const gmx_vsite_t                        *vsite,
index 3a84611b7238a4ce1341551d32f7d040c1bf3dd9..3d26aee9909dd7a5c581a9329f1bb5e5c7a1d751 100644 (file)
@@ -72,7 +72,7 @@ namespace gmx
 enum class StartingBehavior;
 class BoxDeformation;
 class Constraints;
-class PpForceWorkload;
+class MdScheduleWorkload;
 class IMDOutputProvider;
 class ImdSession;
 class MDLogger;
index 766391eb76d39b821663a070ad77c9b446a9a668..382a32be2ff2adaf7a4141c2daa2f6dc2fc023dc 100644 (file)
@@ -657,7 +657,7 @@ LegacySimulator::do_tpi()
                      state_global->box, state_global->x.arrayRefWithPadding(), &state_global->hist,
                      f.arrayRefWithPadding(), force_vir, mdatoms, enerd, fcd,
                      state_global->lambda,
-                     nullptr, fr, ppForceWorkload, nullptr, mu_tot, t, nullptr,
+                     nullptr, fr, mdScheduleWork, nullptr, mu_tot, t, nullptr,
                      GMX_FORCE_NONBONDED | GMX_FORCE_ENERGY |
                      (bNS ? GMX_FORCE_DYNAMICBOX | GMX_FORCE_NS : 0) |
                      (bStateChanged ? GMX_FORCE_STATECHANGED : 0),
index 2045043d2c22c830ad69c0ebd340fefccb4a0f15..551f5c22263f1cc16c5e3c8df349bc010d6504b7 100644 (file)
@@ -623,12 +623,13 @@ static void nbnxn_cuda_clear_e_fshift(gmx_nbnxn_cuda_t *nb)
     CU_RET_ERR(stat, "cudaMemsetAsync on e_el falied");
 }
 
-void gpu_clear_outputs(gmx_nbnxn_cuda_t *nb, int flags)
+void gpu_clear_outputs(gmx_nbnxn_cuda_t *nb,
+                       bool              computeVirial)
 {
     nbnxn_cuda_clear_f(nb, nb->atdat->natoms);
     /* clear shift force array and energies if the outputs were
        used in the current step */
-    if (flags & GMX_FORCE_VIRIAL)
+    if (computeVirial)
     {
         nbnxn_cuda_clear_e_fshift(nb);
     }
index 6f6bdd1d729dadde706e550bdd33db17758cdf2c..7196ebe4520cdf65e367cc3f4b0944ef20e84942 100644 (file)
@@ -99,7 +99,7 @@ void gpu_upload_shiftvec(gmx_nbnxn_gpu_t gmx_unused               *nb,
 /** Clears GPU outputs: nonbonded force, shift force and energy. */
 GPU_FUNC_QUALIFIER
 void gpu_clear_outputs(gmx_nbnxn_gpu_t gmx_unused *nb,
-                       int              gmx_unused flags) GPU_FUNC_TERM;
+                       bool            gmx_unused  computeVirial) GPU_FUNC_TERM;
 
 /** Frees all GPU resources used for the nonbonded calculations. */
 GPU_FUNC_QUALIFIER
index 843ffc04331213704fef25a103bfba0250af096c..a531330459199caeaa30288c2c4392a23a1ebdb9 100644 (file)
@@ -771,14 +771,13 @@ static void nbnxn_ocl_clear_f(gmx_nbnxn_ocl_t *nb, int natoms_clear)
 }
 
 //! This function is documented in the header file
-void
-gpu_clear_outputs(gmx_nbnxn_ocl_t   *nb,
-                  const int          flags)
+void gpu_clear_outputs(gmx_nbnxn_ocl_t *nb,
+                       bool             computeVirial)
 {
     nbnxn_ocl_clear_f(nb, nb->atdat->natoms);
     /* clear shift force array and energies if the outputs were
        used in the current step */
-    if (flags & GMX_FORCE_VIRIAL)
+    if (computeVirial)
     {
         nbnxn_ocl_clear_e_fshift(nb);
     }