Fix use of simd-masks in gapsys softcore.
authorSebastian Kehl <sebastian.kehl@mpcdf.mpg.de>
Thu, 21 Oct 2021 15:24:49 +0000 (17:24 +0200)
committerAndrey Alekseenko <al42and@gmail.com>
Thu, 21 Oct 2021 21:58:00 +0000 (21:58 +0000)
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

index 5db070ff42a034ff04ff04d783f45d6ab7ec1cc6..de1852d3b718014fe904d5d09d70f02f822d4bcc 100644 (file)
@@ -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);