Hi,
I have compiled the latest LLVM using source code from the Github main branch, but the clang++ compiler reports a nvlink error, “could not open input file 'OMPStream-766936.cubin”, when compiling the OpenMP version BabelStream benchmark.
I found out the nvlink error arises when CMake executes the following three commands:
“/home/lechen/Repository/OpenMP/llvm-install/main/bin/clang-offload-bundler” -type=o -targets=host-x86_64-unknown-linux-gnu,openmp-nvptx64-nvidia-cuda-sm_70 -inputs=CMakeFiles/omp-stream.dir/src/omp/OMPStream.cpp.o -outputs=/home/lechen/.tmux_tmp/OMPStream-feb037.o,/home/lechen/.tmux_tmp/OMPStream-766936.cubin -unbundle -allow-missing-bundles
“/home/lechen/Repository/OpenMP/llvm-install/main/bin/clang-offload-bundler” -type=o -targets=host-x86_64-unknown-linux-gnu,openmp-nvptx64-nvidia-cuda-sm_70 -inputs=CMakeFiles/omp-stream.dir/src/main.cpp.o -outputs=/home/lechen/.tmux_tmp/main-e9854a.o,/home/lechen/.tmux_tmp/main-81e658.cubin -unbundle -allow-missing-bundles
“/rwthfs/rz/cluster/home/lechen/Repository/OpenMP/llvm-install/main/bin/clang-nvlink-wrapper” -o /home/lechen/.tmux_tmp/OMPStream-d73a78.out -v -arch sm_70 -L/home/lechen/Repository/OpenMP/llvm-install/main/lib -L/usr/local_rwth/sw/cuda/11.2.0/nvvm/libdevice -L/rwthfs/rz/cluster/home/lechen/Repository/OpenMP/llvm-install/main/lib /home/lechen/.tmux_tmp/OMPStream-766936.cubin /home/lechen/.tmux_tmp/main-81e658.cubin --nvlink-path=/rwthfs/rz/SW/cuda/11.2.0/RHEL_7/cuda/bin/nvlink
nvlink fatal : Could not open input file '/home/lechen/.tmux_tmp/OMPStream-766936.cubin’
It seems that the cubin file OMPStream-766936.cubin is not correctly generated. I also tried to manually execute the three commands. This time OMPStream-766936.cubin is generated but actually an empty file, and another generated cubin file, main-81e658.cubin, is also empty.
I was wondering whether this is due to the incorrect CMake setting for the LLVM. I have listed the details of this error in the following paragraphs. If anyone knows the root cause of this issue, please let me know. Thanks.
CMake setting for LLVM:
cmake -GNinja -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=$INSTALLDIR
-DLLVM_ENABLE_LIBCXX=ON
-DLLVM_LIT_ARGS="-sv -j12"
-DPAPI_PREFIX=${PAPI_ROOT}
-DCLANG_DEFAULT_CXX_STDLIB=libc++
-DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_70
-DLIBOMPTARGET_ENABLE_DEBUG=on
-DLIBOMPTARGET_NVPTX_ENABLE_BCLIB=true
-DLIBOMPTARGET_NVPTX_AUTODETECT_COMPUTE_CAPABILITY=OFF
-DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=“70”
-DLLVM_ENABLE_PROJECTS=“clang;compiler-rt;libcxxabi;libcxx;libunwind;flang;clang-tools-extra;openmp”
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
-DLLVM_INSTALL_UTILS=ON
$LLVM_SOURCE
CMake setting for BabelStream:
cmake -DCMAKE_CXX_COMPILER=clang++
-DMODEL=“omp”
-DOFFLOAD=NVIDIA:sm_70
$BABELSTREAM_SOURCE
System and LLVM details:
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/lechen/Repository/OpenMP/llvm-install/main/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /rwthfs/rz/SW/cuda/11.2.0/RHEL_7/cuda, version 11.2
Warns and errors reported by clang++:
warning:
linking module ‘/home/lechen/Repository/OpenMP/llvm-install/main/lib/libomptarget-new-nvptx-sm_70.bc’: Linking two modules of different target triples: ‘/home/lechen/Repository/OpenMP/llvm-install/main/lib/libomptarget-new-nvptx-sm_70.bc’ is ‘nvptx64’ whereas ‘/home/lechen/Repository/BabelStream/src/main.cpp’ is ‘nvptx64-nvidia-cuda’
nvlink error:
nvlink fatal : Could not open input file ‘/home/lechen/.tmux_tmp/OMPStream-766936.cubin’’
home/lechen/Repository/OpenMP/llvm-install/main/bin/clang-nvlink-wrapper: error: ‘nvlink’ failed
clang-14: error: nvlink command failed with exit code 1 (use -v to see invocation)