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
#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"
}
}
-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;
// 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;
}
* \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.
*
*
* \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.
*