From 0558c2b62eb4a41bafba23dbd55c1e6ad05c1926 Mon Sep 17 00:00:00 2001 From: Sebastian Kehl Date: Thu, 21 Oct 2021 17:24:49 +0200 Subject: [PATCH] Fix use of simd-masks in gapsys softcore. Don't rely on bools to be implicitly cast to the correct BoolType mask but enforce this more explicitly. --- src/gromacs/gmxlib/nonbonded/nb_softcore.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gromacs/gmxlib/nonbonded/nb_softcore.h b/src/gromacs/gmxlib/nonbonded/nb_softcore.h index 5db070ff42..de1852d3b7 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_softcore.h +++ b/src/gromacs/gmxlib/nonbonded/nb_softcore.h @@ -86,8 +86,11 @@ static inline void reactionFieldQuadraticPotential(const RealType qq, RealType* dvdl, BoolType mask) { + RealType one(1); + RealType zero(0); + /* check if we have to use the hardcore values */ - BoolType computeValues = mask && (lambdaFac < 1 && 0 < alphaEff && facel != 0); + BoolType computeValues = mask && (lambdaFac < one && zero < alphaEff && facel != zero); if (gmx::anyTrue(computeValues)) { RealType lambdaFacRev = gmx::selectByMask(1 - lambdaFac, computeValues); @@ -146,8 +149,11 @@ static inline void ewaldQuadraticPotential(const RealType qq, RealType* dvdl, BoolType mask) { + RealType one(1); + RealType zero(0); + /* check if we have to use the hardcore values */ - BoolType computeValues = mask && (lambdaFac < 1 && 0 < alphaEff && facel != 0); + BoolType computeValues = mask && (lambdaFac < one && zero < alphaEff && facel != zero); if (gmx::anyTrue(computeValues)) { RealType lambdaFacRev = gmx::selectByMask(1 - lambdaFac, computeValues); @@ -212,8 +218,11 @@ static inline void lennardJonesQuadraticPotential(const RealType c6, constexpr real c_oneTwelth = 1.0_real / 12.0_real; constexpr real c_half = 1.0_real / 2.0_real; + RealType one(1); + RealType zero(0); + /* check if we have to use the hardcore values */ - BoolType computeValues = mask && (lambdaFac < 1 && 0 < alphaEff); + BoolType computeValues = mask && (lambdaFac < one && zero < alphaEff); if (gmx::anyTrue(computeValues)) { RealType lambdaFacRev = gmx::selectByMask(1 - lambdaFac, computeValues); -- 2.22.0