]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid C-style casts in cpu/compiler_feature checks
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 12 Dec 2018 22:50:23 +0000 (23:50 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 12 Dec 2018 23:33:38 +0000 (00:33 +0100)
cmake/checks/check_01_cpu_features.cmake
cmake/checks/check_02_compiler_features.cmake

index 5404df016c8c1540bfcee7070b60ec3bd53dfa1b..f69c1ee268f5df9017994c49f2f86569cd4ea82c 100644 (file)
@@ -87,14 +87,14 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
     __m128d * data =
       reinterpret_cast<__m128d*>(_mm_malloc (2*vector_bytes, vector_bytes));
     double * ptr = reinterpret_cast<double*>(&a);
-    ptr[0] = (volatile double)(1.0);
+    ptr[0] = static_cast<volatile double>(1.0);
     for (int i=1; i<n_vectors; ++i)
       ptr[i] = 0.0;
-    b = _mm_set1_pd ((volatile double)(2.25));
+    b = _mm_set1_pd (static_cast<volatile double>(2.25));
     data[0] = _mm_add_pd (a, b);
     data[1] = _mm_mul_pd (b, data[0]);
     ptr = reinterpret_cast<double*>(&data[1]);
-    unsigned int return_value = 0;
+    int return_value = 0;
     if (ptr[0] != 7.3125)
       return_value = 1;
     for (int i=1; i<n_vectors; ++i)
@@ -143,14 +143,14 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
       __m256d * data =
         reinterpret_cast<__m256d*>(_mm_malloc (2*vector_bytes, vector_bytes));
       double * ptr = reinterpret_cast<double*>(&a);
-      ptr[0] = (volatile double)(1.0);
+      ptr[0] = static_cast<volatile double>(1.0);
       for (int i=1; i<n_vectors; ++i)
         ptr[i] = 0.0;
-      b = _mm256_set1_pd ((volatile double)(2.25));
+      b = _mm256_set1_pd (static_cast<volatile double>(2.25));
       data[0] = _mm256_add_pd (a, b);
       data[1] = _mm256_mul_pd (b, data[0]);
       ptr = reinterpret_cast<double*>(&data[1]);
-      unsigned int return_value = 0;
+      int return_value = 0;
       if (ptr[0] != 7.3125)
         return_value = 1;
       for (int i=1; i<n_vectors; ++i)
@@ -184,7 +184,7 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
       __m512d * data =
         reinterpret_cast<__m512d*>(_mm_malloc (2*vector_bytes, vector_bytes));
       double * ptr = reinterpret_cast<double*>(&a);
-      ptr[0] = (volatile double)(1.0);
+      ptr[0] = static_cast<volatile double>(1.0);
       for (int i=1; i<n_vectors; ++i)
         ptr[i] = 0.0;
       const volatile double x = 2.25;
@@ -192,7 +192,7 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
       data[0] = _mm512_add_pd (a, b);
       data[1] = _mm512_mul_pd (b, data[0]);
       ptr = reinterpret_cast<double*>(&data[1]);
-      unsigned int return_value = 0;
+      int return_value = 0;
       if (ptr[0] != 7.3125)
         return_value = 1;
       for (int i=1; i<n_vectors; ++i)
@@ -218,20 +218,20 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
     __vector double a, b, data1, data2;
     const int n_vectors = sizeof(a)/sizeof(double);
     double * ptr = reinterpret_cast<double*>(&a);
-    ptr[0] = (volatile double)(1.0);
+    ptr[0] = static_cast<volatile double>(1.0);
     for (int i=1; i<n_vectors; ++i)
       ptr[i] = 0.0;
-    b = vec_splats ((volatile double)(2.25));
+    b = vec_splats (static_cast<volatile double>(2.25));
     data1 = vec_add (a, b);
     data2 = vec_mul (b, data1);
     ptr = reinterpret_cast<double*>(&data2);
-    unsigned int return_value = 0;
+    int return_value = 0;
     if (ptr[0] != 7.3125)
       return_value += 1;
     for (int i=1; i<n_vectors; ++i)
       if (ptr[i] != 5.0625)
         return_value += 2;
-    b = vec_splats ((volatile double)(-1.0));
+    b = vec_splats (static_cast<volatile double>(-1.0));
     data1 = vec_abs(vec_mul (b, data2));
     vec_vsx_st(data1, 0, ptr);
     b = vec_vsx_ld(0, ptr);
index 984ed8ddd5dfe5a244a84cd0347cb6befba7f93d..1b48a3c8d66495432b7a78952fc2230eb28e27e4 100644 (file)
@@ -118,8 +118,8 @@ CHECK_CXX_COMPILER_BUG(
 #
 CHECK_CXX_SOURCE_COMPILES(
   "
-  bool f() {}
-  int main(){ if (__builtin_expect(f(),false)) ; }
+  bool f() { return true; }
+  int main(){ if (__builtin_expect(f(),false)) {} }
   "
   DEAL_II_HAVE_BUILTIN_EXPECT)
 

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.