* This will extract temperature scaling factors from tcstat, transform them into the plain
* array and call the normal integrate method.
*
+ * \param[in] fReadyOnDevice Event synchronizer indicating that the forces are ready in the device memory.
* \param[in] dt Timestep.
* \param[in] updateVelocities If the velocities should be constrained.
* \param[in] computeVirial If virial should be updated.
* \param[in] dtPressureCouple Period between pressure coupling steps
* \param[in] velocityScalingMatrix Parrinello-Rahman velocity scaling matrix
*/
- void integrate(real dt,
+ void integrate(GpuEventSynchronizer *fReadyOnDevice,
+ real dt,
bool updateVelocities,
bool computeVirial,
tensor virial,
UpdateConstrainCuda::~UpdateConstrainCuda() = default;
-void UpdateConstrainCuda::integrate(gmx_unused const real dt,
+void UpdateConstrainCuda::integrate(gmx_unused GpuEventSynchronizer *fReadyOnDevice,
+ gmx_unused const real dt,
gmx_unused const bool updateVelocities,
gmx_unused const bool computeVirial,
gmx_unused tensor virialScaled,
namespace gmx
{
-void UpdateConstrainCuda::Impl::integrate(const real dt,
+void UpdateConstrainCuda::Impl::integrate(GpuEventSynchronizer *fReadyOnDevice,
+ const real dt,
const bool updateVelocities,
const bool computeVirial,
tensor virial,
// TODO There is no point in having separate virial matrix for constraints
clear_mat(virial);
+ // Make sure that the forces are ready on device before proceeding with the update.
+ fReadyOnDevice->enqueueWaitEvent(commandStream_);
+
// The integrate should save a copy of the current coordinates in d_xp_ and write updated once into d_x_.
// The d_xp_ is only needed by constraints.
integrator_->integrate(d_x_, d_xp_, d_v_, d_f_, dt,
UpdateConstrainCuda::~UpdateConstrainCuda() = default;
-void UpdateConstrainCuda::integrate(const real dt,
+void UpdateConstrainCuda::integrate(GpuEventSynchronizer *fReadyOnDevice,
+ const real dt,
const bool updateVelocities,
const bool computeVirial,
tensor virialScaled,
const float dtPressureCouple,
const matrix velocityScalingMatrix)
{
- impl_->integrate(dt, updateVelocities, computeVirial, virialScaled,
+ impl_->integrate(fReadyOnDevice,
+ dt, updateVelocities, computeVirial, virialScaled,
doTempCouple, tcstat,
doPressureCouple, dtPressureCouple, velocityScalingMatrix);
}
*
* Integrates the equation of motion using Leap-Frog algorithm and applies
* LINCS and SETTLE constraints.
- * Updates d_xp_ and d_v_ fields of this object.
* If computeVirial is true, constraints virial is written at the provided pointer.
* doTempCouple should be true if:
* 1. The temperature coupling is enabled.
* 2. This is the temperature coupling step.
* Parameters virial/lambdas can be nullptr if computeVirial/doTempCouple are false.
*
+ * \param[in] fReadyOnDevice Event synchronizer indicating that the forces are ready in the device memory.
* \param[in] dt Timestep.
* \param[in] updateVelocities If the velocities should be constrained.
* \param[in] computeVirial If virial should be updated.
* \param[in] dtPressureCouple Period between pressure coupling steps
* \param[in] velocityScalingMatrix Parrinello-Rahman velocity scaling matrix
*/
- void integrate(real dt,
+ void integrate(GpuEventSynchronizer *fReadyOnDevice,
+ real dt,
bool updateVelocities,
bool computeVirial,
tensor virial,
bool doTempCouple = (ir->etc != etcNO && do_per_step(step + ir->nsttcouple - 1, ir->nsttcouple));
bool doPressureCouple = (ir->epc == epcPARRINELLORAHMAN && do_per_step(step + ir->nstpcouple - 1, ir->nstpcouple));
+ // TODO: Use StepWorkload fields.
+ bool useGpuFBufferOps = simulationWork.useGpuBufferOps && !(bCalcVir || bCalcEner);
+
// This applies Leap-Frog, LINCS and SETTLE in succession
- integrator->integrate(ir->delta_t, true, bCalcVir, shake_vir,
+ integrator->integrate(stateGpu->getForcesReadyOnDeviceEvent(StatePropagatorDataGpu::AtomLocality::Local, useGpuFBufferOps),
+ ir->delta_t, true, bCalcVir, shake_vir,
doTempCouple, ekind->tcstat,
doPressureCouple, ir->nstpcouple*ir->delta_t, M);
stateGpu->copyCoordinatesFromGpu(ArrayRef<RVec>(state->x), StatePropagatorDataGpu::AtomLocality::All);