Make SETTLE setup code platform-agnostic
[alexxy/gromacs.git] / src / gromacs / mdlib / settle_gpu.h
similarity index 91%
rename from src/gromacs/mdlib/settle_gpu.cuh
rename to src/gromacs/mdlib/settle_gpu.h
index f09fbd344f4a37b96c5e21fc7fcebade243fd0c4..641c53d95ab44240e94a9c229e30a59445108f2a 100644 (file)
@@ -40,8 +40,8 @@
  *
  * \ingroup module_mdlib
  */
-#ifndef GMX_MDLIB_SETTLE_GPU_CUH
-#define GMX_MDLIB_SETTLE_GPU_CUH
+#ifndef GMX_MDLIB_SETTLE_GPU_H
+#define GMX_MDLIB_SETTLE_GPU_H
 
 #include "gmxpre.h"
 
@@ -62,6 +62,18 @@ class InteractionDefinitions;
 namespace gmx
 {
 
+//! Indices of atoms in a water molecule
+struct WaterMolecule
+{
+    //! Oxygen atom
+    int ow1;
+    //! First hydrogen atom
+    int hw2;
+    //! Second hydrogen atom
+    int hw3;
+};
+
+
 /*! \internal \brief Class with interfaces and data for GPU version of SETTLE. */
 class SettleGpu
 {
@@ -134,15 +146,15 @@ private:
     //! Scaled virial tensor (9 reals, GPU)
     std::vector<float> h_virialScaled_;
     //! Scaled virial tensor (9 reals, GPU)
-    float* d_virialScaled_;
+    DeviceBuffer<float> d_virialScaled_;
 
     //! Number of settles
     int numSettles_ = 0;
 
-    //! Indexes of atoms (.x for oxygen, .y and.z for hydrogens, CPU)
-    std::vector<int3> h_atomIds_;
-    //! Indexes of atoms (.x for oxygen, .y and.z for hydrogens, GPU)
-    int3* d_atomIds_;
+    //! Indexes of atoms (.i for oxygen, .j and.k for hydrogens, CPU)
+    std::vector<WaterMolecule> h_atomIds_;
+    //! Indexes of atoms (.i for oxygen, .j and.k for hydrogens, GPU)
+    DeviceBuffer<WaterMolecule> d_atomIds_;
     //! Current size of the array of atom IDs
     int numAtomIds_ = -1;
     //! Allocated size for the array of atom IDs
@@ -154,4 +166,4 @@ private:
 
 } // namespace gmx
 
-#endif // GMX_MDLIB_SETTLE_GPU_CUH
+#endif // GMX_MDLIB_SETTLE_GPU_H