Use ArrayRefs instead of mdatoms in gmx_nb_free_energy_kernel signature
authorJoe Jordan <ejjordan12@gmail.com>
Fri, 26 Mar 2021 12:08:14 +0000 (12:08 +0000)
committerJoe Jordan <ejjordan12@gmail.com>
Fri, 26 Mar 2021 12:08:14 +0000 (12:08 +0000)
In addition to helping facilitate the coming mdatoms refactoring,
this is needed to facilitate calling gmx_nb_free_energy_kernel from
nblib without constructing mdatoms.

src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp
src/gromacs/gmxlib/nonbonded/nb_free_energy.h
src/gromacs/mdlib/sim_util.cpp
src/gromacs/nbnxm/kerneldispatch.cpp
src/gromacs/nbnxm/nbnxm.h

index 5fb29200b803afac67fe445ca99453916bdc9747..86c17b74792cbb5b0686e3121b1b3e493a0a0ff8 100644 (file)
@@ -203,7 +203,10 @@ static void nb_free_energy_kernel(const t_nblist&                nlist,
                                   gmx::ArrayRef<const gmx::RVec> coords,
                                   gmx::ForceWithShiftForces*     forceWithShiftForces,
                                   const t_forcerec&              fr,
-                                  const t_mdatoms&               mdatoms,
+                                  gmx::ArrayRef<const real>      chargeA,
+                                  gmx::ArrayRef<const real>      chargeB,
+                                  gmx::ArrayRef<const int>       typeA,
+                                  gmx::ArrayRef<const int>       typeB,
                                   int                            flags,
                                   gmx::ArrayRef<const real>      lambda,
                                   gmx::ArrayRef<real>            dvdl,
@@ -239,10 +242,6 @@ static void nb_free_energy_kernel(const t_nblist&                nlist,
     gmx::ArrayRef<const int> gid    = nlist.gid;
 
     const real*               shiftvec  = fr.shift_vec[0];
-    const real*               chargeA   = mdatoms.chargeA;
-    const real*               chargeB   = mdatoms.chargeB;
-    const int*                typeA     = mdatoms.typeA;
-    const int*                typeB     = mdatoms.typeB;
     const int                 ntype     = fr.ntype;
     gmx::ArrayRef<const real> nbfp      = fr.nbfp;
     gmx::ArrayRef<const real> nbfp_grid = fr.ljpme_c6grid;
@@ -870,7 +869,10 @@ typedef void (*KernelFunction)(const t_nblist&                nlist,
                                gmx::ArrayRef<const gmx::RVec> coords,
                                gmx::ForceWithShiftForces*     forceWithShiftForces,
                                const t_forcerec&              fr,
-                               const t_mdatoms&               mdatoms,
+                               gmx::ArrayRef<const real>      chargeA,
+                               gmx::ArrayRef<const real>      chargeB,
+                               gmx::ArrayRef<const int>       typeA,
+                               gmx::ArrayRef<const int>       typeB,
                                int                            flags,
                                gmx::ArrayRef<const real>      lambda,
                                gmx::ArrayRef<real>            dvdl,
@@ -995,7 +997,10 @@ void gmx_nb_free_energy_kernel(const t_nblist&                nlist,
                                gmx::ArrayRef<const gmx::RVec> coords,
                                gmx::ForceWithShiftForces*     ff,
                                const t_forcerec&              fr,
-                               const t_mdatoms&               mdatoms,
+                               gmx::ArrayRef<const real>      chargeA,
+                               gmx::ArrayRef<const real>      chargeB,
+                               gmx::ArrayRef<const int>       typeA,
+                               gmx::ArrayRef<const int>       typeB,
                                int                            flags,
                                gmx::ArrayRef<const real>      lambda,
                                gmx::ArrayRef<real>            dvdl,
@@ -1036,5 +1041,5 @@ void gmx_nb_free_energy_kernel(const t_nblist&                nlist,
                                 vdwModifierIsPotSwitch,
                                 useSimd,
                                 ic);
-    kernelFunc(nlist, coords, ff, fr, mdatoms, flags, lambda, dvdl, energygrp_elec, energygrp_vdw, nrnb);
+    kernelFunc(nlist, coords, ff, fr, chargeA, chargeB, typeA, typeB, flags, lambda, dvdl, energygrp_elec, energygrp_vdw, nrnb);
 }
index 67920fc4ae8712d42975f52ad5fbbba9c309494a..97e64eb0ff858ea3277a8f49aac6812236dd97b2 100644 (file)
@@ -42,7 +42,6 @@
 #include "gromacs/utility/basedefinitions.h"
 
 struct t_forcerec;
-struct t_mdatoms;
 struct t_nrnb;
 struct t_nblist;
 namespace gmx
@@ -56,7 +55,10 @@ void gmx_nb_free_energy_kernel(const t_nblist&                nlist,
                                gmx::ArrayRef<const gmx::RVec> coords,
                                gmx::ForceWithShiftForces*     forceWithShiftForces,
                                const t_forcerec&              fr,
-                               const t_mdatoms&               mdatoms,
+                               gmx::ArrayRef<const real>      chargeA,
+                               gmx::ArrayRef<const real>      chargeB,
+                               gmx::ArrayRef<const int>       typeA,
+                               gmx::ArrayRef<const int>       typeB,
                                int                            flags,
                                gmx::ArrayRef<const real>      lambda,
                                gmx::ArrayRef<real>            dvdl,
index abb68c4a765906d30c5a60e2090fa37f61549860..bfe35003764c5e732acdc199fd1e97995f7c1fdc 100644 (file)
@@ -1759,7 +1759,10 @@ void do_force(FILE*                               fplog,
                                       *fr,
                                       x.unpaddedArrayRef(),
                                       &forceOutNonbonded->forceWithShiftForces(),
-                                      *mdatoms,
+                                      gmx::arrayRefFromArray(mdatoms->chargeA, mdatoms->nr),
+                                      gmx::arrayRefFromArray(mdatoms->chargeB, mdatoms->nr),
+                                      gmx::arrayRefFromArray(mdatoms->typeA, mdatoms->nr),
+                                      gmx::arrayRefFromArray(mdatoms->typeB, mdatoms->nr),
                                       inputrec.fepvals.get(),
                                       lambda,
                                       enerd,
@@ -1772,7 +1775,10 @@ void do_force(FILE*                               fplog,
                                           *fr,
                                           x.unpaddedArrayRef(),
                                           &forceOutNonbonded->forceWithShiftForces(),
-                                          *mdatoms,
+                                          gmx::arrayRefFromArray(mdatoms->chargeA, mdatoms->nr),
+                                          gmx::arrayRefFromArray(mdatoms->chargeB, mdatoms->nr),
+                                          gmx::arrayRefFromArray(mdatoms->typeA, mdatoms->nr),
+                                          gmx::arrayRefFromArray(mdatoms->typeB, mdatoms->nr),
                                           inputrec.fepvals.get(),
                                           lambda,
                                           enerd,
index e40f04f8bba01545ada1630fd217fe3d23e6eb24..0bfa57b9926e060dc2917df15e8244d1c62a6f72 100644 (file)
@@ -497,7 +497,10 @@ void nonbonded_verlet_t::dispatchFreeEnergyKernel(gmx::InteractionLocality
                                                   const t_forcerec&              fr,
                                                   gmx::ArrayRef<const gmx::RVec> coords,
                                                   gmx::ForceWithShiftForces* forceWithShiftForces,
-                                                  const t_mdatoms&           mdatoms,
+                                                  gmx::ArrayRef<const real>  chargeA,
+                                                  gmx::ArrayRef<const real>  chargeB,
+                                                  gmx::ArrayRef<const int>   typeA,
+                                                  gmx::ArrayRef<const int>   typeB,
                                                   t_lambda*                  fepvals,
                                                   gmx::ArrayRef<const real>  lambda,
                                                   gmx_enerdata_t*            enerd,
@@ -550,7 +553,10 @@ void nonbonded_verlet_t::dispatchFreeEnergyKernel(gmx::InteractionLocality
                                       coords,
                                       forceWithShiftForces,
                                       fr,
-                                      mdatoms,
+                                      chargeA,
+                                      chargeB,
+                                      typeA,
+                                      typeB,
                                       kernelFlags,
                                       kernelLambda,
                                       kernelDvdl,
@@ -608,7 +614,10 @@ void nonbonded_verlet_t::dispatchFreeEnergyKernel(gmx::InteractionLocality
                                               coords,
                                               forceWithShiftForces,
                                               fr,
-                                              mdatoms,
+                                              chargeA,
+                                              chargeB,
+                                              typeA,
+                                              typeB,
                                               kernelFlags,
                                               kernelLambda,
                                               kernelDvdl,
index 37f09824e7ca74f3d1ef56937677d61985d3c615..bbfe22453d53b78f3986fdf4677eb4b7805fa414 100644 (file)
@@ -135,7 +135,6 @@ class PairSearch;
 class PairlistSets;
 struct t_commrec;
 struct t_lambda;
-struct t_mdatoms;
 struct t_nrnb;
 struct t_forcerec;
 struct t_inputrec;
@@ -371,7 +370,10 @@ public:
                                   const t_forcerec&              fr,
                                   gmx::ArrayRef<const gmx::RVec> coords,
                                   gmx::ForceWithShiftForces*     forceWithShiftForces,
-                                  const t_mdatoms&               mdatoms,
+                                  gmx::ArrayRef<const real>      chargeA,
+                                  gmx::ArrayRef<const real>      chargeB,
+                                  gmx::ArrayRef<const int>       typeA,
+                                  gmx::ArrayRef<const int>       typeB,
                                   t_lambda*                      fepvals,
                                   gmx::ArrayRef<const real>      lambda,
                                   gmx_enerdata_t*                enerd,