Merge branch release-2018
[alexxy/gromacs.git] / src / gromacs / gpu_utils / gpuregiontimer_ocl.h
index 81444cafdcee5a10b73927ba191bf2d516b52e67..00f28c633fd032235896eac981d872bfd7f28511 100644 (file)
 
 #include <array>
 
+#include "gromacs/gpu_utils/gputraits_ocl.h"
 #include "gromacs/gpu_utils/oclutils.h"
 
 #include "gpuregiontimer.h"
 
-template <> struct GpuTraits<GpuFramework::OpenCL>
-{
-    using CommandStream = cl_command_queue;
-    using CommandEvent  = cl_event;
-};
-
-//! Short-hand for external use
-using GpuRegionTimer = GpuRegionTimerWrapper<GpuFramework::OpenCL>;
-
-// cppcheck-suppress noConstructor
 /*! \libinternal \brief
  * The OpenCL implementation of the GPU code region timing.
  * With OpenCL, one has to use cl_event handle for each API call that has to be timed, and
@@ -70,12 +61,8 @@ using GpuRegionTimer = GpuRegionTimerWrapper<GpuFramework::OpenCL>;
  * The array size is fixed at a small but sufficiently large value for the number of cl_events
  * that might contribute to a timer region, currently 10.
  */
-template <> class GpuRegionTimerImpl<GpuFramework::OpenCL>
+class GpuRegionTimerImpl
 {
-    //! Short-hands
-    using CommandStream = typename GpuTraits<GpuFramework::OpenCL>::CommandStream;
-    using CommandEvent  = typename GpuTraits<GpuFramework::OpenCL>::CommandEvent;
-
     /*! \brief The underlying individual timing events array.
      * The maximum size is chosen arbitrarily to work with current code, and can be changed.
      * There is simply no need for run-time resizing, and it's unlikely we'll ever need more than 10.
@@ -86,6 +73,15 @@ template <> class GpuRegionTimerImpl<GpuFramework::OpenCL>
 
     public:
 
+        GpuRegionTimerImpl()  = default;
+        ~GpuRegionTimerImpl() = default;
+        //! No copying
+        GpuRegionTimerImpl(const GpuRegionTimerImpl &)       = delete;
+        //! No assignment
+        GpuRegionTimerImpl &operator=(GpuRegionTimerImpl &&) = delete;
+        //! Moving is disabled but can be considered in the future if needed
+        GpuRegionTimerImpl(GpuRegionTimerImpl &&)            = delete;
+
         /*! \brief Should be called before the region start. */
         inline void openTimingRegion(CommandStream){}
         /*! \brief Should be called after the region end. */
@@ -128,7 +124,10 @@ template <> class GpuRegionTimerImpl<GpuFramework::OpenCL>
             // As long as we're doing nullptr checks, we might want to be extra cautious.
             events_.fill(nullptr);
         }
-        /*! \brief Provides next unused cl_event for OpenCL API consumption. */
+        /*! \brief Returns a new raw timing event
+         * for passing into individual GPU API calls
+         * within the region if the API requires it (e.g. on OpenCL).
+         */
         inline CommandEvent *fetchNextEvent()
         {
             GMX_ASSERT(currentEvent_ < events_.size(), "Increase c_maxEventNumber_ if needed");
@@ -138,4 +137,7 @@ template <> class GpuRegionTimerImpl<GpuFramework::OpenCL>
         }
 };
 
+//! Short-hand for external use
+using GpuRegionTimer = GpuRegionTimerWrapper<GpuRegionTimerImpl>;
+
 #endif