Work around false xlc-13.1.5 bug in SIMD test
authorErik Lindahl <erik@kth.se>
Thu, 9 Feb 2017 14:45:51 +0000 (15:45 +0100)
committerErik Lindahl <erik@kth.se>
Thu, 9 Feb 2017 15:45:00 +0000 (16:45 +0100)
atan2(0,0) should return 0.0, which the Gromacs simd implementation
does. However, since at least one compiler produces -nan for the
standard library version it's better to compare with the known
correct value rather than calling std:atan2(0,0).

Refs #2102.

Change-Id: I60449e9f16fb1ab79486927a3e9993da0cce937f

src/gromacs/simd/tests/simd_math.cpp

index d9aa834dec488223b0e7f18a78c09d716dec4333..e02efcaf95fb945c89cd2571026521dbf00388b8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2017, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -439,8 +439,9 @@ TEST_F(SimdMathTest, atan2)
     GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom1R(std::atan2(1.0, 0.0)), atan2(rSimd_1_2_3, setZero()));
     GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom1R(std::atan2(0.0, -1.0)), atan2(setZero(), rSimd_m1_m2_m3));
     GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom1R(std::atan2(-1.0, 0.0)), atan2(rSimd_m1_m2_m3, setZero()));
-    // degenerate value (origin) should return 0.0
-    GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom1R(std::atan2(0.0, 0.0)), atan2(setSimdRealFrom3R(0.0, 0.0, 0.0), setZero()));
+    // degenerate value (origin) should return 0.0. At least IBM xlc 13.1.5 gets the reference
+    // value wrong (-nan) at -O3 optimization, so we compare to the correct value (0.0) instead.
+    GMX_EXPECT_SIMD_REAL_NEAR(setSimdRealFrom1R(0.0), atan2(setSimdRealFrom3R(0.0, 0.0, 0.0), setZero()));
 }
 
 /*! \brief Evaluate reference version of PME force correction. */