Use RVec instead of float for x, v and f device buffers
[alexxy/gromacs.git] / src / gromacs / gpu_utils / cudautils.cuh
index 71d9b7dac45dac38ac76b96357cdec6b91e0acde..6f41e8589cef48b528bc3e1b48d2967764ae4c0d 100644 (file)
@@ -215,6 +215,19 @@ static inline void rvec_inc(rvec a, const float3 b)
     rvec tmp = { b.x, b.y, b.z };
     rvec_inc(a, tmp);
 }
+/*! \brief Cast RVec buffer to float3 buffer.
+ *
+ * \param[in] in The RVec buffer to cast.
+ *
+ * \returns Buffer, casted to float3*.
+ */
+static inline __host__ __device__ float3* asFloat3(gmx::RVec* in)
+{
+    static_assert(sizeof(in[0]) == sizeof(float3),
+                  "Size of the host-side data-type is different from the size of the device-side "
+                  "counterpart.");
+    return reinterpret_cast<float3*>(in);
+}
 
 /*! \brief Wait for all taks in stream \p s to complete.
  *