From: Martin Kronbichler Date: Mon, 13 May 2019 08:21:35 +0000 (+0200) Subject: Disable vectorization if DEAL_II_VECTORIZATION_LEVEL=0 X-Git-Tag: v9.1.0-rc1~25^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4fe1b806f6d086218cae85c58342815c7cef55a;p=dealii.git Disable vectorization if DEAL_II_VECTORIZATION_LEVEL=0 --- diff --git a/cmake/checks/check_01_cpu_features.cmake b/cmake/checks/check_01_cpu_features.cmake index c86145d6fe..72ddad565d 100644 --- a/cmake/checks/check_01_cpu_features.cmake +++ b/cmake/checks/check_01_cpu_features.cmake @@ -78,7 +78,7 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION) CHECK_CXX_SOURCE_RUNS( " - #include + #include int main() { __m128d a, b; @@ -116,7 +116,7 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION) #ifndef __AVX__ #error \"__AVX__ flag not set, no support for AVX\" #endif - #include + #include class VectorizedArray { public: @@ -175,7 +175,7 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION) #ifndef __AVX512F__ #error \"__AVX512F__ flag not set, no support for AVX512\" #endif - #include + #include int main() { __m512d a, b; diff --git a/include/deal.II/base/vectorization.h b/include/deal.II/base/vectorization.h index 39b374b23f..fb05f2432d 100644 --- a/include/deal.II/base/vectorization.h +++ b/include/deal.II/base/vectorization.h @@ -26,7 +26,7 @@ // Note: // The flag DEAL_II_COMPILER_VECTORIZATION_LEVEL is essentially constructed -// according to the following scheme +// according to the following scheme (on x86-based architectures) // #ifdef __AVX512F__ // #define DEAL_II_COMPILER_VECTORIZATION_LEVEL 3 // #elif defined (__AVX__) @@ -40,31 +40,36 @@ // 'check_01_cpu_features.cmake', ensures that these feature are not only // present in the compilation unit but also working properly. -#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__SSE2__) && \ - !defined(__AVX__) -# error \ - "Mismatch in vectorization capabilities: AVX was detected during configuration of deal.II and switched on, but it is apparently not available for the file you are trying to compile at the moment. Check compilation flags controlling the instruction set, such as -march=native." -#endif -#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__SSE2__) && \ - !defined(__AVX512F__) -# error \ - "Mismatch in vectorization capabilities: AVX-512F was detected during configuration of deal.II and switched on, but it is apparently not available for the file you are trying to compile at the moment. Check compilation flags controlling the instruction set, such as -march=native." -#endif +#if DEAL_II_COMPILER_VECTORIZATION_LEVEL > 0 + +# if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__SSE2__) && \ + !defined(__AVX__) +# error \ + "Mismatch in vectorization capabilities: AVX was detected during configuration of deal.II and switched on, but it is apparently not available for the file you are trying to compile at the moment. Check compilation flags controlling the instruction set, such as -march=native." +# endif +# if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__SSE2__) && \ + !defined(__AVX512F__) +# error \ + "Mismatch in vectorization capabilities: AVX-512F was detected during configuration of deal.II and switched on, but it is apparently not available for the file you are trying to compile at the moment. Check compilation flags controlling the instruction set, such as -march=native." +# endif -#if defined(_MSC_VER) -# include -#elif defined(__ALTIVEC__) -# include +# if defined(_MSC_VER) +# include +# elif defined(__ALTIVEC__) +# include // altivec.h defines vector, pixel, bool, but we do not use them, so undefine // them before they make trouble -# undef vector -# undef pixel -# undef bool -#else -# include +# undef vector +# undef pixel +# undef bool +# else +# include +# endif + #endif + DEAL_II_NAMESPACE_OPEN