When the CPU has no forces to calculatie, we should not assign
bondeds to the GPU. Here we only assign bondeds to the GPU when
the CPU does PME for electrostatics and/or LJ.
Change-Id: I82f3047311bde45c026c78e44adc4985eb07b0e7
auto canUseGpuForBonded = buildSupportsGpuBondeds(nullptr) && inputSupportsGpuBondeds(*inputrec, mtop, nullptr);
useGpuForBonded =
decideWhetherToUseGpusForBonded(useGpuForNonbonded, useGpuForPme, usingVerletScheme,
auto canUseGpuForBonded = buildSupportsGpuBondeds(nullptr) && inputSupportsGpuBondeds(*inputrec, mtop, nullptr);
useGpuForBonded =
decideWhetherToUseGpusForBonded(useGpuForNonbonded, useGpuForPme, usingVerletScheme,
- bondedTarget, canUseGpuForBonded, cr->nnodes,
+ bondedTarget, canUseGpuForBonded,
+ EVDW_PME(inputrec->vdwtype),
+ EEL_PME_EWALD(inputrec->coulombtype),
domdecOptions.numPmeRanks, gpusWereDetected);
pmeRunMode = (useGpuForPme ? PmeRunMode::GPU : PmeRunMode::CPU);
domdecOptions.numPmeRanks, gpusWereDetected);
pmeRunMode = (useGpuForPme ? PmeRunMode::GPU : PmeRunMode::CPU);
}
bool decideWhetherToUseGpusForBonded(const bool useGpuForNonbonded,
}
bool decideWhetherToUseGpusForBonded(const bool useGpuForNonbonded,
- const bool /*useGpuForPme*/,
+ const bool useGpuForPme,
const bool usingVerletScheme,
const TaskTarget bondedTarget,
const bool canUseGpuForBonded,
const bool usingVerletScheme,
const TaskTarget bondedTarget,
const bool canUseGpuForBonded,
- const int /*numRanksPerSimulation*/,
- const int /*numPmeRanksPerSimulation*/,
+ const bool usingLJPme,
+ const bool usingElecPmeOrEwald,
+ const int numPmeRanksPerSimulation,
const bool gpusWereDetected)
{
if (bondedTarget == TaskTarget::Cpu)
const bool gpusWereDetected)
{
if (bondedTarget == TaskTarget::Cpu)
}
// If we get here, then the user permitted GPUs, which we should
}
// If we get here, then the user permitted GPUs, which we should
- // use for bonded interactions if any were detected.
- return gpusWereDetected;
+ // use for bonded interactions if any were detected and the CPU
+ // is busy, for which we currently only check PME or Ewald.
+ // (It would be better to dynamically assign bondeds based on timings)
+ // 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));
+
+ return gpusWereDetected && usingOurCpuForPmeOrEwald;
* \param[in] usingVerletScheme Whether the nonbondeds are using the Verlet scheme.
* \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] usingVerletScheme Whether the nonbondeds are using the Verlet scheme.
* \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] numRanksPerSimulation The number of ranks in each simulation.
- * \param[in] numPmeRanksPerSimulation The number of PME ranks in each simulation.
+ * \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] 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.
*
* \returns Whether the simulation will run bondeded tasks on GPUs.
* \param[in] gpusWereDetected Whether compatible GPUs were detected on any node.
*
* \returns Whether the simulation will run bondeded tasks on GPUs.
bool usingVerletScheme,
TaskTarget bondedTarget,
bool canUseGpuForBonded,
bool usingVerletScheme,
TaskTarget bondedTarget,
bool canUseGpuForBonded,
- int numRanksPerSimulation,
+ bool usingLJPme,
+ bool usingElecPmeOrEwald,
int numPmeRanksPerSimulation,
bool gpusWereDetected);
int numPmeRanksPerSimulation,
bool gpusWereDetected);