Modify single/double EPS to agree with ISO C
authorErik Lindahl <erik@kth.se>
Thu, 5 Jun 2014 14:34:26 +0000 (16:34 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 9 Jun 2014 05:12:51 +0000 (07:12 +0200)
The previous Gromacs values were a factor 2 too tight. While
we're at it, we also added float modifiers to the single-precision
constants, increased the accuracy in the double max/min values,
and improved the least significant bit in one of the single-precision
values. The previous relative accuracies for the PME correction
analytical approximations where set fairly arbitrary by dividing a
tightly chose constant with GMX_REAL_EPS, and since this is now a
larger number the unit test tolerance for those corrections has been
increased slightly to avoid triggering false failures.

Fixes #1356.

Change-Id: If29d2ff4141d86fd019e0dbdbfb7737ead28c3d4

src/gromacs/legacyheaders/types/simple.h
src/gromacs/simd/tests/simd_math.cpp

index f00da633cb59f22468413daa2b2c068bff50fca1..9a69a3af6bc831f46c389b94a56bdc6cdb78a2bb 100644 (file)
@@ -92,22 +92,22 @@ typedef int         atom_id;      /* To indicate an atoms id         */
 #define NO_ATID     (atom_id)(~0) /* Use this to indicate invalid atid */
 
 /*! \brief Double precision accuracy */
-#define GMX_DOUBLE_EPS   1.11022302E-16
+#define GMX_DOUBLE_EPS   2.2204460492503131e-16
 
 /*! \brief Maximum double precision value - reduced 1 unit in last digit for MSVC */
-#define GMX_DOUBLE_MAX   1.79769312E+308
+#define GMX_DOUBLE_MAX   1.7976931348623157e+308
 
 /*! \brief Minimum double precision value */
-#define GMX_DOUBLE_MIN   2.22507386E-308
+#define GMX_DOUBLE_MIN   2.2250738585072014e-308
 
 /*! \brief Single precision accuracy */
-#define GMX_FLOAT_EPS    5.96046448E-08
+#define GMX_FLOAT_EPS    1.19209290e-07F
 
 /*! \brief Maximum single precision value - reduced 1 unit in last digit for MSVC */
-#define GMX_FLOAT_MAX    3.40282346E+38
+#define GMX_FLOAT_MAX    3.40282346E+38F
 
 /*! \brief Minimum single precision value */
-#define GMX_FLOAT_MIN    1.17549435E-38
+#define GMX_FLOAT_MIN    1.175494351E-38F
 
 
 /* Check whether we already have a real type! */
index 9d4d63eeabd07e2a7771c36bd6ba8248e93a53ee..a064ae1fae16a5879f3fc80eb19b71e893459aee 100644 (file)
@@ -451,9 +451,9 @@ TEST_F(SimdMathTest, gmxSimdPmecorrForceR)
 {
     // Pme correction only needs to be ~1e-6 accuracy single, 1e-10 double
 #ifdef GMX_DOUBLE
-    setUlpTol((gmx_int64_t)(1e-10/GMX_REAL_EPS));
+    setUlpTol((gmx_int64_t)(5e-10/GMX_REAL_EPS));
 #else
-    setUlpTol((gmx_int64_t)(1e-6/GMX_REAL_EPS));
+    setUlpTol((gmx_int64_t)(5e-6/GMX_REAL_EPS));
 #endif
 
     setRange(0.15, 4);
@@ -473,9 +473,9 @@ TEST_F(SimdMathTest, gmxSimdPmecorrPotentialR)
 {
     // Pme correction only needs to be ~1e-6 accuracy single, 1e-10 double
 #ifdef GMX_DOUBLE
-    setUlpTol((gmx_int64_t)(1e-10/GMX_REAL_EPS));
+    setUlpTol((gmx_int64_t)(5e-10/GMX_REAL_EPS));
 #else
-    setUlpTol((gmx_int64_t)(1e-6/GMX_REAL_EPS));
+    setUlpTol((gmx_int64_t)(5e-6/GMX_REAL_EPS));
 #endif
     setRange(0.15, 4);
     setAbsTol(GMX_REAL_EPS);