-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
alpaka-group/alpaka
#2256Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"cuda
Milestone
Description
Since Clang 17+, the default C++ standard of Clang for the CUDA mode is gnu++17 [1]. But this does not compile together with the libstdc++ because CUDA does not support float 128 bit.
$ touch empty.cu
$ clang++ -c empty.cu --cuda-gpu-arch=sm_52
In file included from <built-in>:1:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/llvm-18.1.1-ulsiaj6fzcc36manvhg3rtgjy4z7w56d/lib/clang/18/include/__clang_cuda_runtime_wrapper.h:41:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/llvm-18.1.1-ulsiaj6fzcc36manvhg3rtgjy4z7w56d/lib/clang/18/include/cuda_wrappers/cmath:27:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/cmath:47:
/opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/std_abs.h:103:7: error: __float128 is not supported on this target
103 | abs(__float128 __x)
| ^
/opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/std_abs.h:102:3: error: __float128 is not supported on this target
102 | __float128
| ^
/opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/std_abs.h:103:18: note: '__x' defined here
103 | abs(__float128 __x)
| ^
/opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/std_abs.h:103:18: note: '__x' defined here
/opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/std_abs.h:103:18: note: '__x' defined here
In file included from <built-in>:1:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/llvm-18.1.1-ulsiaj6fzcc36manvhg3rtgjy4z7w56d/lib/clang/18/include/__clang_cuda_runtime_wrapper.h:41:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/llvm-18.1.1-ulsiaj6fzcc36manvhg3rtgjy4z7w56d/lib/clang/18/include/cuda_wrappers/cmath:27:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/cmath:1935:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/specfun.h:45:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/stl_algobase.h:64:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/stl_pair.h:59:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/move.h:57:
/opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/type_traits:415:39: error: __float128 is not supported on this target
415 | struct __is_floating_point_helper<__float128>
| ^
In file included from <built-in>:1:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/llvm-18.1.1-ulsiaj6fzcc36manvhg3rtgjy4z7w56d/lib/clang/18/include/__clang_cuda_runtime_wrapper.h:41:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/llvm-18.1.1-ulsiaj6fzcc36manvhg3rtgjy4z7w56d/lib/clang/18/include/cuda_wrappers/cmath:27:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/cmath:1935:
In file included from /opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/specfun.h:45:
/opt/spack-modules/opt/spack/linux-ubuntu22.04-zen2/gcc-11.3.0/gcc-11.3.0-uhujaf27y72d4ic2yowfgz5slofuagt5/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../include/c++/11.3.0/bits/stl_algobase.h:1049:21: error: __float128 is not supported on this target
1049 | __size_to_integer(__float128 __n) { return (long long)__n; }
| ^
4 errors generated when compiling for sm_52.The bug is already fixed, if the libstdc++ is installed via apt on Debian (based) systems, because the maintainer provides a patch which makes the libstdc++ compatible with CUDA:
- https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1717257
- https://salsa.debian.org/toolchain-team/gcc/-/blob/32556e0c070cdd077a1289caa85d990080cd43c0/debian/patches/cuda-float128.diff
The major problem is, that CMake expected that the compiler works out of the box with it's default C++ standard, therefore the CMake CUDA compiler detection does not work with Clang 17+: https://gitlab.kitware.com/cmake/cmake/-/issues/25861
Is it possible to fix the bug in Clang/LLVM? Maybe by changing the default standard from gnu++17 to c++17.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"cuda