*/
#include "gmxpre.h"
-#include "leapfrog_gpu.cuh"
+#include "leapfrog_gpu.h"
#include <assert.h>
#include <stdio.h>
//! Maximum number of threads in a block (for __launch_bounds__)
constexpr static int c_maxThreadsPerBlock = c_threadsPerBlock;
-/*! \brief Sets the number of different temperature coupling values
- *
- * This is needed to template the kernel
- * \todo Unify with similar enum in CPU update module
- */
-enum class NumTempScaleValues
-{
- None, //!< No temperature coupling
- Single, //!< Single T-scaling value (one group)
- Multiple //!< Multiple T-scaling values, need to use T-group indices
-};
-
-/*! \brief Different variants of the Parrinello-Rahman velocity scaling
- *
- * This is needed to template the kernel
- * \todo Unify with similar enum in CPU update module
- */
-enum class VelocityScalingType
-{
- None, //!< Do not apply velocity scaling (not a PR-coupling run or step)
- Diagonal, //!< Apply velocity scaling using a diagonal matrix
- Full //!< Apply velocity scaling using a full matrix
-};
-
/*! \brief Main kernel for Leap-Frog integrator.
*
* The coordinates and velocities are updated on the GPU. Also saves the intermediate values of the coordinates for
return kernelPtr;
}
-void LeapFrogGpu::integrate(const float3* d_x,
- float3* d_xp,
- float3* d_v,
- const float3* d_f,
+void LeapFrogGpu::integrate(const DeviceBuffer<float3> d_x,
+ DeviceBuffer<float3> d_xp,
+ DeviceBuffer<float3> d_v,
+ const DeviceBuffer<float3> d_f,
const real dt,
const bool doTemperatureScaling,
gmx::ArrayRef<const t_grp_tcstat> tcstat,
* \ingroup module_mdlib
* \inlibraryapi
*/
-#ifndef GMX_MDLIB_LEAPFROG_GPU_CUH
-#define GMX_MDLIB_LEAPFROG_GPU_CUH
+#ifndef GMX_MDLIB_LEAPFROG_GPU_H
+#define GMX_MDLIB_LEAPFROG_GPU_H
+
+#include "config.h"
+
+#if GMX_GPU_CUDA
+# include "gromacs/gpu_utils/devicebuffer.cuh"
+# include "gromacs/gpu_utils/gputraits.cuh"
+#endif
-#include "gromacs/gpu_utils/gputraits.cuh"
#include "gromacs/gpu_utils/hostallocator.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/pbcutil/pbc_aiuc.h"
namespace gmx
{
+
+/*! \brief Sets the number of different temperature coupling values
+ *
+ * This is needed to template the kernel
+ * \todo Unify with similar enum in CPU update module
+ */
+enum class NumTempScaleValues
+{
+ None, //!< No temperature coupling
+ Single, //!< Single T-scaling value (one group)
+ Multiple //!< Multiple T-scaling values, need to use T-group indices
+};
+
+/*! \brief Different variants of the Parrinello-Rahman velocity scaling
+ *
+ * This is needed to template the kernel
+ * \todo Unify with similar enum in CPU update module
+ */
+enum class VelocityScalingType
+{
+ None, //!< Do not apply velocity scaling (not a PR-coupling run or step)
+ Diagonal, //!< Apply velocity scaling using a diagonal matrix
+ Full //!< Apply velocity scaling using a full matrix
+};
+
class LeapFrogGpu
{
* \param[in] dtPressureCouple Period between pressure coupling steps
* \param[in] prVelocityScalingMatrix Parrinello-Rahman velocity scaling matrix
*/
- void integrate(const float3* d_x,
- float3* d_xp,
- float3* d_v,
- const float3* d_f,
+ void integrate(const DeviceBuffer<float3> d_x,
+ DeviceBuffer<float3> d_xp,
+ DeviceBuffer<float3> d_v,
+ const DeviceBuffer<float3> d_f,
const real dt,
const bool doTemperatureScaling,
gmx::ArrayRef<const t_grp_tcstat> tcstat,
int numAtoms_;
//! 1/mass for all atoms (GPU)
- real* d_inverseMasses_;
+ DeviceBuffer<float> d_inverseMasses_;
//! Current size of the reciprocal masses array
int numInverseMasses_ = -1;
//! Maximum size of the reciprocal masses array
*/
gmx::HostVector<float> h_lambdas_;
//! Device-side temperature scaling factors
- float* d_lambdas_;
+ DeviceBuffer<float> d_lambdas_;
//! Current size of the array with temperature scaling factors (lambdas)
int numLambdas_ = -1;
//! Maximum size of the array with temperature scaling factors (lambdas)
//! Array that maps atom index onto the temperature scaling group to get scaling parameter
- unsigned short* d_tempScaleGroups_;
+ DeviceBuffer<unsigned short> d_tempScaleGroups_;
//! Current size of the temperature coupling groups array
int numTempScaleGroups_ = -1;
//! Maximum size of the temperature coupling groups array