Hello everybody,
i am currently testing the NVPTX back-end and playing around with the IR it generates. Unfortunately i have come to an compilation error i cannot solve on my own. Maybe someone reading this knows what is causing the trouble and has a possible solution.
I am using Ubuntu 16.04, Cuda 7.5 and clang version 3.9.0
(GitHub - llvm-mirror/clang: Mirror kept for legacy. Moved to https://github.com/llvm/llvm-project 2869a420162946c5eecaa3742fc9c50a698d7a61) (GitHub - llvm-mirror/llvm: Project moved to: https://github.com/llvm/llvm-project 56547528a22d290a2e8b2c40810abb8117a8a6bc)
I have attached my source code which i try to compile with clang++ (it is just for testing so the code is not mean to do something useful) and here is the command i am using:
$ clang++ --cuda-gpu-arch=sm_20 loops.cu -o loops-clang -L/opt/cuda-7.5/lib64 -lcudart_static -ldl -lrt -pthread
ptxas /tmp/loops-36dc47.s, line 5; error : Unsupported .version 4.2; current version is '3.2'
ptxas fatal : Ptx assembly aborted due to errors
clang-3.9: error: ptxas command failed with exit code 255 (use -v to see invocation)
Compilation with nvcc works by the way.
I will be glad about any help and provide more information if needed.
Kind regards
Lorenz
loops.cu (3.39 KB)
Hello Lorenz,
I think I may have found what is causing the problem. I had the same problem and was able to solve it, see below.
Do you have more than one version of cuda installed? I think however clang invokes the compilation of the cuda parts of the code may be causing the problem. It may be falling back onto an older version of cuda.
In my case I had cuda-5.5 installed at /usr/local/cuda-5.5 with /usr/local/cuda linked to it. And I have cuda-7.5 installed elsewhere, that is the version in my $PATH and the one I was linking against during compilation. When I ran the compilation with the -v flag, I found that /usr/local/cuda/ptxas was being being invoked (cuda-5.5) instead of the version of ptxas (cuda-7.5) I had in my $PATH. That is the default location that cuda is normally installed to, clang may be defaulting to that. If you have root access, you might try installing cuda-7.5 to /usr/local/cuda. Doing that fixed it for me.
I think this might be a bug in how cuda code is compiled. clang should respect what version you keep in your $PATH.
Best Regards,
Pranav
Yes as pranav pointed this issue is with your installation. Point to correct ptxas binary and it should just compile because the error clearly indicates that the generated ptx has newer version but binary is old. Try ‘which ptxas’, it may help.
Sorry, after a few days. I was pretty busy so i have just read your answer.
Indeed i have multiple cuda installations. I will check if that fixes the problem. Thank you very much!