]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix bug in build system when using Kokkos 12969/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 12 Nov 2021 21:25:37 +0000 (21:25 +0000)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Thu, 18 Nov 2021 21:09:14 +0000 (21:09 +0000)
cmake/configure/configure_2_trilinos.cmake
cmake/modules/FindKOKKOS.cmake

index fd415de1a16de8eebc5dceda92edd0ad3ce9e4d0..8a9a4a0796f5c3734be9766a8082633d68f5e25f 100644 (file)
@@ -177,6 +177,20 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
     ENDIF()
 
     IF(DEAL_II_TRILINOS_WITH_KOKKOS)
+      CHECK_SYMBOL_EXISTS(
+        "KOKKOS_ENABLE_CUDA"
+        "Kokkos_Macros.hpp"
+        DEAL_II_KOKKOS_CUDA_EXISTS
+        )
+      IF(DEAL_II_KOKKOS_CUDA_EXISTS)
+        # We need to disable SIMD vectorization for CUDA device code.
+        # Otherwise, nvcc compilers from version 9 on will emit an error message like:
+        # "[...] contains a vector, which is not supported in device code". We
+        # would like to set the variable in check_01_cpu_feature but at that point
+        # we don't know if CUDA support is enabled in Kokkos
+        SET(DEAL_II_VECTORIZATION_WIDTH_IN_BITS 0)
+      ENDIF()
+
       CHECK_SYMBOL_EXISTS(
         "KOKKOS_ENABLE_CUDA_LAMBDA"
         "Kokkos_Macros.hpp"
index 6c39f3c7d9f5e22a7df013b98eef64f000c223e0..7c992628f8df3267bd9b6cde5097d2f9b6b01576 100644 (file)
@@ -44,10 +44,18 @@ ELSE()
       STRING(REGEX REPLACE "\\$<\\$<LINK_LANGUAGE:CXX>:([^>]*)>" "\\1" KOKKOS_EXTRA_LD_FLAGS "${KOKKOS_EXTRA_LD_FLAGS_FULL}")
       GET_PROPERTY(KOKKOS_COMPILE_FLAGS_FULL TARGET Kokkos::kokkoscore PROPERTY INTERFACE_COMPILE_OPTIONS)
       STRING(REGEX REPLACE "\\$<\\$<COMPILE_LANGUAGE:CXX>:([^>]*)>" "\\1" KOKKOS_COMPILE_FLAGS "${KOKKOS_COMPILE_FLAGS_FULL}")
-      # In serial the flag is empty but ADD_FLAGS does not support adding an empty
-      # flag
-      IF(KOKKOS_COMPILE_FLAGS)
-        ADD_FLAGS(DEAL_II_CXX_FLAGS ${KOKKOS_COMPILE_FLAGS})
+
+      # We need to disable SIMD vectorization for CUDA device code.
+      # Otherwise, nvcc compilers from version 9 on will emit an error message like:
+      # "[...] contains a vector, which is not supported in device code". We
+      # would like to set the variable in check_01_cpu_feature but at that point
+      # we don't know if CUDA support is enabled in Kokkos
+      IF(Kokkos_ENABLE_CUDA)
+        SET(DEAL_II_VECTORIZATION_WIDTH_IN_BITS 0)
+        IF(DEAL_II_WITH_KOKKOS_BACKEND)
+          # Require lambda support to use Kokkos as a backend
+          KOKKOS_CHECK(OPTIONS CUDA_LAMBDA)
+        ENDIF()
       ENDIF()
 
       DEAL_II_FIND_LIBRARY(KOKKOS_CORE_LIBRARY
@@ -72,6 +80,7 @@ ELSE()
     LIBRARIES REQUIRED KOKKOS_CORE_LIBRARY KOKKOS_CONTAINERS_LIBRARY
     INCLUDE_DIRS REQUIRED KOKKOS_INSTALL_INCLUDE_DIR
     USER_INCLUDE_DIRS REQUIRED KOKKOS_INSTALL_INCLUDE_DIR
+    CXX_FLAGS OPTIONAL KOKKOS_COMPILE_FLAGS
     LINKER_FLAGS OPTIONAL KOKKOS_EXTRA_LD_FLAGS
     CLEAR KOKKOS_DIR KOKKOS_CORE_LIBRARY KOKKOS_CONTAINERS_LIBRARY
     )

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.