[Openmp-dev] nvlink reported undefined reference when building OpenMP offloading program

Shilei Tian via Openmp-dev openmp-dev at lists.llvm.org
Mon Nov 4 18:30:58 PST 2019


Hi,

I was trying to build an OpenMP offloading program. nvlink always reported following error:

nvlink error   : Undefined reference to '_Z25GetLogicalThreadIdInBlockb' in '/tmp/main-02fcf5.cubin'
nvlink error   : Undefined reference to '_Z13checkSPMDModeP5ident' in '/tmp/main-02fcf5.cubin'
nvlink error   : Undefined reference to '_Z14GetOmpThreadIdib' in '/tmp/main-02fcf5.cubin'
nvlink error   : Undefined reference to '_Z22setExecutionParameters13ExecutionMode11RuntimeMode' in '/tmp/main-02fcf5.cubin'
nvlink error   : Undefined reference to '_Z18GetThreadIdInBlockv' in '/tmp/main-02fcf5.cubin'
nvlink error   : Undefined reference to '_Z24GetNumberOfWorkersInTeamv' in '/tmp/main-02fcf5.cubin'
nvlink error   : Undefined reference to '_Z16IncParallelLevelbj' in '/tmp/main-02fcf5.cubin'
nvlink error   : Undefined reference to '_Z16DecParallelLevelbj' in '/tmp/main-02fcf5.cubin’

I was using clang which was built with trunk via following CMake command:

cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86;NVPTX" -DLLVM_ENABLE_PROJECTS="clang;openmp" -DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_75 -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=75 -DCMAKE_INSTALL_PREFIX=$HOME/.local ../llvm
make -j $(nproc)

OpenMP library was built via following CMake command:

cmake -DCMAKE_C_COMPILER=$HOME/.local/bin/clang -DCMAKE_CXX_COMPILER=$HOME/.local/bin/clang++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/.local -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=75 ..
make -j $(nproc)

And finally the compilation command is:

clang -fopenmp -fopenmp-targets=nvptx64 main.c

Did I miss something? The program is very simple:

 int main() {
   int i = 0;

 #pragma omp target nowait
   {
     i++;
     int k = 0;
     ++k;
   }

   int j = 0;
 #pragma omp target nowait
   {
     ++j;
   }

   return 0;
 }

I have CUDA 10.1 on the system.

Regards,
Shilei

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20191104/2b5d6210/attachment-0001.html>


More information about the Openmp-dev mailing list