]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Move SSE2 and AVX checks to check_for_system_features
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 18 Nov 2012 09:39:25 +0000 (09:39 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 18 Nov 2012 09:39:25 +0000 (09:39 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@27562 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/checks/check_for_compiler_features.cmake
deal.II/cmake/checks/check_for_system_features.cmake
deal.II/include/deal.II/base/config.h.in

index 32ef352c1d20c961b8fbe630c4f020bf6e23b089..18f148cca63e348f4f9eb783e7ab4eb7b9477f51 100644 (file)
@@ -167,119 +167,6 @@ CHECK_CXX_SOURCE_COMPILES(
   HAVE_LIBSTDCXX_DEMANGLER)
 
 
-#
-# Check whether the compiler allows for vectorization and that
-# vectorization actually works. 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_COMPILER_HAS_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_COMPILER_HAS_AVX)
-
-IF(DEAL_II_COMPILER_HAS_SSE2)
-  IF(DEAL_II_COMPILER_HAS_AVX)
-    SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 2)
-  ELSE()
-    SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 1)
-  ENDIF()
-ELSE()
-  SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 0)
-ENDIF()
-
-
-
-#
-# Check whether the compiler allows to use arithmetic operations
-# +-*/ on vectorized data types or whether we need to use
-# _mm_add_pd for addition and so on. +-*/ is preferred because
-# it allows the compiler to choose other optimizations like
-# fused multiply add, whereas _mm_add_pd explicitly enforces the
-# assembler command.
-#
-# - Matthias Maier, rewritten 2012
-#
-CHECK_CXX_SOURCE_COMPILES(
-  "
-  #include <emmintrin.h>
-  int main()
-  {
-    __m128d a, b;
-    a = _mm_set_sd (1.0);
-    b = _mm_set1_pd (2.1);
-    __m128d c = a + b;
-    __m128d d = b - c;
-    __m128d e = c * a + d;
-    __m128d f = e/a;
-    (void)f;
-  }
-  "
-  DEAL_II_COMPILER_USE_VECTOR_ARITHMETICS)
-
-
-
 #
 # Gcc and some other compilers have __PRETTY_FUNCTION__, showing
 # an unmangled version of the function we are presently in,
@@ -328,7 +215,6 @@ IF(NOT DEAL_II_COMPILER_HAS_ATTRIBUTE_PRETTY_FUNCTION)
 ENDIF()
 
 
-
 #
 # Check for minimal vector capacity
 #
@@ -353,6 +239,7 @@ IF(NOT DEAL_II_MIN_VECTOR_CAPACITY)
     "Could not determine DEAL_II_MIN_VECTOR_CAPACITY, "
     "source might not compile..."
     )
+  SET(DEAL_II_MIN_VECTOR_CAPACITY 1)
 ELSE()
   SET(DEAL_II_MIN_VECTOR_CAPACITY
     ${DEAL_II_MIN_VECTOR_CAPACITY_RETURN_VALUE}
@@ -385,13 +272,13 @@ IF(NOT DEAL_II_MIN_BOOL_VECTOR_CAPACITY)
     "Could not determine DEAL_II_MIN_VECTOR_CAPACITY, "
     "source might not compile..."
     )
+  SET(DEAL_II_MIN_VECTOR_CAPACITY 1)
 ELSE()
   SET(DEAL_II_MIN_BOOL_VECTOR_CAPACITY
     ${DEAL_II_MIN_BOOL_VECTOR_CAPACITY_RETURN_VALUE})
 ENDIF()
 
 
-
 #
 # Newer versions of gcc can pass a flag to the assembler to
 # compress debug sections. At the time of writing this test,
@@ -413,7 +300,6 @@ IF(NOT CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
 ENDIF()
 
 
-
 #
 # Gcc and some other compilers have an attribute of the form
 # __attribute__((deprecated)) that can be used to make the
index bbad2845cd0dd8208e910442222a8252d023fdb1..92e3c1bf0074e70a8375d7d06f845a9eaec872e1 100644 (file)
 ##
 #####
 
+
+###########################################################################
+#                                                                         #
+#                    Platform and CPU specific tests:                     #
+#                                                                         #
+###########################################################################
+
 #
-# Check for various system features:
+# Determine the Endianess of the platform:
 #
-
 INCLUDE(TestBigEndian)
 TEST_BIG_ENDIAN(DEAL_II_WORDS_BIGENDIAN)
 
 
 #
-# Check for various posix (and linux) specific header files:
+# 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);
+    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)
+
+IF(DEAL_II_HAVE_SSE2)
+  IF(DEAL_II_HAVE_AVX)
+    SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 2)
+  ELSE()
+    SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 1)
+  ENDIF()
+ELSE()
+  SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 0)
+ENDIF()
+
+#
+# Check whether the compiler allows to use arithmetic operations
+# +-*/ on vectorized data types or whether we need to use
+# _mm_add_pd for addition and so on. +-*/ is preferred because
+# it allows the compiler to choose other optimizations like
+# fused multiply add, whereas _mm_add_pd explicitly enforces the
+# assembler command.
+#
+# - Matthias Maier, rewritten 2012
 #
+CHECK_CXX_SOURCE_COMPILES(
+  "
+  #include <emmintrin.h>
+  int main()
+  {
+    __m128d a, b;
+    a = _mm_set_sd (1.0);
+    b = _mm_set1_pd (2.1);
+    __m128d c = a + b;
+    __m128d d = b - c;
+    __m128d e = c * a + d;
+    __m128d f = e/a;
+    (void)f;
+  }
+  "
+  DEAL_II_COMPILER_USE_VECTOR_ARITHMETICS)
+
+
+###########################################################################
+#                                                                         #
+#                     POSIX and Linux specific tests:                     #
+#                                                                         #
+###########################################################################
 
 CHECK_INCLUDE_FILE("sys/resource.h"  HAVE_SYS_RESOURCE_H)
 CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
@@ -36,13 +154,13 @@ CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
 # Windows/MinGW unistd.h is available but not all posix functions. So test
 # for each funtion as well.
 #
-
 CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
 CHECK_FUNCTION_EXISTS(gethostname HAVE_GETHOSTNAME)
 CHECK_FUNCTION_EXISTS(getpid HAVE_GETPID)
 CHECK_FUNCTION_EXISTS(rand_r HAVE_RAND_R)
 CHECK_FUNCTION_EXISTS(times HAVE_TIMES)
 
+
 #
 # Do we have the Bessel function jn?
 #
@@ -58,10 +176,16 @@ IF(NOT m_lib MATCHES "-NOTFOUND")
   ENDIF()
 ENDIF()
 
+
+###########################################################################
+#                                                                         #
+#                    Windos and CYGWIN specific setup:                    #
+#                                                                         #
+###########################################################################
+
 #
 # Export DEAL_II_MSVC if we are on a Windows platform.
 #
-
 IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
   SET(DEAL_II_MSVC TRUE)
 ENDIF()
@@ -80,3 +204,4 @@ IF( CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR
     )
   SET(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
 ENDIF()
+
index 6544f91b9ee7154d844ab402688445f164e4b905..2b6516607f3aed7509dcf09f79f0256c101b5330 100644 (file)
 #cmakedefine DEAL_II_USE_SLEPC
 
 
-/**************************************
- * Configured in configure_tbb.cmake: *
- **************************************/
+/********************************************
+ * Configured in configure_1_threads.cmake: *
+ ********************************************/
 
 /* Flag indicating whether the library shall be compiled for multithreaded
  * applications. If so, then it is set to one, otherwise to zero.
  */
 #cmakedefine HAVE_LIBSTDCXX_DEMANGLER
 
-/* Equal to 0 in the generic case, equal to 1 if CPU compiled for supports
- * SSE2, equal to 2 if CPU compiled for supports AVX
- */
-#define DEAL_II_COMPILER_VECTORIZATION_LEVEL @DEAL_II_COMPILER_VECTORIZATION_LEVEL@
-
-/* Defined if the compiler can use arithmetic operations on vectorized data
- * types
- */
-#cmakedefine DEAL_II_COMPILER_USE_VECTOR_ARITHMETICS
-
 /* If already available, do not define at all. Otherwise, define to
  * __func__ if that is available. In all other cases, indicate that no
  * information about the present function is available for this compiler.
 /* Defined if the system stores words with the most significant byte first */
 #cmakedefine DEAL_II_WORDS_BIGENDIAN
 
+/* Equal to 0 in the generic case, equal to 1 if CPU compiled for supports
+ * SSE2, equal to 2 if CPU compiled for supports AVX
+ */
+#define DEAL_II_COMPILER_VECTORIZATION_LEVEL @DEAL_II_COMPILER_VECTORIZATION_LEVEL@
+
+/* Defined if the compiler can use arithmetic operations on vectorized data
+ * types
+ */
+#cmakedefine DEAL_II_COMPILER_USE_VECTOR_ARITHMETICS
+
 
 /* Defined if you have the <sys/resource.h> header file */
 #cmakedefine HAVE_SYS_RESOURCE_H
 /* Defined if you have the <sys/types.h> header file. */
 #cmakedefine HAVE_SYS_TYPES_H
 
-
 /* Defined if you have the <unistd.h> header file. */
 #cmakedefine HAVE_UNISTD_H
 
 #cmakedefine DEAL_II_MSVC
 
 /* Disable a bunch of warnings for Microsoft Visual C++. */
-#ifdef DEAL_II_MSVC
-#  pragma warning( disable : 4244 ) /* implied downcasting from double to float */
-#  pragma warning( disable : 4267 ) /* implied downcasting from size_t to unsigned int */
-#  pragma warning( disable : 4996 ) /* unsafe functions, such as strcat and sprintf */
-#  pragma warning( disable : 4355 ) /* 'this' : used in base member initializer list */
-#  pragma warning( disable : 4661 ) /* no suitable definition provided for explicit template instantiation request */
-#  pragma warning( disable : 4800 ) /* forcing value to bool 'true' or 'false' (performance warning) */
-#  pragma warning( disable : 4146 ) /* unary minus operator applied to unsigned type, result still unsigned */
-#  pragma warning( disable : 4667 ) /* no function template defined that matches forced instantiation */
-#  pragma warning( disable : 4520 ) /* multiple default constructors specified */
-#  pragma warning( disable : 4700 ) /* uninitialized local variable */
-#  pragma warning( disable : 4789 ) /* destination of memory copy is too small */
-#  pragma warning( disable : 4808 ) /* case 'value' is not a valid value for switch condition of type 'bool */
-#endif // DEAL_II_MSVC
+//#ifdef DEAL_II_MSVC
+//#  pragma warning( disable : 4244 ) /* implied downcasting from double to float */
+//#  pragma warning( disable : 4267 ) /* implied downcasting from size_t to unsigned int */
+//#  pragma warning( disable : 4996 ) /* unsafe functions, such as strcat and sprintf */
+//#  pragma warning( disable : 4355 ) /* 'this' : used in base member initializer list */
+//#  pragma warning( disable : 4661 ) /* no suitable definition provided for explicit template instantiation request */
+//#  pragma warning( disable : 4800 ) /* forcing value to bool 'true' or 'false' (performance warning) */
+//#  pragma warning( disable : 4146 ) /* unary minus operator applied to unsigned type, result still unsigned */
+//#  pragma warning( disable : 4667 ) /* no function template defined that matches forced instantiation */
+//#  pragma warning( disable : 4520 ) /* multiple default constructors specified */
+//#  pragma warning( disable : 4700 ) /* uninitialized local variable */
+//#  pragma warning( disable : 4789 ) /* destination of memory copy is too small */
+//#  pragma warning( disable : 4808 ) /* case 'value' is not a valid value for switch condition of type 'bool */
+//#endif // DEAL_II_MSVC
 
 
 #include <deal.II/base/numbers.h>

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.