LLVM/Clang을 사용하여 내 Nvidia GPU에서 OpenMP4 + 코드를 실행하고 싶습니다. 나는 llvm/clang/omp 라이브러리를 여기에있는 지시에 따라 트렁크에서 다운로드하고 컴파일했다 : https://clang.llvm.org/get_started.html 그리고 여기 : https://openmp.llvm.org/. 나는 컴파일러 -RT와 libcxx를 만들지 않았지만, 그것이 어떤 차이를 만들지는 않을 것이라고 생각한다.Clang 6 (트렁크)에서 nvptx 대상을 사용하여 OpenMP`target` 지시문을 컴파일 할 때 링커 오류가 발생했습니다.
int main(void)
{
#pragma omp target
{
}
return 0;
}
그리고 내가 이것으로 컴파일 : /home/user/opt/llvm/bin/clang++ -v main.cpp -fopenmp -lomptarget -fopenmp-targets=nvptx64-nvidia-cuda --cuda-path=/home/user/opt/pgi/linux86-64/2017/cuda/8.0
경우
cmake -G "Unix Makefiles" ../llvm -DCMAKE_BUILD_TYPE=Release -DOPENMP_ENABLE_LIBOMPTARGET=ON
내가 하나의 OpenMP를 target
지시어로 아주 기본적인 프로그램을 작성 :
내 CMake 명령이 있었다 당신은 물어 : 네, 컴파일러에 대한 내 경로를 설정하지 않은하지만 내 LD_LIBRARY_PATH
포인트는 libomptarget
어디에 있는지 확인했다. 여기
그리고
는 (마지막 ~ 10 개 라인이 오류를 보여주는) 내가 위의 명령을 실행 한 후 얻을 출력/오류입니다 :<If this is too much information, just go to the last 10 lines to see the error>
clang version 6.0.0 (trunk 312875)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/user/opt/llvm/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/7.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.2.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /home/user/opt/pgi/linux86-64/2017/cuda/8.0, version 7.0
"/home/user/opt/llvm/bin/clang-6.0" -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /home/user/opt/llvm/lib/clang/6.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward -internal-isystem /usr/local/include -internal-isystem /home/user/opt/llvm/lib/clang/6.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /usr/local/include -internal-isystem /home/user/opt/llvm/lib/clang/6.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 190 -fopenmp -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-be2d35.bc -x c++ main.cpp -fopenmp-targets=nvptx64-nvidia-cuda
clang -cc1 version 6.0.0 based upon LLVM 6.0.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
ignoring nonexistent directory "/include"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/home/user/opt/llvm/lib/clang/6.0.0/include"
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward
/usr/local/include
/home/user/opt/llvm/lib/clang/6.0.0/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
"/home/user/opt/llvm/bin/clang-6.0" -cc1 -triple nvptx64-nvidia-cuda -aux-triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as -fuse-init-array -mlink-cuda-bitcode /home/user/opt/pgi/linux86-64/2017/cuda/8.0/nvvm/libdevice/libdevice.compute_20.10.bc -target-feature +ptx42 -target-cpu sm_20 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /home/user/opt/llvm/lib/clang/6.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward -internal-isystem /usr/local/include -internal-isystem /home/user/opt/llvm/lib/clang/6.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /usr/local/include -internal-isystem /home/user/opt/llvm/lib/clang/6.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 190 -fopenmp -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-7ffbd7.s -x c++ main.cpp -fopenmp-is-device -fopenmp-host-ir-file-path /tmp/main-be2d35.bc
clang -cc1 version 6.0.0 based upon LLVM 6.0.0svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
ignoring nonexistent directory "/include"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0"
ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/home/user/opt/llvm/lib/clang/6.0.0/include"
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward
/usr/local/include
/home/user/opt/llvm/lib/clang/6.0.0/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
"/home/user/opt/pgi/linux86-64/2017/cuda/8.0/bin/ptxas" -m64 -O0 -v --gpu-name sm_20 --output-file /tmp/main-64fc86.cubin /tmp/main-ca9e59.s -c
ptxas info : 1 bytes gmem, 8 bytes cmem[14]
ptxas info : Compiling entry function '__omp_offloading_803_18004c0_main_l3' for 'sm_20'
ptxas info : Function properties for __omp_offloading_803_18004c0_main_l3
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Used 5 registers, 32 bytes cmem[0]
ptxas info : Function properties for __omp_offloading_803_18004c0_main_l3_worker
24 bytes stack frame, 8 bytes spill stores, 8 bytes spill loads
"/home/user/opt/pgi/linux86-64/2017/cuda/8.0/bin/nvlink" -o /tmp/main-f247e3.out -v -arch sm_20 -L/home/user/opt/llvm/lib -lomptarget-nvptx main-64fc86.cubin
nvlink error : Undefined reference to '__kmpc_kernel_init' in 'main-64fc86.cubin'
nvlink error : Undefined reference to '__kmpc_kernel_deinit' in 'main-64fc86.cubin'
nvlink error : Undefined reference to '__kmpc_kernel_parallel' in 'main-64fc86.cubin'
nvlink error : Undefined reference to '__kmpc_kernel_end_parallel' in 'main-64fc86.cubin'
nvlink info : 1 bytes gmem, 8 bytes cmem[14]
nvlink info : Function properties for '__omp_offloading_803_18004c0_main_l3':
nvlink info : used 18 registers, 24 stack, 0 bytes smem, 32 bytes cmem[0], 0 bytes lmem
clang-6.0: error: fatbinary command failed with exit code 255 (use -v to see invocation)
이 __kmpc*
기호가하도록되어 라이브러리 어떤 생각?
nm libomptarget.so | grep __kmpc_kernel_parallel
및
nm libomptarget.rtl.cuda.so | grep __kmpc_kernel_parallel
하지만 두 명령은 아무것도 돌려주지 않는 : 나는 실행하려고.
마지막으로, 컴파일 플래그에서 -fopenmp-targets=nvptx64-nvidia-cuda
을 제거하면 링커 오류가 발생하지 않습니다. 그러나 물론 CUDA 코드가 생성되지는 않습니다.
무슨 일이 일어나고 있는지,이 기호가 어디에 위치해야하는지, 왜 그들이 없는지에 대한 의견은 환영 할만한 것입니다.
https://parallel-computing.pro/index.php/forum/general-ko/17-blog-post-openmp-4-0- on-nvidia-cuda-gpus – talonmies
@talonmies 감사합니다. 그러나 그것은 나를 혼란스럽게합니다. 실제로 libomptarget의 오래된 저장소는 libomptarget-nvptx라는 라이브러리를 생성합니다. 실제로, 제 경우 nvlinker는 -lomptarget-nvptx를 추가합니다. 그러나 libomptarget은 이제 llvm의 일부이며, 나에게 보낸 링크에 인용 된 github 저장소에서 libomptarget을 다운로드 할 필요가 없습니다 (맞습니까?). 이상하게도,이 새로운 libomptarget 버전은 libomptarget-nvptx 라이브러리를 생성하지 않습니다 (심지어 모든 CMakeLists.txt 파일을 덮어 버렸습니다). 내가 뭔가 잘못 됐어? – AstrOne
끝 부분을 읽으십시오 - 저는 sm_20 빌드 타겟이 문제라고 추측 할 것입니다. – talonmies