From: Erik Lindahl Date: Thu, 5 Jun 2014 14:34:26 +0000 (+0200) Subject: Modify single/double EPS to agree with ISO C X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=97161d2601f4f98a45d49de2ef8f630f18c94455;p=alexxy%2Fgromacs.git Modify single/double EPS to agree with ISO C 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 --- diff --git a/src/gromacs/legacyheaders/types/simple.h b/src/gromacs/legacyheaders/types/simple.h index f00da633cb..9a69a3af6b 100644 --- a/src/gromacs/legacyheaders/types/simple.h +++ b/src/gromacs/legacyheaders/types/simple.h @@ -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! */ diff --git a/src/gromacs/simd/tests/simd_math.cpp b/src/gromacs/simd/tests/simd_math.cpp index 9d4d63eeab..a064ae1fae 100644 --- a/src/gromacs/simd/tests/simd_math.cpp +++ b/src/gromacs/simd/tests/simd_math.cpp @@ -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);