*/
void setPbc(const t_pbc *pbc);
- /*! \brief Synchronize the device stream.
+ /*! \brief Blocking wait on the update of coordinates being ready.
+ *
+ * \todo Remove when the "stitching" is done.
*/
- void synchronizeStream();
+ void waitCoordinatesReadyOnDevice();
+
+
+ /*! \brief Return the synchronizer associated with the event indicated that the coordinates are ready on the device.
+ */
+ void *getCoordinatesReadySync();
private:
class Impl;
gmx::PrivateImplPointer<Impl> impl_;
-
};
} //namespace gmx
gmx_unused const void *commandStream)
: impl_(nullptr)
{
- GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called insted of the correct implementation.");
+ GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
}
UpdateConstrainCuda::~UpdateConstrainCuda() = default;
gmx_unused const float dtPressureCouple,
gmx_unused const matrix velocityScalingMatrix)
{
- GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called insted of the correct implementation.");
+ GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
}
void UpdateConstrainCuda::set(gmx_unused DeviceBuffer<float> d_x,
gmx_unused const t_mdatoms &md,
gmx_unused const int numTempScaleValues)
{
- GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called insted of the correct implementation.");
+ GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
}
void UpdateConstrainCuda::setPbc(gmx_unused const t_pbc *pbc)
{
- GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called insted of the correct implementation.");
+ GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
}
-void UpdateConstrainCuda::synchronizeStream()
+void UpdateConstrainCuda::waitCoordinatesReadyOnDevice()
{
- GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called insted of the correct implementation.");
+ GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
+}
+
+void* UpdateConstrainCuda::getCoordinatesReadySync()
+{
+ GMX_ASSERT(false, "A CPU stub for UpdateConstrain was called instead of the correct implementation.");
+ return nullptr;
}
} // namespace gmx
}
}
+ coordinatesReady_.markEvent(commandStream_);
+
return;
}
settleCuda_->setPbc(pbc);
}
-void UpdateConstrainCuda::Impl::synchronizeStream()
+void UpdateConstrainCuda::Impl::waitCoordinatesReadyOnDevice()
+{
+ coordinatesReady_.waitForEvent();
+}
+
+void *UpdateConstrainCuda::Impl::getCoordinatesReadySync()
{
- gpuStreamSynchronize(commandStream_);
+ return static_cast<void*> (&coordinatesReady_);
}
UpdateConstrainCuda::UpdateConstrainCuda(const t_inputrec &ir,
impl_->setPbc(pbc);
}
-void UpdateConstrainCuda::synchronizeStream()
+void UpdateConstrainCuda::waitCoordinatesReadyOnDevice()
+{
+ impl_->waitCoordinatesReadyOnDevice();
+}
+
+void* UpdateConstrainCuda::getCoordinatesReadySync()
{
- impl_->synchronizeStream();
+ return impl_->getCoordinatesReadySync();
}
} //namespace gmx
#include "gmxpre.h"
+#include "gromacs/gpu_utils/gpueventsynchronizer.cuh"
#include "gromacs/mdlib/leapfrog_cuda.cuh"
#include "gromacs/mdlib/lincs_cuda.cuh"
#include "gromacs/mdlib/settle_cuda.cuh"
*/
void setPbc(const t_pbc *pbc);
- /*! \brief Synchronize the device stream.
+ /*! \brief Blocking wait on the update of coordinates being ready.
+ *
+ * \todo Remove when the "stitching" is done.
+ */
+ void waitCoordinatesReadyOnDevice();
+
+
+ /*! \brief Return the synchronizer associated with the event indicated that the coordinates are ready on the device.
*/
- void synchronizeStream();
+ void *getCoordinatesReadySync();
private:
//! SETTLE CUDA object for water constrains
std::unique_ptr<SettleCuda> settleCuda_;
+ //! An event to indicate when the update of coordinates is complete
+ GpuEventSynchronizer coordinatesReady_;
};
} // namespace gmx
doPressureCouple, ir->nstpcouple*ir->delta_t, M);
stateGpu->copyCoordinatesFromGpu(ArrayRef<RVec>(state->x), StatePropagatorDataGpu::AtomLocality::All);
stateGpu->copyVelocitiesFromGpu(state->v, StatePropagatorDataGpu::AtomLocality::All);
- // Synchronize the update stream.
- // TODO: Replace with event-based synchronization.
- integrator->synchronizeStream();
+
+ // TODO: replace with stateGpu->waitForCopyCoordinatesFromGpu(...)
+ integrator->waitCoordinatesReadyOnDevice();
}
else
{