]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add DEAL_II_ALLOW_PLATFORM_INTROSPECTION
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 27 Feb 2013 18:27:06 +0000 (18:27 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 27 Feb 2013 18:27:06 +0000 (18:27 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@28620 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/CMakeLists.txt
deal.II/cmake/checks/check_01_cpu_features.cmake
deal.II/cmake/setup_cached_variables.cmake
deal.II/cmake/setup_compiler_flags_gnu.cmake
deal.II/doc/development/cmake.html

index 2fe926b748d92c2d58108b1a646d9577623b6be4..5cb5f2936856cbde9ec2c54084b7e6b4ce2d338c 100644 (file)
@@ -44,11 +44,11 @@ LIST(APPEND CMAKE_MODULE_PATH
 #
 # Load all macros:
 #
+INCLUDE(setup_external_macros)
 FILE(GLOB _macro_files "cmake/macros/*.cmake")
 FOREACH(_file ${_macro_files})
   INCLUDE(${_file})
 ENDFOREACH()
-INCLUDE(setup_external_macros)
 
 #
 # Check whether the doc and bundled folders are available:
index 056758c64ec0e2467e0f2193b2051f3479aca738..805ab227974a779371939dd7c2820028fd1bddc3 100644 (file)
@@ -40,66 +40,35 @@ INCLUDE(TestBigEndian)
 TEST_BIG_ENDIAN(DEAL_II_WORDS_BIGENDIAN)
 
 
-#
-# Check whether the compiler allows for vectorization and that
-# vectorization actually works on the given CPU. For this test, we use
-# compiler intrinsics similar to what is used in the deal.II library and
-# check whether the arithmetic operations are correctly performed on
-# examples where all numbers are exactly represented as floating point
-# numbers.
-#
-# - Matthias Maier, rewritten 2012
-#
-CHECK_CXX_SOURCE_RUNS(
-  "
-  #include <emmintrin.h>
-  #include <mm_malloc.h>
-  int main()
-  {
-  __m128d a, b;
-  const unsigned int vector_bytes = sizeof(__m128d);
-  const int n_vectors = vector_bytes/sizeof(double);
-  __m128d * data =
-    reinterpret_cast<__m128d*>(_mm_malloc (2*vector_bytes, vector_bytes));
-  double * ptr = reinterpret_cast<double*>(&a);
-  ptr[0] = (volatile double)(1.0);
-  for (int i=1; i<n_vectors; ++i)
-    ptr[i] = 0.0;
-  b = _mm_set1_pd ((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;
-  if (ptr[0] != 7.3125)
-    return_value = 1;
-  for (int i=1; i<n_vectors; ++i)
-    if (ptr[i] != 5.0625)
-      return_value = 1;
-  _mm_free (data);
-  return return_value;
-  }
-  "
-  DEAL_II_HAVE_SSE2)
-
-
-CHECK_CXX_SOURCE_RUNS(
-  "
-  #include <immintrin.h>
-  #include <mm_malloc.h>
-  int main()
-  {
-    __m256d a, b;
-    const unsigned int vector_bytes = sizeof(__m256d);
+IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
+  #
+  # Check whether the compiler allows for vectorization and that
+  # vectorization actually works on the given CPU. For this test, we use
+  # compiler intrinsics similar to what is used in the deal.II library and
+  # check whether the arithmetic operations are correctly performed on
+  # examples where all numbers are exactly represented as floating point
+  # numbers.
+  #
+  # - Matthias Maier, rewritten 2012
+  #
+  CHECK_CXX_SOURCE_RUNS(
+    "
+    #include <emmintrin.h>
+    #include <mm_malloc.h>
+    int main()
+    {
+    __m128d a, b;
+    const unsigned int vector_bytes = sizeof(__m128d);
     const int n_vectors = vector_bytes/sizeof(double);
-    __m256d * data =
-      reinterpret_cast<__m256d*>(_mm_malloc (2*vector_bytes, vector_bytes));
+    __m128d * data =
+      reinterpret_cast<__m128d*>(_mm_malloc (2*vector_bytes, vector_bytes));
     double * ptr = reinterpret_cast<double*>(&a);
     ptr[0] = (volatile double)(1.0);
     for (int i=1; i<n_vectors; ++i)
       ptr[i] = 0.0;
-    b = _mm256_set1_pd ((volatile double)(2.25));
-    data[0] = _mm256_add_pd (a, b);
-    data[1] = _mm256_mul_pd (b, data[0]);
+    b = _mm_set1_pd ((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;
     if (ptr[0] != 7.3125)
@@ -109,9 +78,42 @@ CHECK_CXX_SOURCE_RUNS(
         return_value = 1;
     _mm_free (data);
     return return_value;
-  }
-  "
-  DEAL_II_HAVE_AVX)
+    }
+    "
+    DEAL_II_HAVE_SSE2)
+
+
+  CHECK_CXX_SOURCE_RUNS(
+    "
+    #include <immintrin.h>
+    #include <mm_malloc.h>
+    int main()
+    {
+      __m256d a, b;
+      const unsigned int vector_bytes = sizeof(__m256d);
+      const int n_vectors = vector_bytes/sizeof(double);
+      __m256d * data =
+        reinterpret_cast<__m256d*>(_mm_malloc (2*vector_bytes, vector_bytes));
+      double * ptr = reinterpret_cast<double*>(&a);
+      ptr[0] = (volatile double)(1.0);
+      for (int i=1; i<n_vectors; ++i)
+        ptr[i] = 0.0;
+      b = _mm256_set1_pd ((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;
+      if (ptr[0] != 7.3125)
+        return_value = 1;
+      for (int i=1; i<n_vectors; ++i)
+        if (ptr[i] != 5.0625)
+          return_value = 1;
+      _mm_free (data);
+      return return_value;
+    }
+    "
+    DEAL_II_HAVE_AVX)
+ENDIF()
 
 
 IF(DEAL_II_HAVE_SSE2)
@@ -123,4 +125,3 @@ IF(DEAL_II_HAVE_SSE2)
 ELSE()
   SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 0)
 ENDIF()
-
index ab3029b91f3abfee4a27284074330b5f15c87869..77785e96d6158c928826e576b024e98e0efdbe3d 100644 (file)
@@ -29,6 +29,7 @@
 #
 # Options regarding compilation and linking:
 #
+#     DEAL_II_ALLOW_PLATFORM_INTROSPECTION
 #     DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS
 #     CMAKE_BUILD_TYPE
 #     BUILD_SHARED_LIBS
@@ -106,6 +107,11 @@ ENDIF()
 #                                                                         #
 ###########################################################################
 
+SET(DEAL_II_ALLOW_PLATFORM_INTROSPECTION ON CACHE BOOL
+  "Allow platform introspection for CPU command set, SSE and AVX"
+  )
+MARK_AS_ADVANCED(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
+
 OPTION(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS
   "Configure sensible default CFLAGS and CXXFLAGS depending on platform, compiler and build target."
   ON
index 2ab59a91fb45cbd68ed3c795466c0d8653dea59d..c41b2400e61bc12ff477bbbc34eeb108638b9990 100644 (file)
@@ -34,6 +34,13 @@ ENDIF()
 #                      #
 ########################
 
+#
+# Enable all supported CPU instruction sets:
+#
+IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
+  ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-march=native")
+ENDIF()
+
 #
 # Set the pic flag.
 #
index 3e3c88b30d4b93142244963c2edd739fa2800ba9..89917ad974331985eceffae9aff0a27d7858226f 100644 (file)
     <p>
       The build can be further controlled by the following variables:
       <ul>
+        <li>
+          <code>DEAL_II_ALLOW_PLATFORM_INTROSPECTION</code>: If set
+          (default), <acronym>deal.II</acronym> will do platform
+          introspection for the given CPU.
+
        <li>
           <code>BUILD_SHARED_LIBS</code>: If set (default),
           <acronym>deal.II</acronym> will be linked as a shared library

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.