]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Work around bug in clang-3.6 with AVX. 629/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 2 Mar 2015 14:31:47 +0000 (15:31 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 2 Mar 2015 14:31:47 +0000 (15:31 +0100)
cmake/checks/check_01_cpu_features.cmake

index 480f5ff085b971fbe8bb0d077461f52d791fb893..6d7c466f82bce7e77d30264546453cc4782180a0 100644 (file)
@@ -109,9 +109,32 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
     "
     DEAL_II_HAVE_SSE2)
 
+  #
+  # clang-3.6.0 has a bug in operator+ on two VectorizedArray components as
+  # defined in deal.II. Therefore, the test for AVX needs to also test for
+  # operator+ to be correctly implemented.
+  #
   CHECK_CXX_SOURCE_RUNS(
     "
     #include <immintrin.h>
+    class VectorizedArray
+    {
+    public:
+      VectorizedArray &
+      operator += (const VectorizedArray &vec)
+      {
+        data = _mm256_add_pd (data, vec.data);
+        return *this;
+      }
+      __m256d data;
+    };
+    inline
+    VectorizedArray
+    operator + (const VectorizedArray &u, const VectorizedArray &v)
+    {
+      VectorizedArray tmp = u;
+      return tmp+=v;
+    }
     int main()
     {
       __m256d a, b;
@@ -133,6 +156,14 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
       for (int i=1; i<n_vectors; ++i)
         if (ptr[i] != 5.0625)
           return_value = 1;
+      VectorizedArray c, d, e;
+      c.data = b;
+      d.data = b;
+      e = c + d;
+      ptr = reinterpret_cast<double*>(&e.data);
+      for (int i=0; i<n_vectors; ++i)
+        if (ptr[i] != 4.5)
+          return_value = 1;
       _mm_free (data);
       return return_value;
     }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.