]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Bugfix: Guard DEAL_II_HAVE_OPENMP_SIMD test 7681/head
authorMatthias Maier <tamiko@43-1.org>
Sun, 3 Feb 2019 18:06:59 +0000 (12:06 -0600)
committerMatthias Maier <tamiko@43-1.org>
Sun, 3 Feb 2019 18:14:43 +0000 (12:14 -0600)
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.

cmake/checks/check_01_cpu_features.cmake

index f69c1ee268f5df9017994c49f2f86569cd4ea82c..c86145d6feff75bd171197c60a6f972b2589daa1 100644 (file)
@@ -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)

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.