Remove dependence on t_mdatoms from GPU version of leap-frog
authorArtem Zhmurov <zhmurov@gmail.com>
Mon, 25 May 2020 08:13:12 +0000 (08:13 +0000)
committerArtem Zhmurov <zhmurov@gmail.com>
Mon, 25 May 2020 08:13:12 +0000 (08:13 +0000)
src/gromacs/mdlib/leapfrog_gpu.cu
src/gromacs/mdlib/leapfrog_gpu.cuh
src/gromacs/mdlib/tests/leapfrogtestrunners.cu
src/gromacs/mdlib/update_constrain_gpu_impl.cu

index 7e8287235f817d142087354ddae6eeacef196d35..f34c51db4599da69a0bdedc1c2730acf73d4843c 100644 (file)
@@ -59,6 +59,7 @@
 #include "gromacs/gpu_utils/devicebuffer.h"
 #include "gromacs/gpu_utils/vectype_ops.cuh"
 #include "gromacs/math/vec.h"
+#include "gromacs/mdtypes/group.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/pbcutil/pbc_aiuc_cuda.cuh"
 #include "gromacs/utility/arrayref.h"
@@ -335,16 +336,19 @@ LeapFrogGpu::~LeapFrogGpu()
     freeDeviceBuffer(&d_inverseMasses_);
 }
 
-void LeapFrogGpu::set(const t_mdatoms& md, const int numTempScaleValues, const unsigned short* tempScaleGroups)
+void LeapFrogGpu::set(const int             numAtoms,
+                      const real*           inverseMasses,
+                      const int             numTempScaleValues,
+                      const unsigned short* tempScaleGroups)
 {
-    numAtoms_                       = md.nr;
+    numAtoms_                       = numAtoms;
     kernelLaunchConfig_.gridSize[0] = (numAtoms_ + c_threadsPerBlock - 1) / c_threadsPerBlock;
 
     numTempScaleValues_ = numTempScaleValues;
 
     reallocateDeviceBuffer(&d_inverseMasses_, numAtoms_, &numInverseMasses_,
                            &numInverseMassesAlloc_, deviceContext_);
-    copyToDeviceBuffer(&d_inverseMasses_, (float*)md.invmass, 0, numAtoms_, deviceStream_,
+    copyToDeviceBuffer(&d_inverseMasses_, (float*)inverseMasses, 0, numAtoms_, deviceStream_,
                        GpuApiCallBehavior::Sync, nullptr);
 
     // Temperature scale group map only used if there are more then one group
index 6097a9a87e0abd6244248c8d87a202cb2d08a4d6..cec20f751d0aa52f4a73c0bbac94282b38797cb3 100644 (file)
 #ifndef GMX_MDLIB_LEAPFROG_GPU_CUH
 #define GMX_MDLIB_LEAPFROG_GPU_CUH
 
-#include "gromacs/gpu_utils/device_context.h"
 #include "gromacs/gpu_utils/gputraits.cuh"
 #include "gromacs/gpu_utils/hostallocator.h"
-#include "gromacs/mdtypes/group.h"
-#include "gromacs/mdtypes/mdatom.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/pbcutil/pbc_aiuc.h"
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/classhelpers.h"
 
+class DeviceContext;
+class DeviceStream;
+struct t_grp_tcstat;
+
 namespace gmx
 {
 
@@ -102,11 +103,15 @@ public:
      * and temperature coupling groups. Copies inverse masses and temperature coupling groups
      * to the GPU.
      *
-     * \param[in] md                  MD atoms, from which inverse masses are taken.
+     * \param[in] numAtoms            Number of atoms in the system.
+     * \param[in] inverseMasses       Inverse masses of atoms.
      * \param[in] numTempScaleValues  Number of temperature scale groups.
      * \param[in] tempScaleGroups     Maps the atom index to temperature scale value.
      */
-    void set(const t_mdatoms& md, int numTempScaleValues, const unsigned short* tempScaleGroups);
+    void set(const int             numAtoms,
+             const real*           inverseMasses,
+             int                   numTempScaleValues,
+             const unsigned short* tempScaleGroups);
 
     /*! \brief Class with hardware-specific interfaces and implementations.*/
     class Impl;
index 2edab594381bb3bcff170d65f62f20c54ce96f02..f895816ad2a81efa997b74a8314dcf2f57082446 100644 (file)
@@ -91,7 +91,8 @@ void integrateLeapFrogGpu(LeapFrogTestData* testData, int numSteps)
 
     auto integrator = std::make_unique<LeapFrogGpu>(deviceContext, deviceStream);
 
-    integrator->set(testData->mdAtoms_, testData->numTCoupleGroups_, testData->mdAtoms_.cTC);
+    integrator->set(testData->numAtoms_, testData->inverseMasses_.data(),
+                    testData->numTCoupleGroups_, testData->mdAtoms_.cTC);
 
     bool doTempCouple = testData->numTCoupleGroups_ > 0;
     for (int step = 0; step < numSteps; step++)
index 0cc6c46a4e0f9caa9798cf6a58160eec9f58e97d..0f54925c90af9339ea3cf898e7cb625830fe58d5 100644 (file)
@@ -66,6 +66,7 @@
 #include "gromacs/mdlib/lincs_gpu.cuh"
 #include "gromacs/mdlib/settle_gpu.cuh"
 #include "gromacs/mdlib/update_constrain_gpu.h"
+#include "gromacs/mdtypes/mdatom.h"
 
 namespace gmx
 {
@@ -213,8 +214,8 @@ void UpdateConstrainGpu::Impl::set(DeviceBuffer<RVec>            d_x,
                            &numInverseMassesAlloc_, deviceContext_);
 
     // Integrator should also update something, but it does not even have a method yet
-    integrator_->set(md, numTempScaleValues, md.cTC);
-    lincsGpu_->set(idef, md.nr, md.invmass);
+    integrator_->set(numAtoms_, md.invmass, numTempScaleValues, md.cTC);
+    lincsGpu_->set(idef, numAtoms_, md.invmass);
     settleGpu_->set(idef);
 
     coordinateScalingKernelLaunchConfig_.gridSize[0] =