From ccdd40a099812da0e982190c50f2108446d8ea8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Szil=C3=A1rd=20P=C3=A1ll?= Date: Mon, 3 Feb 2020 11:38:50 +0100 Subject: [PATCH] Add simulation workload flag for dipole computation Change-Id: I4e7828d4dc73fb9caea100e0303779853be80c70 --- src/gromacs/mdlib/sim_util.cpp | 17 +++++++-------- src/gromacs/mdrun/runner.cpp | 8 +++---- src/gromacs/mdtypes/simulation_workload.h | 4 +++- .../decidesimulationworkload.cpp | 21 ++++++++++--------- .../taskassignment/decidesimulationworkload.h | 20 +++++++++--------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 61878b8f5a..54dae71d61 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -955,16 +955,13 @@ void do_force(FILE* fplog, clear_mat(vir_force); - if (stepWork.stateChanged) + if (stepWork.stateChanged && simulationWork.computeMuTot) { - if (inputrecNeedMutot(inputrec)) - { - /* Calculate total (local) dipole moment in a temporary common array. - * This makes it possible to sum them over nodes faster. - */ - calc_mu(start, homenr, x.unpaddedArrayRef(), mdatoms->chargeA, mdatoms->chargeB, - mdatoms->nChargePerturbed, mu, mu + DIM); - } + /* Calculate total (local) dipole moment in a temporary common array. + * This makes it possible to sum them over nodes faster. + */ + calc_mu(start, homenr, x.unpaddedArrayRef(), mdatoms->chargeA, mdatoms->chargeB, + mdatoms->nChargePerturbed, mu, mu + DIM); } if (fr->pbcType != PbcType::No) @@ -1355,7 +1352,7 @@ void do_force(FILE* fplog, wallcycle_stop(wcycle, ewcLAUNCH_GPU); } - if (stepWork.stateChanged && inputrecNeedMutot(inputrec)) + if (stepWork.stateChanged && simulationWork.computeMuTot) { if (PAR(cr)) { diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 41f609d1cc..f68714ce70 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -1557,10 +1557,10 @@ int Mdrunner::mdrunner() // make it work. MdrunScheduleWorkload runScheduleWork; // Also populates the simulation constant workload description. - runScheduleWork.simulationWork = createSimulationWorkload( - useGpuForNonbonded, pmeRunMode, useGpuForBonded, useGpuForUpdate, - devFlags.enableGpuBufferOps, devFlags.enableGpuHaloExchange, - devFlags.enableGpuPmePPComm, haveEwaldSurfaceContribution(*inputrec)); + runScheduleWork.simulationWork = + createSimulationWorkload(*inputrec, useGpuForNonbonded, pmeRunMode, useGpuForBonded, + useGpuForUpdate, devFlags.enableGpuBufferOps, + devFlags.enableGpuHaloExchange, devFlags.enableGpuPmePPComm); std::unique_ptr stateGpu; if (gpusWereDetected diff --git a/src/gromacs/mdtypes/simulation_workload.h b/src/gromacs/mdtypes/simulation_workload.h index 9bf230a593..5dfe43c333 100644 --- a/src/gromacs/mdtypes/simulation_workload.h +++ b/src/gromacs/mdtypes/simulation_workload.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -142,6 +142,8 @@ public: class SimulationWorkload { public: + //! Whether total dipole needs to be computed + bool computeMuTot = false; //! If we have calculation of short range nonbondeds on CPU bool useCpuNonbonded = false; //! If we have calculation of short range nonbondeds on GPU diff --git a/src/gromacs/taskassignment/decidesimulationworkload.cpp b/src/gromacs/taskassignment/decidesimulationworkload.cpp index 16849d4e5d..b9ba44e94c 100644 --- a/src/gromacs/taskassignment/decidesimulationworkload.cpp +++ b/src/gromacs/taskassignment/decidesimulationworkload.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -50,16 +50,17 @@ namespace gmx { -SimulationWorkload createSimulationWorkload(bool useGpuForNonbonded, - PmeRunMode pmeRunMode, - bool useGpuForBonded, - bool useGpuForUpdate, - bool useGpuForBufferOps, - bool useGpuHaloExchange, - bool useGpuPmePpComm, - bool haveEwaldSurfaceContribution) +SimulationWorkload createSimulationWorkload(const t_inputrec& inputrec, + bool useGpuForNonbonded, + PmeRunMode pmeRunMode, + bool useGpuForBonded, + bool useGpuForUpdate, + bool useGpuForBufferOps, + bool useGpuHaloExchange, + bool useGpuPmePpComm) { SimulationWorkload simulationWorkload; + simulationWorkload.computeMuTot = inputrecNeedMutot(&inputrec); simulationWorkload.useCpuNonbonded = !useGpuForNonbonded; simulationWorkload.useGpuNonbonded = useGpuForNonbonded; simulationWorkload.useCpuPme = (pmeRunMode == PmeRunMode::CPU); @@ -71,7 +72,7 @@ SimulationWorkload createSimulationWorkload(bool useGpuForNonbonded, simulationWorkload.useGpuHaloExchange = useGpuHaloExchange; simulationWorkload.useGpuPmePpCommunication = useGpuPmePpComm && (pmeRunMode == PmeRunMode::GPU); simulationWorkload.useGpuDirectCommunication = useGpuHaloExchange || useGpuPmePpComm; - simulationWorkload.haveEwaldSurfaceContribution = haveEwaldSurfaceContribution; + simulationWorkload.haveEwaldSurfaceContribution = haveEwaldSurfaceContribution(inputrec); return simulationWorkload; } diff --git a/src/gromacs/taskassignment/decidesimulationworkload.h b/src/gromacs/taskassignment/decidesimulationworkload.h index 538fa823ed..b8d81c02b5 100644 --- a/src/gromacs/taskassignment/decidesimulationworkload.h +++ b/src/gromacs/taskassignment/decidesimulationworkload.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -56,6 +56,7 @@ namespace gmx * Build datastructure that contains decisions whether to run different workload * task on GPUs. * + * \param[in] inputrec The input record * \param[in] useGpuForNonbonded Whether we have short-range nonbonded interactions * calculations on GPU(s). * \param[in] pmeRunMode Run mode indicating what resource is PME execured on. @@ -65,17 +66,16 @@ namespace gmx * \param[in] useGpuForBufferOps Whether buffer ops / reduction are calculated on GPU(s). * \param[in] useGpuHaloExchange Whether GPU direct communication is used in halo exchange. * \param[in] useGpuPmePpComm Whether GPU direct communication is used in PME-PP communication. - * \param[in] haveEwaldSurfaceContribution Whether there is an Ewald surface contribution * \returns Simulation lifetime constant workload description. */ -SimulationWorkload createSimulationWorkload(bool useGpuForNonbonded, - PmeRunMode pmeRunMode, - bool useGpuForBonded, - bool useGpuForUpdate, - bool useGpuForBufferOps, - bool useGpuHaloExchange, - bool useGpuPmePpComm, - bool haveEwaldSurfaceContribution); +SimulationWorkload createSimulationWorkload(const t_inputrec& inputrec, + bool useGpuForNonbonded, + PmeRunMode pmeRunMode, + bool useGpuForBonded, + bool useGpuForUpdate, + bool useGpuForBufferOps, + bool useGpuHaloExchange, + bool useGpuPmePpComm); } // namespace gmx -- 2.22.0