alpaka-group / alpaka

Abstraction Library for Parallel Kernel Acceleration :llama:
https://alpaka.readthedocs.io
Mozilla Public License 2.0
337 stars 69 forks source link

alpaka does not work with Clang 17+ as CUDA compiler with vanila libstdc++ (gnu) #2254

Closed SimeonEhrig closed 2 months ago

SimeonEhrig commented 2 months ago

CMake configure fails if I use Clang 17+ as CUDA compiler together with the libstdc++ library (part of the GCC compiler collection).

$ cmake --preset gpu-cuda-clang 
Preset CMake variables:

  BUILD_TESTING="ON"
  CMAKE_CUDA_COMPILER="clang++"
  CMAKE_CXX_COMPILER="clang++"
  alpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE="ON"
  alpaka_ACC_GPU_CUDA_ENABLE="ON"
  alpaka_BUILD_EXAMPLES="ON"

-- The CXX compiler identification is Clang 17.0.4
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/llvm-17.0.4-fdedxkcbid2axx2csrbi3bsjobdhcdky/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Boost: /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/boost-1.75.0-z3egc22qy3an5l2p6ojcdg4cc6iqvvxe/lib/cmake/Boost-1.75.0/BoostConfig.cmake (found suitable version "1.75.0", minimum required is "1.74.0") found components: atomic 
-- boost::atomic_ref<T> found
-- C++20 math constants not found. Falling back to non-standard constants.
-- The CUDA compiler identification is unknown
CMake Error at /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-12.2.0/cmake-3.26.6-b3nwcvfcgtjtzufrlhbl2ost5ybbfk2n/share/cmake-3.26/Modules/CMakeDetermineCUDACompiler.cmake:603 (message):
  Failed to detect a default CUDA architecture.

  Compiler output:

Call Stack (most recent call first):
  cmake/alpakaCommon.cmake:376 (enable_language)
  CMakeLists.txt:95 (include)

-- Configuring incomplete, errors occurred!

The reason is because CUDA does not support float 128bit, which is part of the GNU extensions of the libstdc++ . Details are described in this issue: https://gitlab.kitware.com/cmake/cmake/-/issues/25861

Since Clang 17, the default C++ standard is gnu++17. Before it was c++14. https://reviews.llvm.org/D155539

The bug does not appears, if you use the libstdc++ installed via apt on Debian based operation systems, because they apply a patch to solve the problem:

Therefore the problem is not detected in our CI, because we use Ubuntu based container and install gcc via apt.

The problem can be reproduced on the HAL workstation, because it use a libstdc++ version installed via spack.