【发布时间】:2021-11-02 22:16:34
【问题描述】:
我在 CMake 中将clang++-12 设置为 CUDA 编译器如下:
cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CUDA_ARCHITECTURES="75" \
-DCMAKE_CUDA_COMPILER=clang++-12 \
-DCMAKE_CXX_COMPILER=clang++-12 -DCMAKE_C_COMPILER=clang-12
我尝试用它编译一个大型代码库,但基本上它对于包含 CUB 并使用一些纹理的 .cu 文件失败,并出现以下错误:
clang: warning: Unknown CUDA version. cuda.h: CUDA_VERSION=11040. Assuming the latest supported version 10.1 [-Wunknown-cuda-version]
clang: warning: argument unused during compilation: '-G -Werror' [-Wunused-command-line-argument]
In file included from /scratch/src/libgpu/src/skelapp/skel_dummy.cu:2:
In file included from /scratch/src/libgpu/include/gg.cuh:5:
In file included from /scratch/src/libgpu/include/AppendOnlyList.cuh:6:
In file included from /usr/local/cuda-11.4/include/cub/cub.cuh:61:
In file included from /usr/local/cuda-11.4/include/cub/device/device_spmv.cuh:41:
In file included from /usr/local/cuda-11.4/include/cub/device/dispatch/dispatch_spmv_orig.cuh:42:
In file included from /usr/local/cuda-11.4/include/cub/device/dispatch/../../agent/agent_spmv_orig.cuh:47:
/usr/local/cuda-11.4/include/cub/device/dispatch/../../agent/../iterator/tex_ref_input_iterator.cuh:133:39: error: reference to __host__ variable 'ref' in __device__ function
words[i] = tex1Dfetch(ref, (tex_offset * TEXTURE_MULTIPLE) + i);
^
In file included from <built-in>:1:
In file included from /usr/lib/llvm-12/lib/clang/12.0.1/include/__clang_cuda_runtime_wrapper.h:333:
/usr/local/cuda-11.4/include/texture_indirect_functions.h:111:4: error: use of undeclared identifier '__nv_tex_surf_handler'
__nv_tex_surf_handler("__itex1Dfetch", ptr, obj, x);
^
/usr/local/cuda-11.4/include/texture_indirect_functions.h:120:3: note: in instantiation of function template specialization 'tex1Dfetch<int>' requested here
tex1Dfetch(&ret, texObject, x);
^
/scratch/src/libgpu/include/worklist.cuh:393:12: note: in instantiation of function template specialization 'tex1Dfetch<int>' requested here
item = tex1Dfetch<int>(tx, id);
^
2 errors generated when compiling for sm_75.
make[2]: *** [libgpu/CMakeFiles/some_gpu.dir/build.make:146: libgpu/CMakeFiles/some_gpu.dir/src/skelapp/skel_dummy.cu.o] Error 1
如何解决这个问题?我应该向 NVIDIA 或 LLVM 提交错误吗?
环境是带有 LLVM/Clang 12 和 CUDA Toolkit 11.4.1 的 Ubuntu 20.04。 CUB 与 CUDA Toolkit 捆绑在一起。
【问题讨论】:
-
使用受支持的 CUDA 版本,Clang 仅支持 CUDA 9 可能还有 CUDA 10,这取决于您的 clang 构建的新程度
-
clang: warning: Unknown CUDA version. cuda.h: CUDA_VERSION=11040. Assuming the latest supported version 10.1 [-Wunknown-cuda-version]向 NVIDIA 提交与此相关的错误是没有意义的。 NVIDIA 不开发或维护 Clang。一种可能的解决方法是改用nvcc。 -
这是一个标准纹理参考,自第一个 CUDA 测试版发布以来完全合法
-
Clang 不支持纹理/表面查找,无论使用何种 CUDA 版本。它可以实施,但到目前为止还没有特别需要证明这项努力的合理性。
-
仅供参考,clang 可能最终会很快支持纹理查找。 reviews.llvm.org/D110089