From: Joe Jordan Date: Wed, 14 Apr 2021 16:16:27 +0000 (+0000) Subject: Pass forcerec arguments instead of forcerec to gmx_nb_free_energy_kernel X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=f7fc116002966d93ff3f3145da0e6a43e4b17c6a;p=alexxy%2Fgromacs.git Pass forcerec arguments instead of forcerec to gmx_nb_free_energy_kernel --- diff --git a/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp b/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp index 8fde84db9f..6f51cee171 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp +++ b/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp @@ -202,7 +202,12 @@ template coords, gmx::ForceWithShiftForces* forceWithShiftForces, - const t_forcerec& fr, + const int ntype, + const real rlist, + const interaction_const_t& ic, + gmx::ArrayRef shiftvec, + gmx::ArrayRef nbfp, + gmx::ArrayRef nbfp_grid, gmx::ArrayRef chargeA, gmx::ArrayRef chargeB, gmx::ArrayRef typeA, @@ -230,9 +235,6 @@ static void nb_free_energy_kernel(const t_nblist& nlist, constexpr real two = 2.0; constexpr real six = 6.0; - /* Extract pointer to non-bonded interaction constants */ - const interaction_const_t* ic = fr.ic.get(); - // Extract pair list data const int nri = nlist.nri; gmx::ArrayRef iinr = nlist.iinr; @@ -241,14 +243,9 @@ static void nb_free_energy_kernel(const t_nblist& nlist, gmx::ArrayRef shift = nlist.shift; gmx::ArrayRef gid = nlist.gid; - const auto shiftvec = fr.shift_vec; - const int ntype = fr.ntype; - gmx::ArrayRef nbfp = fr.nbfp; - gmx::ArrayRef nbfp_grid = fr.ljpme_c6grid; - const real lambda_coul = lambda[static_cast(FreeEnergyPerturbationCouplingType::Coul)]; const real lambda_vdw = lambda[static_cast(FreeEnergyPerturbationCouplingType::Vdw)]; - const auto& scParams = *ic->softCoreParameters; + const auto& scParams = *ic.softCoreParameters; const real alpha_coul = scParams.alphaCoulomb; const real alpha_vdw = scParams.alphaVdw; const real lam_power = scParams.lambdaPower; @@ -259,23 +256,23 @@ static void nb_free_energy_kernel(const t_nblist& nlist, const bool doPotential = ((flags & GMX_NONBONDED_DO_POTENTIAL) != 0); // Extract data from interaction_const_t - const real facel = ic->epsfac; - const real rCoulomb = ic->rcoulomb; - const real krf = ic->reactionFieldCoefficient; - const real crf = ic->reactionFieldShift; - const real shLjEwald = ic->sh_lj_ewald; - const real rVdw = ic->rvdw; - const real dispersionShift = ic->dispersion_shift.cpot; - const real repulsionShift = ic->repulsion_shift.cpot; + const real facel = ic.epsfac; + const real rCoulomb = ic.rcoulomb; + const real krf = ic.reactionFieldCoefficient; + const real crf = ic.reactionFieldShift; + const real shLjEwald = ic.sh_lj_ewald; + const real rVdw = ic.rvdw; + const real dispersionShift = ic.dispersion_shift.cpot; + const real repulsionShift = ic.repulsion_shift.cpot; // Note that the nbnxm kernels do not support Coulomb potential switching at all - GMX_ASSERT(ic->coulomb_modifier != InteractionModifiers::PotSwitch, + GMX_ASSERT(ic.coulomb_modifier != InteractionModifiers::PotSwitch, "Potential switching is not supported for Coulomb with FEP"); real vdw_swV3, vdw_swV4, vdw_swV5, vdw_swF2, vdw_swF3, vdw_swF4; if (vdwModifierIsPotSwitch) { - const real d = ic->rvdw - ic->rvdw_switch; + const real d = ic.rvdw - ic.rvdw_switch; vdw_swV3 = -10.0 / (d * d * d); vdw_swV4 = 15.0 / (d * d * d * d); vdw_swV5 = -6.0 / (d * d * d * d * d); @@ -290,7 +287,7 @@ static void nb_free_energy_kernel(const t_nblist& nlist, } NbkernelElecType icoul; - if (ic->eeltype == CoulombInteractionType::Cut || EEL_RF(ic->eeltype)) + if (ic.eeltype == CoulombInteractionType::Cut || EEL_RF(ic.eeltype)) { icoul = NbkernelElecType::ReactionField; } @@ -299,7 +296,7 @@ static void nb_free_energy_kernel(const t_nblist& nlist, icoul = NbkernelElecType::None; } - real rcutoff_max2 = std::max(ic->rcoulomb, ic->rvdw); + real rcutoff_max2 = std::max(ic.rcoulomb, ic.rvdw); rcutoff_max2 = rcutoff_max2 * rcutoff_max2; const real* tab_ewald_F_lj = nullptr; @@ -312,18 +309,18 @@ static void nb_free_energy_kernel(const t_nblist& nlist, real sh_ewald = 0; if (elecInteractionTypeIsEwald || vdwInteractionTypeIsEwald) { - sh_ewald = ic->sh_ewald; + sh_ewald = ic.sh_ewald; } if (elecInteractionTypeIsEwald) { - const auto& coulombTables = *ic->coulombEwaldTables; + const auto& coulombTables = *ic.coulombEwaldTables; ewtab = coulombTables.tableFDV0.data(); coulombTableScale = coulombTables.scale; coulombTableScaleInvHalf = half / coulombTableScale; } if (vdwInteractionTypeIsEwald) { - const auto& vdwTables = *ic->vdwEwaldTables; + const auto& vdwTables = *ic.vdwEwaldTables; tab_ewald_F_lj = vdwTables.tableF.data(); tab_ewald_V_lj = vdwTables.tableV.data(); vdwTableScale = vdwTables.scale; @@ -377,7 +374,7 @@ static void nb_free_energy_kernel(const t_nblist& nlist, real* gmx_restrict f = &(forceWithShiftForces->force()[0][0]); real* gmx_restrict fshift = &(forceWithShiftForces->shiftForces()[0][0]); - const real rlistSquared = gmx::square(fr.rlist); + const real rlistSquared = gmx::square(rlist); int numExcludedPairsBeyondRlist = 0; @@ -624,7 +621,7 @@ static void nb_free_energy_kernel(const t_nblist& nlist, if (vdwModifierIsPotSwitch) { - RealType d = rV - ic->rvdw_switch; + RealType d = rV - ic.rvdw_switch; d = (d > zero) ? d : zero; const RealType d2 = d * d; const RealType sw = @@ -862,14 +859,19 @@ static void nb_free_energy_kernel(const t_nblist& nlist, "The error is likely triggered by the use of couple-intramol=no " "and the maximal distance in the decoupled molecule exceeding rlist.", numExcludedPairsBeyondRlist, - fr.rlist); + rlist); } } typedef void (*KernelFunction)(const t_nblist& nlist, gmx::ArrayRef coords, gmx::ForceWithShiftForces* forceWithShiftForces, - const t_forcerec& fr, + const int ntype, + const real rlist, + const interaction_const_t& ic, + gmx::ArrayRef shiftvec, + gmx::ArrayRef nbfp, + gmx::ArrayRef nbfp_grid, gmx::ArrayRef chargeA, gmx::ArrayRef chargeB, gmx::ArrayRef typeA, @@ -997,7 +999,13 @@ static KernelFunction dispatchKernel(const bool scLambdasOrAlpha void gmx_nb_free_energy_kernel(const t_nblist& nlist, gmx::ArrayRef coords, gmx::ForceWithShiftForces* ff, - const t_forcerec& fr, + const bool useSimd, + const int ntype, + const real rlist, + const interaction_const_t& ic, + gmx::ArrayRef shiftvec, + gmx::ArrayRef nbfp, + gmx::ArrayRef nbfp_grid, gmx::ArrayRef chargeA, gmx::ArrayRef chargeB, gmx::ArrayRef typeA, @@ -1009,7 +1017,6 @@ void gmx_nb_free_energy_kernel(const t_nblist& nlist, gmx::ArrayRef energygrp_vdw, t_nrnb* nrnb) { - const interaction_const_t& ic = *fr.ic; GMX_ASSERT(EEL_PME_EWALD(ic.eeltype) || ic.eeltype == CoulombInteractionType::Cut || EEL_RF(ic.eeltype), "Unsupported eeltype with free energy"); GMX_ASSERT(ic.softCoreParameters, "We need soft-core parameters"); @@ -1019,7 +1026,6 @@ void gmx_nb_free_energy_kernel(const t_nblist& nlist, const bool elecInteractionTypeIsEwald = (EEL_PME_EWALD(ic.eeltype)); const bool vdwModifierIsPotSwitch = (ic.vdw_modifier == InteractionModifiers::PotSwitch); bool scLambdasOrAlphasDiffer = true; - const bool useSimd = fr.use_simd_kernels; if (scParams.alphaCoulomb == 0 && scParams.alphaVdw == 0) { @@ -1042,5 +1048,23 @@ void gmx_nb_free_energy_kernel(const t_nblist& nlist, vdwModifierIsPotSwitch, useSimd, ic); - kernelFunc(nlist, coords, ff, fr, chargeA, chargeB, typeA, typeB, flags, lambda, dvdl, energygrp_elec, energygrp_vdw, nrnb); + kernelFunc(nlist, + coords, + ff, + ntype, + rlist, + ic, + shiftvec, + nbfp, + nbfp_grid, + chargeA, + chargeB, + typeA, + typeB, + flags, + lambda, + dvdl, + energygrp_elec, + energygrp_vdw, + nrnb); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_free_energy.h b/src/gromacs/gmxlib/nonbonded/nb_free_energy.h index 97e64eb0ff..c08ff371cf 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_free_energy.h +++ b/src/gromacs/gmxlib/nonbonded/nb_free_energy.h @@ -44,6 +44,7 @@ struct t_forcerec; struct t_nrnb; struct t_nblist; +struct interaction_const_t; namespace gmx { class ForceWithShiftForces; @@ -54,7 +55,13 @@ class ArrayRef; void gmx_nb_free_energy_kernel(const t_nblist& nlist, gmx::ArrayRef coords, gmx::ForceWithShiftForces* forceWithShiftForces, - const t_forcerec& fr, + bool useSimd, + int ntype, + real rlist, + const interaction_const_t& ic, + gmx::ArrayRef shiftvec, + gmx::ArrayRef nbfp, + gmx::ArrayRef nbfp_grid, gmx::ArrayRef chargeA, gmx::ArrayRef chargeB, gmx::ArrayRef typeA, diff --git a/src/gromacs/gmxlib/nonbonded/tests/nb_free_energy.cpp b/src/gromacs/gmxlib/nonbonded/tests/nb_free_energy.cpp index 145c70f340..5b7e08454c 100644 --- a/src/gromacs/gmxlib/nonbonded/tests/nb_free_energy.cpp +++ b/src/gromacs/gmxlib/nonbonded/tests/nb_free_energy.cpp @@ -447,7 +447,13 @@ protected: gmx_nb_free_energy_kernel(nbl, x_.arrayRefWithPadding().unpaddedArrayRef(), &forces, - fr, + fr.use_simd_kernels, + fr.ntype, + fr.rlist, + *fr.ic, + fr.shift_vec, + fr.nbfp, + fr.ljpme_c6grid, input_.atoms.chargeA, input_.atoms.chargeB, input_.atoms.typeA, diff --git a/src/gromacs/nbnxm/kerneldispatch.cpp b/src/gromacs/nbnxm/kerneldispatch.cpp index 93e28f8487..fbd58b0af7 100644 --- a/src/gromacs/nbnxm/kerneldispatch.cpp +++ b/src/gromacs/nbnxm/kerneldispatch.cpp @@ -556,7 +556,13 @@ void nonbonded_verlet_t::dispatchFreeEnergyKernel(gmx::InteractionLocality gmx_nb_free_energy_kernel(*nbl_fep[th], coords, forceWithShiftForces, - fr, + fr.use_simd_kernels, + fr.ntype, + fr.rlist, + *fr.ic, + fr.shift_vec, + fr.nbfp, + fr.ljpme_c6grid, chargeA, chargeB, typeA, @@ -617,7 +623,13 @@ void nonbonded_verlet_t::dispatchFreeEnergyKernel(gmx::InteractionLocality gmx_nb_free_energy_kernel(*nbl_fep[th], coords, forceWithShiftForces, - fr, + fr.use_simd_kernels, + fr.ntype, + fr.rlist, + *fr.ic, + fr.shift_vec, + fr.nbfp, + fr.ljpme_c6grid, chargeA, chargeB, typeA,