Add environment variable that changes the meaning of '-update auto'
authorArtem Zhmurov <zhmurov@gmail.com>
Fri, 18 Oct 2019 15:17:06 +0000 (17:17 +0200)
committerMagnus Lundborg <magnus.lundborg@scilifelab.se>
Mon, 21 Oct 2019 09:47:10 +0000 (11:47 +0200)
This change creates 'GMX_FORCE_UPDATE_DEFAULT_GPU', that changes the
default behavior of '-update' option to 'gpu'. Also changed the
gpuupdate Jenkins trigger to set this environment variable.

Refs. #3163.

Change-Id: I4463de3266d97c5f91bac65d3d997cf564e6e880

admin/builds/gromacs.py
src/gromacs/mdrun/runner.cpp
src/gromacs/modularsimulator/modularsimulator.cpp
src/gromacs/taskassignment/decidegpuusage.cpp
src/gromacs/taskassignment/decidegpuusage.h

index ba642b04686bf975037d42f2502bc8270d326c04..4fa518f1864865c2b4d442d5e6b9d8d9d9e87590 100644 (file)
@@ -186,7 +186,7 @@ def do_build(context):
     # GPU update flag enables GPU update+constraints as well as buffer ops (dependency)
     if context.opts.gpuupdate:
         context.env.set_env_var('GMX_USE_GPU_BUFFER_OPS', "1")
-        context.env.set_env_var('GMX_UPDATE_CONSTRAIN_GPU', "1")
+        context.env.set_env_var('GMX_FORCE_UPDATE_DEFAULT_GPU', "1")
 
     regressiontests_path = context.workspace.get_project_dir(Project.REGRESSIONTESTS)
 
index 843f401c282c37b165c4ef8e5cadf502519712e9..74a690ef1bb74439360cd386250e912ab3bf98fa 100644 (file)
@@ -167,21 +167,20 @@ namespace gmx
 {
 
 /*! \brief Structure that holds boolean flags corresponding to the development
- *        features present enabled through environemnt variables.
+ *        features present enabled through environment variables.
  *
  */
 struct DevelopmentFeatureFlags
 {
-    ///! True if the Buffer ops development feature is enabled
+    //! True if the Buffer ops development feature is enabled
     // TODO: when the trigger of the buffer ops offload is fully automated this should go away
-    bool enableGpuBufferOps     = false;
-    ///! True if the update-constraints development feature is enabled
-    // TODO This needs to be reomved when the code gets cleaned up of GMX_UPDATE_CONSTRAIN_GPU
-    bool useGpuUpdateConstrain  = false;
-    ///! True if the GPU halo exchange development feature is enabled
-    bool enableGpuHaloExchange  = false;
-    ///! True if the PME PP direct commuinication GPU development feature is enabled
-    bool enableGpuPmePPComm     = false;
+    bool enableGpuBufferOps      = false;
+    //! If true, forces 'mdrun -update auto' default to 'gpu'
+    bool forceGpuUpdateDefaultOn = false;
+    //! True if the GPU halo exchange development feature is enabled
+    bool enableGpuHaloExchange   = false;
+    //! True if the PME PP direct communication GPU development feature is enabled
+    bool enableGpuPmePPComm      = false;
 };
 
 /*! \brief Manage any development feature flag variables encountered
@@ -210,10 +209,10 @@ static DevelopmentFeatureFlags manageDevelopmentFeatures(const gmx::MDLogger &md
     // getenv results are ignored when clearly they are used.
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-    devFlags.enableGpuBufferOps    = (getenv("GMX_USE_GPU_BUFFER_OPS") != nullptr) && (GMX_GPU == GMX_GPU_CUDA) && useGpuForNonbonded;
-    devFlags.useGpuUpdateConstrain = (getenv("GMX_UPDATE_CONSTRAIN_GPU") != nullptr);
-    devFlags.enableGpuHaloExchange = (getenv("GMX_GPU_DD_COMMS") != nullptr && GMX_THREAD_MPI && (GMX_GPU == GMX_GPU_CUDA));
-    devFlags.enableGpuPmePPComm    = (getenv("GMX_GPU_PME_PP_COMMS") != nullptr && GMX_THREAD_MPI && (GMX_GPU == GMX_GPU_CUDA));
+    devFlags.enableGpuBufferOps      = (getenv("GMX_USE_GPU_BUFFER_OPS") != nullptr) && (GMX_GPU == GMX_GPU_CUDA) && useGpuForNonbonded;
+    devFlags.forceGpuUpdateDefaultOn = (getenv("GMX_FORCE_UPDATE_DEFAULT_GPU") != nullptr);
+    devFlags.enableGpuHaloExchange   = (getenv("GMX_GPU_DD_COMMS") != nullptr && GMX_THREAD_MPI && (GMX_GPU == GMX_GPU_CUDA));
+    devFlags.enableGpuPmePPComm      = (getenv("GMX_GPU_PME_PP_COMMS") != nullptr && GMX_THREAD_MPI && (GMX_GPU == GMX_GPU_CUDA));
 #pragma GCC diagnostic pop
 
     if (devFlags.enableGpuBufferOps)
@@ -230,10 +229,10 @@ static DevelopmentFeatureFlags manageDevelopmentFeatures(const gmx::MDLogger &md
         }
     }
 
-    if (devFlags.useGpuUpdateConstrain)
+    if (devFlags.forceGpuUpdateDefaultOn)
     {
         GMX_LOG(mdlog.warning).asParagraph().appendTextFormatted(
-                "NOTE: This run uses the 'GPU update/constraints' feature, enabled by the GMX_UPDATE_CONSTRAIN_GPU environment variable.");
+                "NOTE: This run will default to '-update gpu' as requested by the GMX_FORCE_UPDATE_DEFAULT_GPU environment variable.");
     }
 
     if (devFlags.enableGpuPmePPComm)
@@ -1537,7 +1536,8 @@ int Mdrunner::mdrunner()
         }
 
         // Before we start the actual simulator, try if we can run the update task on the GPU.
-        useGpuForUpdate = decideWhetherToUseGpuForUpdate(DOMAINDECOMP(cr),
+        useGpuForUpdate = decideWhetherToUseGpuForUpdate(devFlags.forceGpuUpdateDefaultOn,
+                                                         DOMAINDECOMP(cr),
                                                          useGpuForPme,
                                                          useGpuForNonbonded,
                                                          devFlags.enableGpuBufferOps,
index b77321d1764adae31373d61b950580cd4bdfa657..2cc1503ab1d5f9bcd32af4edf77313e2e7c3eefe 100644 (file)
@@ -895,7 +895,7 @@ bool ModularSimulator::isInputCompatible(
                 "Membrane embedding is not supported by the modular simulator.");
     // TODO: Change this to the boolean passed when we merge the user interface change for the GPU update.
     isInputCompatible = isInputCompatible && conditionalAssert(
-                getenv("GMX_UPDATE_CONSTRAIN_GPU") == nullptr,
+                getenv("GMX_FORCE_UPDATE_DEFAULT_GPU") == nullptr,
                 "Integration on the GPU is not supported by the modular simulator.");
     // Modular simulator is centered around NS updates
     // TODO: think how to handle nstlist == 0
index fbf0df5c322a22b14a7d7260d71424cc449fcfcd..e759b2c5db179cf964f323009583bb1c746c12f3 100644 (file)
@@ -491,19 +491,21 @@ bool decideWhetherToUseGpusForBonded(const bool       useGpuForNonbonded,
     return gpusWereDetected && usingOurCpuForPmeOrEwald;
 }
 
-bool decideWhetherToUseGpuForUpdate(bool              isDomainDecomposition,
-                                    bool              useGpuForPme,
-                                    bool              useGpuForNonbonded,
-                                    bool              useGpuForBufferOps,
-                                    TaskTarget        updateTarget,
-                                    bool              gpusWereDetected,
-                                    const t_inputrec &inputrec,
-                                    const MDAtoms    &mdatoms,
-                                    bool              useEssentialDynamics,
-                                    bool              doOrientationRestraints,
-                                    bool              doDistanceRestraints,
-                                    bool              useReplicaExchange)
+bool decideWhetherToUseGpuForUpdate(bool                 forceGpuUpdateDefaultOn,
+                                    bool                 isDomainDecomposition,
+                                    bool                 useGpuForPme,
+                                    bool                 useGpuForNonbonded,
+                                    bool                 useGpuForBufferOps,
+                                    TaskTarget           updateTarget,
+                                    bool                 gpusWereDetected,
+                                    const t_inputrec    &inputrec,
+                                    const MDAtoms       &mdatoms,
+                                    bool                 useEssentialDynamics,
+                                    bool                 doOrientationRestraints,
+                                    bool                 doDistanceRestraints,
+                                    bool                 useReplicaExchange)
 {
+
     if (updateTarget == TaskTarget::Cpu)
     {
         return false;
@@ -580,7 +582,8 @@ bool decideWhetherToUseGpuForUpdate(bool              isDomainDecomposition,
         }
         return false;
     }
-    return (updateTarget == TaskTarget::Gpu);
+
+    return ((forceGpuUpdateDefaultOn && updateTarget == TaskTarget::Auto) || (updateTarget == TaskTarget::Gpu));
 }
 
 }  // namespace gmx
index 2afa571b2029d5ba045f938bd2754f11f5ce87b0..7a3ea2ca8614addc6b50349d96bb748092724c81 100644 (file)
@@ -231,6 +231,7 @@ bool decideWhetherToUseGpusForBonded(bool       useGpuForNonbonded,
 
 /*! \brief Decide whether to use GPU for update.
  *
+ * \param[in]  forceGpuUpdateDefaultOn   If the update should be offloaded by default.
  * \param[in]  isDomainDecomposition     Whether there more than one domain.
  * \param[in]  useGpuForPme              Whether GPUs will be used for PME interactions.
  * \param[in]  useGpuForNonbonded        Whether GPUs will be used for nonbonded interactions.
@@ -248,18 +249,19 @@ bool decideWhetherToUseGpusForBonded(bool       useGpuForNonbonded,
  * \throws     std::bad_alloc            If out of memory
  *             InconsistentInputError    If the user requirements are inconsistent.
  */
-bool decideWhetherToUseGpuForUpdate(bool              isDomainDecomposition,
-                                    bool              useGpuForPme,
-                                    bool              useGpuForNonbonded,
-                                    bool              useGpuForBufferOps,
-                                    TaskTarget        updateTarget,
-                                    bool              gpusWereDetected,
-                                    const t_inputrec &inputrec,
-                                    const MDAtoms    &mdatoms,
-                                    bool              useEssentialDynamics,
-                                    bool              doOrientationRestraints,
-                                    bool              doDistanceRestraints,
-                                    bool              useReplicaExchange);
+bool decideWhetherToUseGpuForUpdate(bool                 forceGpuUpdateDefaultOn,
+                                    bool                 isDomainDecomposition,
+                                    bool                 useGpuForPme,
+                                    bool                 useGpuForNonbonded,
+                                    bool                 useGpuForBufferOps,
+                                    TaskTarget           updateTarget,
+                                    bool                 gpusWereDetected,
+                                    const t_inputrec    &inputrec,
+                                    const MDAtoms       &mdatoms,
+                                    bool                 useEssentialDynamics,
+                                    bool                 doOrientationRestraints,
+                                    bool                 doDistanceRestraints,
+                                    bool                 useReplicaExchange);
 
 
 }  // namespace gmx