gstat = global_stat_init(ir);
+ const auto& simulationWork = runScheduleWork->simulationWork;
+ const bool useGpuForPme = simulationWork.useGpuPme;
+ const bool useGpuForNonbonded = simulationWork.useGpuNonbonded;
+ const bool useGpuForBufferOps = simulationWork.useGpuBufferOps;
+ const bool useGpuForUpdate = simulationWork.useGpuUpdate;
+
/* Check for polarizable models and flexible constraints */
shellfc = init_shell_flexcon(fplog, top_global, constr ? constr->numFlexibleConstraints() : 0,
- ir->nstcalcenergy, DOMAINDECOMP(cr));
+ ir->nstcalcenergy, DOMAINDECOMP(cr), useGpuForPme);
{
double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1);
std::unique_ptr<t_state> stateInstance;
t_state* state;
-
gmx_localtop_t top(top_global->ffparams);
auto mdatoms = mdAtoms->mdatoms();
- const auto& simulationWork = runScheduleWork->simulationWork;
- const bool useGpuForPme = simulationWork.useGpuPme;
- const bool useGpuForNonbonded = simulationWork.useGpuNonbonded;
- const bool useGpuForBufferOps = simulationWork.useGpuBufferOps;
- const bool useGpuForUpdate = simulationWork.useGpuUpdate;
-
ForceBuffers f(fr->useMts, ((useGpuForNonbonded && useGpuForBufferOps) || useGpuForUpdate)
? PinningPolicy::PinnedIfSupported
: PinningPolicy::CannotBePinned);
#include "gromacs/mdtypes/mdatom.h"
#include "gromacs/mdtypes/mdrunoptions.h"
#include "gromacs/mdtypes/observableshistory.h"
+#include "gromacs/mdtypes/simulation_workload.h"
#include "gromacs/mdtypes/state.h"
#include "gromacs/mimic/communicator.h"
#include "gromacs/mimic/utilities.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/logger.h"
#include "gromacs/utility/real.h"
-#include "gromacs/utility/smalloc.h"
#include "legacysimulator.h"
#include "replicaexchange.h"
/* Check for polarizable models and flexible constraints */
shellfc = init_shell_flexcon(fplog, top_global, constr ? constr->numFlexibleConstraints() : 0,
- ir->nstcalcenergy, DOMAINDECOMP(cr));
+ ir->nstcalcenergy, DOMAINDECOMP(cr),
+ runScheduleWork->simulationWork.useGpuPme);
{
double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1);
{
GMX_ASSERT(shellfc != nullptr, "With NM we always support shells");
- *shellfc = init_shell_flexcon(stdout, top_global, constr ? constr->numFlexibleConstraints() : 0,
- ir->nstcalcenergy, DOMAINDECOMP(cr));
+ *shellfc =
+ init_shell_flexcon(stdout, top_global, constr ? constr->numFlexibleConstraints() : 0,
+ ir->nstcalcenergy, DOMAINDECOMP(cr), thisRankHasDuty(cr, DUTY_PME));
}
else
{
#include "gromacs/mdtypes/mdatom.h"
#include "gromacs/mdtypes/mdrunoptions.h"
#include "gromacs/mdtypes/observableshistory.h"
+#include "gromacs/mdtypes/simulation_workload.h"
#include "gromacs/mdtypes/state.h"
#include "gromacs/mimic/utilities.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/logger.h"
#include "gromacs/utility/real.h"
-#include "gromacs/utility/smalloc.h"
#include "legacysimulator.h"
#include "replicaexchange.h"
/* Check for polarizable models and flexible constraints */
shellfc = init_shell_flexcon(fplog, top_global, constr ? constr->numFlexibleConstraints() : 0,
- ir->nstcalcenergy, DOMAINDECOMP(cr));
+ ir->nstcalcenergy, DOMAINDECOMP(cr),
+ runScheduleWork->simulationWork.useGpuPme);
{
double io = compute_io(ir, top_global->natoms, *groups, energyOutput.numEnergyTerms(), 1);
}
}
-gmx_shellfc_t* init_shell_flexcon(FILE* fplog, const gmx_mtop_t* mtop, int nflexcon, int nstcalcenergy, bool usingDomainDecomposition)
+gmx_shellfc_t* init_shell_flexcon(FILE* fplog,
+ const gmx_mtop_t* mtop,
+ int nflexcon,
+ int nstcalcenergy,
+ bool usingDomainDecomposition,
+ bool usingPmeOnGpu)
{
gmx_shellfc_t* shfc;
}
}
+ /* shfc->x is used as a coordinate buffer for the sim_util's `do_force` function, and
+ * when using PME it must be pinned. */
+ if (usingPmeOnGpu)
+ {
+ for (i = 0; i < 2; i++)
+ {
+ changePinningPolicy(&shfc->x[i], gmx::PinningPolicy::PinnedIfSupported);
+ }
+ }
+
return shfc;
}
class VirtualSitesHandler;
} // namespace gmx
-/* Initialization function, also predicts the initial shell postions.
- * Returns a pointer to an initialized shellfc object.
+/*! \brief Initialization function, also predicts the initial shell positions.
+ *
+ * \param fplog Pointer to the log stream. Can be set to \c nullptr to disable verbose log.
+ * \param mtop Pointer to a global system topology object.
+ * \param nflexcon Number of flexible constraints.
+ * \param nstcalcenergy How often are energies calculated. Must be provided for sanity check.
+ * \param usingDomainDecomposition Whether domain decomposition is used. Must be provided for sanity check.
+ * \param usingPmeOnGpu Set to true if GPU will be used for PME calculations. Necessary for proper buffer initialization.
+ *
+ * \returns a pointer to an initialized \c shellfc object.
*/
gmx_shellfc_t* init_shell_flexcon(FILE* fplog,
const gmx_mtop_t* mtop,
int nflexcon,
int nstcalcenergy,
- bool usingDomainDecomposition);
+ bool usingDomainDecomposition,
+ bool usingPmeOnGpu);
/* Optimize shell positions */
void relax_shell_flexcon(FILE* log,
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/mdatom.h"
#include "gromacs/mdtypes/mdrunoptions.h"
+#include "gromacs/mdtypes/simulation_workload.h"
#include "gromacs/pbcutil/pbc.h"
#include "energydata.h"
globalTopology,
constr ? constr->numFlexibleConstraints() : 0,
inputrec->nstcalcenergy,
- DOMAINDECOMP(cr))),
+ DOMAINDECOMP(cr),
+ runScheduleWork->simulationWork.useGpuPme)),
doShellFC_(shellfc_ != nullptr),
nextNSStep_(-1),
nextEnergyCalculationStep_(-1),