From d74a2fea5de17ace11c37f0cb03af44592e98146 Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Fri, 18 Oct 2019 17:17:06 +0200 Subject: [PATCH] Add environment variable that changes the meaning of '-update auto' 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 | 2 +- src/gromacs/mdrun/runner.cpp | 34 +++++++++---------- .../modularsimulator/modularsimulator.cpp | 2 +- src/gromacs/taskassignment/decidegpuusage.cpp | 29 +++++++++------- src/gromacs/taskassignment/decidegpuusage.h | 26 +++++++------- 5 files changed, 49 insertions(+), 44 deletions(-) diff --git a/admin/builds/gromacs.py b/admin/builds/gromacs.py index ba642b0468..4fa518f186 100644 --- a/admin/builds/gromacs.py +++ b/admin/builds/gromacs.py @@ -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) diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 843f401c28..74a690ef1b 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -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, diff --git a/src/gromacs/modularsimulator/modularsimulator.cpp b/src/gromacs/modularsimulator/modularsimulator.cpp index b77321d176..2cc1503ab1 100644 --- a/src/gromacs/modularsimulator/modularsimulator.cpp +++ b/src/gromacs/modularsimulator/modularsimulator.cpp @@ -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 diff --git a/src/gromacs/taskassignment/decidegpuusage.cpp b/src/gromacs/taskassignment/decidegpuusage.cpp index fbf0df5c32..e759b2c5db 100644 --- a/src/gromacs/taskassignment/decidegpuusage.cpp +++ b/src/gromacs/taskassignment/decidegpuusage.cpp @@ -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 diff --git a/src/gromacs/taskassignment/decidegpuusage.h b/src/gromacs/taskassignment/decidegpuusage.h index 2afa571b20..7a3ea2ca86 100644 --- a/src/gromacs/taskassignment/decidegpuusage.h +++ b/src/gromacs/taskassignment/decidegpuusage.h @@ -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 -- 2.22.0