代码之家  ›  专栏  ›  技术社区  ›  Serge Rogatch

用clang作为CUDA编译器编译CUB库

  •  0
  • Serge Rogatch  · 技术社区  · 3 年前

    我设置 clang++-12 作为CMake中的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
    

    我试图用它编译一个大型代码库,但本质上它失败了 .cu 包含CUB并使用某些纹理的文件,但出现以下错误:

    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?

    环境为Ubuntu 20.04,带有LLVM/Crang 12和CUDA Toolkit 11.4.1。CUB与CUDA Toolkit捆绑在一起。

    0 回复  |  直到 3 年前
        1
  •  2
  •   ArtemB    3 年前

    如何解决这个问题?我应该将错误提交给NVIDIA还是LLVM?

    没有变通办法。目前,Clang不支持纹理/曲面查找,无论使用的CUDA版本如何。已经打开了一个bug: https://bugs.llvm.org/show_bug.cgi?id=26400

    纹理支持是可以实现的,但到目前为止还没有具体的需要来证明这一努力的合理性。