From 8d94b9ceee2df0dd9babcdcb9b19c390b1073db7 Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Tue, 3 Nov 2020 07:43:32 +0000 Subject: [PATCH] Make the message why GPU bondeds are not available more clear Closes #3728 --- src/gromacs/mdrun/runner.cpp | 9 ++--- src/gromacs/taskassignment/decidegpuusage.cpp | 37 ++++++++++++------- src/gromacs/taskassignment/decidegpuusage.h | 20 +++++----- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 4e27012f62..d43fe4fd8a 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -897,12 +897,9 @@ int Mdrunner::mdrunner() useGpuForPme = decideWhetherToUseGpusForPme( useGpuForNonbonded, pmeTarget, userGpuTaskAssignment, *hwinfo, *inputrec, cr->sizeOfDefaultCommunicator, domdecOptions.numPmeRanks, gpusWereDetected); - auto canUseGpuForBonded = buildSupportsGpuBondeds(nullptr) - && inputSupportsGpuBondeds(*inputrec, mtop, nullptr); - useGpuForBonded = decideWhetherToUseGpusForBonded( - useGpuForNonbonded, useGpuForPme, bondedTarget, canUseGpuForBonded, - EVDW_PME(inputrec->vdwtype), EEL_PME_EWALD(inputrec->coulombtype), - domdecOptions.numPmeRanks, gpusWereDetected); + useGpuForBonded = decideWhetherToUseGpusForBonded(useGpuForNonbonded, useGpuForPme, + bondedTarget, *inputrec, mtop, + domdecOptions.numPmeRanks, gpusWereDetected); } GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR diff --git a/src/gromacs/taskassignment/decidegpuusage.cpp b/src/gromacs/taskassignment/decidegpuusage.cpp index eb88b85d87..91f0eb4720 100644 --- a/src/gromacs/taskassignment/decidegpuusage.cpp +++ b/src/gromacs/taskassignment/decidegpuusage.cpp @@ -57,6 +57,7 @@ #include "gromacs/hardware/detecthardware.h" #include "gromacs/hardware/hardwaretopology.h" #include "gromacs/hardware/hw_info.h" +#include "gromacs/listed_forces/gpubonded.h" #include "gromacs/mdlib/gmx_omp_nthreads.h" #include "gromacs/mdlib/update_constrain_gpu.h" #include "gromacs/mdtypes/commrec.h" @@ -458,27 +459,36 @@ PmeRunMode determinePmeRunMode(const bool useGpuForPme, const TaskTarget& pmeFft } } -bool decideWhetherToUseGpusForBonded(const bool useGpuForNonbonded, - const bool useGpuForPme, - const TaskTarget bondedTarget, - const bool canUseGpuForBonded, - const bool usingLJPme, - const bool usingElecPmeOrEwald, - const int numPmeRanksPerSimulation, - const bool gpusWereDetected) +bool decideWhetherToUseGpusForBonded(bool useGpuForNonbonded, + bool useGpuForPme, + TaskTarget bondedTarget, + const t_inputrec& inputrec, + const gmx_mtop_t& mtop, + int numPmeRanksPerSimulation, + bool gpusWereDetected) { if (bondedTarget == TaskTarget::Cpu) { return false; } - if (!canUseGpuForBonded) + std::string errorMessage; + + if (!buildSupportsGpuBondeds(&errorMessage)) { if (bondedTarget == TaskTarget::Gpu) { - GMX_THROW(InconsistentInputError( - "Bonded interactions on the GPU were required, but not supported for these " - "simulation settings. Change your settings, or do not require using GPUs.")); + GMX_THROW(InconsistentInputError(errorMessage.c_str())); + } + + return false; + } + + if (!inputSupportsGpuBondeds(inputrec, mtop, &errorMessage)) + { + if (bondedTarget == TaskTarget::Gpu) + { + GMX_THROW(InconsistentInputError(errorMessage.c_str())); } return false; @@ -514,7 +524,8 @@ bool decideWhetherToUseGpusForBonded(const bool useGpuForNonbonded, // Note that here we assume that the auto setting of PME ranks will not // choose seperate PME ranks when nonBonded are assigned to the GPU. bool usingOurCpuForPmeOrEwald = - (usingLJPme || (usingElecPmeOrEwald && !useGpuForPme && numPmeRanksPerSimulation <= 0)); + (EVDW_PME(inputrec.vdwtype) + || (EEL_PME_EWALD(inputrec.coulombtype) && !useGpuForPme && numPmeRanksPerSimulation <= 0)); return gpusWereDetected && usingOurCpuForPmeOrEwald; } diff --git a/src/gromacs/taskassignment/decidegpuusage.h b/src/gromacs/taskassignment/decidegpuusage.h index 7dd6ae9b30..b5fd83907f 100644 --- a/src/gromacs/taskassignment/decidegpuusage.h +++ b/src/gromacs/taskassignment/decidegpuusage.h @@ -247,9 +247,8 @@ PmeRunMode determinePmeRunMode(bool useGpuForPme, const TaskTarget& pmeFftTarget * \param[in] useGpuForNonbonded Whether GPUs will be used for nonbonded interactions. * \param[in] useGpuForPme Whether GPUs will be used for PME interactions. * \param[in] bondedTarget The user's choice for mdrun -bonded for where to assign tasks. - * \param[in] canUseGpuForBonded Whether the bonded interactions can run on a GPU - * \param[in] usingLJPme Whether Vdw interactions use LJ-PME. - * \param[in] usingElecPmeOrEwald Whether a PME or Ewald type method is used for electrostatics. + * \param[in] inputrec The user input. + * \param[in] mtop The global topology. * \param[in] numPmeRanksPerSimulation The number of PME ranks in each simulation, can be -1 for auto. * \param[in] gpusWereDetected Whether compatible GPUs were detected on any node. * @@ -257,14 +256,13 @@ PmeRunMode determinePmeRunMode(bool useGpuForPme, const TaskTarget& pmeFftTarget * * \throws std::bad_alloc If out of memory * InconsistentInputError If the user requirements are inconsistent. */ -bool decideWhetherToUseGpusForBonded(bool useGpuForNonbonded, - bool useGpuForPme, - TaskTarget bondedTarget, - bool canUseGpuForBonded, - bool usingLJPme, - bool usingElecPmeOrEwald, - int numPmeRanksPerSimulation, - bool gpusWereDetected); +bool decideWhetherToUseGpusForBonded(bool useGpuForNonbonded, + bool useGpuForPme, + TaskTarget bondedTarget, + const t_inputrec& inputrec, + const gmx_mtop_t& mtop, + int numPmeRanksPerSimulation, + bool gpusWereDetected); /*! \brief Decide whether to use GPU for update. * -- 2.22.0