From 6bd29fe75ac12cdc58aedb617b0931fb86441148 Mon Sep 17 00:00:00 2001 From: maier Date: Sun, 18 Nov 2012 09:39:25 +0000 Subject: [PATCH] Move SSE2 and AVX checks to check_for_system_features git-svn-id: https://svn.dealii.org/branches/branch_cmake@27562 0785d39b-7218-0410-832d-ea1e28bc413d --- .../checks/check_for_compiler_features.cmake | 118 +-------------- .../checks/check_for_system_features.cmake | 135 +++++++++++++++++- deal.II/include/deal.II/base/config.h.in | 55 ++++--- 3 files changed, 159 insertions(+), 149 deletions(-) diff --git a/deal.II/cmake/checks/check_for_compiler_features.cmake b/deal.II/cmake/checks/check_for_compiler_features.cmake index 32ef352c1d..18f148cca6 100644 --- a/deal.II/cmake/checks/check_for_compiler_features.cmake +++ b/deal.II/cmake/checks/check_for_compiler_features.cmake @@ -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 - #include - 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(&a); - ptr[0] = (volatile double)(1.0); - for (int i=1; i(&data[1]); - unsigned int return_value = 0; - if (ptr[0] != 7.3125) - return_value = 1; - for (int i=1; i - #include - 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(&a); - ptr[0] = (volatile double)(1.0); - for (int i=1; i(&data[1]); - unsigned int return_value = 0; - if (ptr[0] != 7.3125) - return_value = 1; - for (int i=1; i - 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 diff --git a/deal.II/cmake/checks/check_for_system_features.cmake b/deal.II/cmake/checks/check_for_system_features.cmake index bbad2845cd..92e3c1bf00 100644 --- a/deal.II/cmake/checks/check_for_system_features.cmake +++ b/deal.II/cmake/checks/check_for_system_features.cmake @@ -12,17 +12,135 @@ ## ##### + +########################################################################### +# # +# 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 + #include + 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(&a); + ptr[0] = (volatile double)(1.0); + for (int i=1; i(&data[1]); + unsigned int return_value = 0; + if (ptr[0] != 7.3125) + return_value = 1; + for (int i=1; i + #include + 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(&a); + ptr[0] = (volatile double)(1.0); + for (int i=1; i(&data[1]); + unsigned int return_value = 0; + if (ptr[0] != 7.3125) + return_value = 1; + for (int i=1; i + 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() + diff --git a/deal.II/include/deal.II/base/config.h.in b/deal.II/include/deal.II/base/config.h.in index 6544f91b9e..2b6516607f 100644 --- a/deal.II/include/deal.II/base/config.h.in +++ b/deal.II/include/deal.II/base/config.h.in @@ -280,9 +280,9 @@ #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. @@ -358,16 +358,6 @@ */ #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. @@ -464,6 +454,16 @@ /* 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 header file */ #cmakedefine HAVE_SYS_RESOURCE_H @@ -477,7 +477,6 @@ /* Defined if you have the header file. */ #cmakedefine HAVE_SYS_TYPES_H - /* Defined if you have the header file. */ #cmakedefine HAVE_UNISTD_H @@ -501,20 +500,20 @@ #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 -- 2.39.5