]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Only allow vectorization with clang 18320/head
authorDaniel Arndt <arndtd@ornl.gov>
Thu, 3 Apr 2025 21:09:52 +0000 (17:09 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Thu, 3 Apr 2025 21:09:52 +0000 (17:09 -0400)
.github/workflows/linux.yml
cmake/modules/FindDEAL_II_KOKKOS.cmake
include/deal.II/base/array_view.h

index c0106e09406b665e33410b8e3f7e6484822e0240..e16b35f409b429c7e1b0572e8322014e8e9d8180 100644 (file)
@@ -374,7 +374,6 @@ jobs:
               -D Kokkos_ENABLE_CUDA=ON \
               -D Kokkos_ENABLE_CUDA_LAMBDA=ON \
               -D Kokkos_ENABLE_CUDA_CONSTEXPR=ON \
-              -D Kokkos_ARCH_NATIVE=ON \
               -D Kokkos_ARCH_VOLTA70=ON \
               ..
         make install
index 8e9226a9065f36b552b2a98bffbbf2a5092bf938..67f80dec927d3393c541a975a19f5bb7ee668e60 100644 (file)
@@ -133,6 +133,15 @@ if(KOKKOS_FOUND)
   endif()
 
   if(Kokkos_ENABLE_CUDA)
+    if (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
+      # We need to disable SIMD vectorization for CUDA device code with nvcc.
+      # 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()
+
     # Require lambda support and expt-relaxed-constexpr for Cuda
     # so that we can use std::array and other interfaces with
     # __host__ constexpr functions in device code
index 0e187c3449634b43a19d4efe8366e72940b5150f..010e6b7a2b65721a5198a6f55a3b706c5b5a2a0a 100644 (file)
@@ -431,15 +431,7 @@ public:
    * Return a pointer to the underlying array serving as element storage.
    * In case the container is empty a nullptr is returned.
    */
-  template <typename Dummy = MemorySpaceType>
-  DEAL_II_HOST_DEVICE
-    std::enable_if_t<std::is_same_v<Dummy, dealii::MemorySpace::Default>,
-                     value_type *>
-    data() const noexcept;
-
-  template <typename Dummy = MemorySpaceType>
-  std::enable_if_t<std::is_same_v<Dummy, dealii::MemorySpace::Host>,
-                   value_type *>
+  DEAL_II_HOST_DEVICE value_type *
   data() const noexcept;
 
   /**
@@ -669,26 +661,9 @@ ArrayView<ElementType, MemorySpaceType>::operator!=(
 
 
 template <typename ElementType, typename MemorySpaceType>
-template <typename Dummy>
-inline DEAL_II_HOST_DEVICE std::enable_if_t<
-  std::is_same_v<Dummy, dealii::MemorySpace::Default>,
-  typename ArrayView<ElementType, MemorySpaceType>::value_type *>
-ArrayView<ElementType, MemorySpaceType>::data() const noexcept
-{
-  if (n_elements == 0)
-    return nullptr;
-  else
-    return starting_element;
-}
-
-
-
-template <typename ElementType, typename MemorySpaceType>
-template <typename Dummy>
-inline std::enable_if_t<
-  std::is_same_v<Dummy, dealii::MemorySpace::Host>,
-  typename ArrayView<ElementType, MemorySpaceType>::value_type *>
-ArrayView<ElementType, MemorySpaceType>::data() const noexcept
+inline DEAL_II_HOST_DEVICE
+  typename ArrayView<ElementType, MemorySpaceType>::value_type *
+  ArrayView<ElementType, MemorySpaceType>::data() const noexcept
 {
   if (n_elements == 0)
     return nullptr;

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.