From: Matthias Maier Date: Sun, 3 Feb 2019 18:06:59 +0000 (-0600) Subject: CMake: Bugfix: Guard DEAL_II_HAVE_OPENMP_SIMD test X-Git-Tag: v9.1.0-rc1~375^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f9ec68aaf5b9b3d750b90b5817a3cd689bba555;p=dealii.git CMake: Bugfix: Guard DEAL_II_HAVE_OPENMP_SIMD test We also have to guard the DEAL_II_HAVE_OPENMP_SIMD test with DEAL_II_ALLOW_PLATFORM_INTROSPECTION. If the latter is set to false our cmake configuration does not attempt to determine any specifics of the unerlying CPU or architecture (and instead relies on the user specifying everything by hand). This is necessary for scenarios where deal.II gets compiled on a different machine than the one it will be run on eventually. In reference to #7663. --- diff --git a/cmake/checks/check_01_cpu_features.cmake b/cmake/checks/check_01_cpu_features.cmake index f69c1ee268..c86145d6fe 100644 --- a/cmake/checks/check_01_cpu_features.cmake +++ b/cmake/checks/check_01_cpu_features.cmake @@ -28,8 +28,8 @@ # DEAL_II_HAVE_AVX *) # DEAL_II_HAVE_AVX512 *) # DEAL_II_HAVE_ALTIVEC *) -# DEAL_II_COMPILER_VECTORIZATION_LEVEL # DEAL_II_HAVE_OPENMP_SIMD *) +# DEAL_II_COMPILER_VECTORIZATION_LEVEL # DEAL_II_OPENMP_SIMD_PRAGMA # # *) @@ -245,7 +245,36 @@ IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION) } " DEAL_II_HAVE_ALTIVEC) -ENDIF() + + # + # OpenMP 4.0 can be used for vectorization. Only the vectorization + # instructions are allowed, the threading must be done through TBB. + # + + # + # Choosing the right compiler flag is a bit of a mess: + # + IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") + IF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "15" ) + SET(_keyword "qopenmp") + ELSEIF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "14" ) + SET(_keyword "openmp") + ENDIF() + ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(_keyword "openmp") + ELSE() + SET(_keyword "fopenmp") + ENDIF() + + CHECK_CXX_COMPILER_FLAG("-${_keyword}-simd" DEAL_II_HAVE_OPENMP_SIMD) + +ENDIF() # IF DEAL_II_ALLOW_PLATFORM_INTROSPECTION + + +# +# Choose DEAL_II_COMPILER_VECTORIZATION level depending on AVX support +# (that was autodetected or manually specified). +# IF(DEAL_II_HAVE_AVX512) SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 3) @@ -263,26 +292,9 @@ ENDIF() # -# OpenMP 4.0 can be used for vectorization. Only the vectorization -# instructions are allowed, the threading must be done through TBB. -# - +# If we have OpenMP SIMD support (i.e. DEAL_II_HAVE_OPENMP_SIMD is true) +# populate DEAL_II_OPENMP_SIMD_PRAGMA. # -# Choosing the right compiler flag is a bit of a mess: -# -IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - IF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "15" ) - SET(_keyword "qopenmp") - ELSEIF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "14" ) - SET(_keyword "openmp") - ENDIF() -ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - SET(_keyword "openmp") -ELSE() - SET(_keyword "fopenmp") -ENDIF() - -CHECK_CXX_COMPILER_FLAG("-${_keyword}-simd" DEAL_II_HAVE_OPENMP_SIMD) SET(DEAL_II_OPENMP_SIMD_PRAGMA " ") IF(DEAL_II_HAVE_OPENMP_SIMD)