Move the ownership of the xUpdatedOnDevice event to update constraints
[alexxy/gromacs.git] / src / gromacs / mdlib / update_constrain_gpu_impl.h
index adfbccda8575cf0fda8099dfc521100d979ce96d..bbba2b38a67b2adecdea198fe18d5cb4d8d7bda8 100644 (file)
@@ -48,6 +48,9 @@
 
 #include "gmxpre.h"
 
+#include "config.h"
+
+#include "gromacs/gpu_utils/gpueventsynchronizer.h"
 #include "gromacs/mdlib/leapfrog_gpu.h"
 #include "gromacs/mdlib/lincs_gpu.h"
 #include "gromacs/mdlib/settle_gpu.h"
@@ -67,10 +70,7 @@ public:
     /*! \brief Create Update-Constrain object.
      *
      * The constructor is given a non-nullptr \p deviceStream, in which all the update and constrain
-     * routines are executed. \p xUpdatedOnDevice should mark the completion of all kernels that
-     * modify coordinates. The event is maintained outside this class and also passed to all (if
-     * any) consumers of the updated coordinates. The \p xUpdatedOnDevice also can not be a nullptr
-     * because the markEvent(...) method is called unconditionally.
+     * routines are executed.
      *
      * \param[in] ir                  Input record data: LINCS takes number of iterations and order of
      *                                projection from it.
@@ -79,17 +79,14 @@ public:
      * \param[in] numTempScaleValues  Number of temperature scaling groups. Set zero for no temperature coupling.
      * \param[in] deviceContext       GPU device context.
      * \param[in] deviceStream        GPU stream to use.
-     * \param[in] xUpdatedOnDevice    The event synchronizer to use to mark that
-     *                                update is done on the GPU.
      * \param[in] wcycle              The wallclock counter
      */
-    Impl(const t_inputrec&     ir,
-         const gmx_mtop_t&     mtop,
-         int                   numTempScaleValues,
-         const DeviceContext&  deviceContext,
-         const DeviceStream&   deviceStream,
-         GpuEventSynchronizer* xUpdatedOnDevice,
-         gmx_wallcycle*        wcycle);
+    Impl(const t_inputrec&    ir,
+         const gmx_mtop_t&    mtop,
+         int                  numTempScaleValues,
+         const DeviceContext& deviceContext,
+         const DeviceStream&  deviceStream,
+         gmx_wallcycle*       wcycle);
 
     ~Impl();
 
@@ -169,7 +166,7 @@ public:
 
     /*! \brief Return the synchronizer associated with the event indicated that the coordinates are ready on the device.
      */
-    GpuEventSynchronizer* getCoordinatesReadySync();
+    GpuEventSynchronizer* xUpdatedOnDeviceEvent();
 
     /*! \brief
      * Returns whether the maximum number of coupled constraints is supported
@@ -222,8 +219,8 @@ private:
     //! SETTLE GPU object for water constrains
     std::unique_ptr<SettleGpu> settleGpu_;
 
-    //! An pointer to the event to indicate when the update of coordinates is complete
-    GpuEventSynchronizer* coordinatesReady_;
+    //! The event to indicate when the update of coordinates is complete
+    GpuEventSynchronizer xUpdatedOnDeviceEvent_;
     //! The wallclock counter
     gmx_wallcycle* wcycle_ = nullptr;
 };