[Openmp-dev] Compiling OpenMP code with CUDA support using libc++

Alexey Bataev via Openmp-dev openmp-dev at lists.llvm.org
Thu Mar 5 03:44:35 PST 2020


Neither libc++, nor libstdc++ cannot be linked with nvlink. NVidia does not provide implementations for either libc++, or libstdc++. You must exclude the use of the standard c++ library from target regions.

Best regards,
Alexey Bataev

> 5 марта 2020 г., в 00:25, G Zhao via Openmp-dev <openmp-dev at lists.llvm.org> написал(а):
> 
> 
> Hi,
> 
> I just compiled LLVM and enable NVPTX by -DLLVM_TARGETS_TO_BUILD="X86;NVPTX". But when I compiled my code using the below command:
> 
> clang++ main.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -o a_gpu.exe
> 
> I got the below error:
> 
> /usr/lib64/gcc/x86_64-pc-linux-gnu/9.2.1/../../../../include/c++/9.2.1/bits/std_abs.h:75:3: error: declaration conflicts with target of using declaration already in scope
>   abs(float __x)
> 
> I think the reason is I am using GCC-9. I did a bit search and someone said using libc++ can address this. So I compiled libcxx and libcxxabi, and used the below command to compile my code again:
> 
> clang++ stdlib=libc++  main.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -o a_gpu.exe
> 
> I got different errors:
> 
> nvlink error   : Undefined reference to '_ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv' in '/tmp/main-42e0a6.cubin'
> nvlink error   : Undefined reference to 'abort' in '/tmp/main-42e0a6.cubin'
> 
> I think the reason here is nvlink don't know we should link libc++ with those cubin files together. But I don't know how to solve this.
> 
> Any one know a workaround to this?
> 
> Thanks!
> 
> 
> 
> 
> _______________________________________________
> Openmp-dev mailing list
> Openmp-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev


More information about the Openmp-dev mailing list