Make SIMD ambiguous test work with float/double only
authorBerk Hess <hess@kth.se>
Thu, 5 Oct 2017 16:31:58 +0000 (18:31 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Thu, 5 Oct 2017 21:25:21 +0000 (23:25 +0200)
Fixes #2262

Change-Id: I612aea147a7808a72aa05dca44f588a60c27eea0

docs/doxygen/suppressions.txt
src/gromacs/simd/tests/simd_ambiguous.cpp

index c8b72742cafc2185d150dcb68f6054b15cf21518..7ca9ce61fd371de8f21c70a09ffaf56dbd1b228a 100644 (file)
@@ -50,7 +50,6 @@ src/gromacs/simd/impl_sparc64_hpc_ace/impl_sparc64_hpc_ace_common.h: warning: sh
 src/gromacs/simd/tests/scalar.cpp: warning: includes "simd.h" unnecessarily
 src/gromacs/simd/tests/scalar_math.cpp: warning: includes "simd.h" unnecessarily
 src/gromacs/simd/tests/scalar_util.cpp: warning: includes "simd.h" unnecessarily
-src/gromacs/simd/tests/simd_ambiguous.cpp: warning: includes "simd.h" unnecessarily
 src/gromacs/tables/cubicsplinetable.h: warning: includes "simd.h" unnecessarily
 src/gromacs/tables/quadraticsplinetable.h: warning: includes "simd.h" unnecessarily
 
index 345cd0e085d621bfbd11ca0deae25f184a4632ab..072cf9e945b3708e8871eeff552f616d51d3c0d4 100644 (file)
  */
 int main()
 {
+    /* We cannot check for SIMD float or double support at cmake,
+     * only for general SIMD support. Therefore with SIMD, but without
+     * SIMD float or double support we make the compilation fail with
+     * a static_assert instead of the ambiguous overload error
+     */
+    constexpr bool testFloat       = std::is_same<TEST_PREC, float>::value;
+    constexpr bool testDouble      = std::is_same<TEST_PREC, double>::value;
+    constexpr bool haveSimdSupport = GMX_SIMD;
+    constexpr bool haveSimdFloat   = GMX_SIMD_HAVE_FLOAT;
+    constexpr bool haveSimdDouble  = GMX_SIMD_HAVE_DOUBLE;
+    static_assert(!haveSimdSupport || !testFloat || haveSimdFloat, "Assertion failure to make test fail without SIMD float support");
+    static_assert(!haveSimdSupport || !testDouble || haveSimdDouble, "Assertion failure to make test fail without SIMD double support");
+
     TEST_PREC  d = 0;
     TEST_PREC *m = &d;
     gmx::TEST_FUNC(gmx::load(m));