<div dir="ltr"><div>Thanks! I didn't notice this. The code is from a legacy project and I just checked all the target regions. It did use STL vectors. I just replaced all those vectors with arrays. Now it can successfully compile. But When I run it, there is another error:</div><div><br></div><div>Libomptarget fatal error 1: failure of target construct while offloading is mandatory</div><div><br></div><div>I tried it on a simple vector add example, and got the same error.</div><div><br></div><div>Below is the debug information with LIBOMPTARGET_DEBUG=1:</div><div><br></div><div>Libomptarget --> Loading RTLs...<br>Libomptarget --> Loading library '<a href="http://libomptarget.rtl.ppc64.so">libomptarget.rtl.ppc64.so</a>'...<br>Libomptarget --> Unable to load library '<a href="http://libomptarget.rtl.ppc64.so">libomptarget.rtl.ppc64.so</a>': <a href="http://libomptarget.rtl.ppc64.so">libomptarget.rtl.ppc64.so</a>: cannot open shared object file: No such file or directory!<br>Libomptarget --> Loading library '<a href="http://libomptarget.rtl.x86_64.so">libomptarget.rtl.x86_64.so</a>'...<br>Libomptarget --> Successfully loaded library '<a href="http://libomptarget.rtl.x86_64.so">libomptarget.rtl.x86_64.so</a>'!<br>Libomptarget --> Registering RTL <a href="http://libomptarget.rtl.x86_64.so">libomptarget.rtl.x86_64.so</a> supporting 4 devices!<br>Libomptarget --> Loading library '<a href="http://libomptarget.rtl.cuda.so">libomptarget.rtl.cuda.so</a>'...<br>Target CUDA RTL --> Start initializing CUDA<br>Libomptarget --> Successfully loaded library '<a href="http://libomptarget.rtl.cuda.so">libomptarget.rtl.cuda.so</a>'!<br>Libomptarget --> Registering RTL <a href="http://libomptarget.rtl.cuda.so">libomptarget.rtl.cuda.so</a> supporting 1 devices!<br>Libomptarget --> Loading library '<a href="http://libomptarget.rtl.aarch64.so">libomptarget.rtl.aarch64.so</a>'...<br>Libomptarget --> Unable to load library '<a href="http://libomptarget.rtl.aarch64.so">libomptarget.rtl.aarch64.so</a>': <a href="http://libomptarget.rtl.aarch64.so">libomptarget.rtl.aarch64.so</a>: cannot open shared object file: No such file or directory!<br>Libomptarget --> RTLs loaded!<br>Libomptarget --> Image 0x000000000041ad20 is NOT compatible with RTL <a href="http://libomptarget.rtl.x86_64.so">libomptarget.rtl.x86_64.so</a>!<br>Libomptarget --> Image 0x000000000041ad20 is compatible with RTL <a href="http://libomptarget.rtl.cuda.so">libomptarget.rtl.cuda.so</a>!<br>Libomptarget --> RTL 0x00000000015b3c40 has index 0!<br>Libomptarget --> Registering image 0x000000000041ad20 with RTL <a href="http://libomptarget.rtl.cuda.so">libomptarget.rtl.cuda.so</a>!<br>Libomptarget --> Done registering entries!<br>Libomptarget --> Call to omp_get_num_devices returning 1<br>Libomptarget --> Default TARGET OFFLOAD policy is now mandatory (devices were found)<br>Libomptarget --> Checking whether device 0 is ready.<br>Libomptarget --> Is the device 0 (local ID 0) initialized? 0<br>Target CUDA RTL --> Init requires flags to 1<br>Target CUDA RTL --> Getting device 0<br>Target CUDA RTL --> Max CUDA blocks per grid 2147483647 exceeds the hard team limit 65536, capping at the hard limit<br>Target CUDA RTL --> Using 1024 CUDA threads per block<br>Target CUDA RTL --> Max number of CUDA blocks 65536, threads 1024 & warp size 32<br>Target CUDA RTL --> Default number of teams set according to library's default 128<br>Target CUDA RTL --> Default number of threads set according to library's default 128<br>Libomptarget --> Device 0 is ready to use.<br>Target CUDA RTL --> Load data from image 0x000000000041ad20<br>Target CUDA RTL --> Error when loading CUDA module<br>Target CUDA RTL --> CUDA error is: device kernel image is invalid<br>Libomptarget --> Unable to generate entries table for device id 0.<br>Libomptarget --> Failed to init globals on device 0<br>Libomptarget --> Failed to get device 0 ready<br>Libomptarget fatal error 1: failure of target construct while offloading is mandatory<br>Libomptarget --> Unloading target library!<br>Libomptarget --> Image 0x000000000041ad20 is compatible with RTL 0x00000000015b3c40!<br>Libomptarget --> Unregistered image 0x000000000041ad20 from RTL 0x00000000015b3c40!<br>Libomptarget --> Done unregistering images!<br>Libomptarget --> Removing translation table for descriptor 0x0000000000440810<br>Libomptarget --> Done unregistering library!<br>Libomptarget --> Deinit target library!<br></div><div><br></div><div>Any hints about this? <br></div><div><br></div><div>Regards,</div><div>Gang Zhao<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Alexey Bataev <<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>> 于2020年3月5日周四 上午5:44写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">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.<br>
<br>
Best regards,<br>
Alexey Bataev<br>
<br>
> 5 марта 2020 г., в 00:25, G Zhao via Openmp-dev <<a href="mailto:openmp-dev@lists.llvm.org" target="_blank">openmp-dev@lists.llvm.org</a>> написал(а):<br>
> <br>
> <br>
> Hi,<br>
> <br>
> I just compiled LLVM and enable NVPTX by -DLLVM_TARGETS_TO_BUILD="X86;NVPTX". But when I compiled my code using the below command:<br>
> <br>
> clang++ main.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -o a_gpu.exe<br>
> <br>
> I got the below error:<br>
> <br>
> /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<br>
>   abs(float __x)<br>
> <br>
> 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:<br>
> <br>
> clang++ stdlib=libc++  main.cpp -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -o a_gpu.exe<br>
> <br>
> I got different errors:<br>
> <br>
> nvlink error   : Undefined reference to '_ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv' in '/tmp/main-42e0a6.cubin'<br>
> nvlink error   : Undefined reference to 'abort' in '/tmp/main-42e0a6.cubin'<br>
> <br>
> 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.<br>
> <br>
> Any one know a workaround to this?<br>
> <br>
> Thanks!<br>
> <br>
> <br>
> <br>
> <br>
> _______________________________________________<br>
> Openmp-dev mailing list<br>
> <a href="mailto:Openmp-dev@lists.llvm.org" target="_blank">Openmp-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev</a><br>
</blockquote></div></div>