Make DeviceContext into a proper class
[alexxy/gromacs.git] / src / gromacs / ewald / pme_gpu_types_host_impl.h
index be4f986957d84f257fd5fc3658886bcbb6579c82..44ca3fd3c3561c64b467e13527f59b0f8c78c627 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -60,6 +60,8 @@
 
 #include "gromacs/timing/gpu_timing.h" // for gtPME_EVENT_COUNT
 
+#include "pme_gpu_3dfft.h"
+
 class GpuParallel3dFft;
 
 /*! \internal \brief
@@ -67,6 +69,11 @@ class GpuParallel3dFft;
  */
 struct PmeGpuSpecific
 {
+    /*! \brief Constructor
+     *
+     * \param[in] deviceContext GPU device context.
+     */
+    PmeGpuSpecific(const DeviceContext& deviceContext) : deviceContext_(deviceContext) {}
     /*! \brief The GPU stream where everything related to the PME happens. */
     CommandStream pmeStream;
 
@@ -76,7 +83,7 @@ struct PmeGpuSpecific
      * but should be a constructor parameter to PmeGpu, as well as PmeGpuProgram,
      * managed by high-level code.
      */
-    DeviceContext context;
+    const DeviceContext& deviceContext_;
 
     /* Synchronization events */
     /*! \brief Triggered after the PME Force Calculations have been completed */
@@ -86,13 +93,13 @@ struct PmeGpuSpecific
 
     /* Settings which are set at the start of the run */
     /*! \brief A boolean which tells whether the complex and real grids for cu/clFFT are different or same. Currenty true. */
-    bool performOutOfPlaceFFT;
+    bool performOutOfPlaceFFT = false;
     /*! \brief A boolean which tells if the GPU timing events are enabled.
      *  False by default, can be enabled by setting the environment variable GMX_ENABLE_GPU_TIMING.
      *  Note: will not be reliable when multiple GPU tasks are running concurrently on the same
      * device context, as CUDA events on multiple streams are untrustworthy.
      */
-    bool useTiming;
+    bool useTiming = false;
 
     //! Vector of FFT setups
     std::vector<std::unique_ptr<GpuParallel3dFft>> fftSetup;
@@ -112,37 +119,37 @@ struct PmeGpuSpecific
      * TODO: these should live in a clean buffered container type, and be refactored in the NB/cudautils as well.
      */
     /*! \brief The kernelParams.atoms.coordinates float element count (actual)*/
-    int coordinatesSize;
+    int coordinatesSize = 0;
     /*! \brief The kernelParams.atoms.coordinates float element count (reserved) */
-    int coordinatesSizeAlloc;
+    int coordinatesSizeAlloc = 0;
     /*! \brief The kernelParams.atoms.forces float element count (actual) */
-    int forcesSize;
+    int forcesSize = 0;
     /*! \brief The kernelParams.atoms.forces float element count (reserved) */
-    int forcesSizeAlloc;
+    int forcesSizeAlloc = 0;
     /*! \brief The kernelParams.atoms.gridlineIndices int element count (actual) */
-    int gridlineIndicesSize;
+    int gridlineIndicesSize = 0;
     /*! \brief The kernelParams.atoms.gridlineIndices int element count (reserved) */
-    int gridlineIndicesSizeAlloc;
+    int gridlineIndicesSizeAlloc = 0;
     /*! \brief Both the kernelParams.atoms.theta and kernelParams.atoms.dtheta float element count (actual) */
-    int splineDataSize;
+    int splineDataSize = 0;
     /*! \brief Both the kernelParams.atoms.theta and kernelParams.atoms.dtheta float element count (reserved) */
-    int splineDataSizeAlloc;
+    int splineDataSizeAlloc = 0;
     /*! \brief The kernelParams.atoms.coefficients float element count (actual) */
-    int coefficientsSize;
+    int coefficientsSize = 0;
     /*! \brief The kernelParams.atoms.coefficients float element count (reserved) */
-    int coefficientsSizeAlloc;
+    int coefficientsSizeAlloc = 0;
     /*! \brief The kernelParams.grid.splineValuesArray float element count (actual) */
-    int splineValuesSize;
+    int splineValuesSize = 0;
     /*! \brief The kernelParams.grid.splineValuesArray float element count (reserved) */
-    int splineValuesSizeAlloc;
+    int splineValuesSizeAlloc = 0;
     /*! \brief The kernelParams.grid.realGrid float element count (actual) */
-    int realGridSize;
+    int realGridSize = 0;
     /*! \brief The kernelParams.grid.realGrid float element count (reserved) */
-    int realGridSizeAlloc;
+    int realGridSizeAlloc = 0;
     /*! \brief The kernelParams.grid.fourierGrid float (not float2!) element count (actual) */
-    int complexGridSize;
+    int complexGridSize = 0;
     /*! \brief The kernelParams.grid.fourierGrid float (not float2!) element count (reserved) */
-    int complexGridSizeAlloc;
+    int complexGridSizeAlloc = 0;
 };
 
 #endif