$ clang++ axpy.cu -o axpy-clang -I/usr/local/cuda/samples/common/inc
In file included from axpy.cu:1:
In file included from /usr/local/cuda/samples/common/inc/helper_cuda.h:24:
/usr/local/cuda/samples/common/inc/helper_string.h:18:10: fatal error: ‘fstream’ file not found #include
^
1 error generated.
axpy.cu:5:1: error: unknown type name ‘global’ global void axpy(float a, float* x, float* y) {
^
axpy.cu:5:12: error: expected unqualified-id global void axpy(float a, float* x, float* y) {
^
axpy.cu:19:19: error: use of undeclared identifier ‘cudaMalloc’
checkCudaErrors(cudaMalloc(&device_x, kDataLen * sizeof(float)));
^
axpy.cu:20:19: error: use of undeclared identifier ‘cudaMalloc’
checkCudaErrors(cudaMalloc(&device_y, kDataLen * sizeof(float)));
^
axpy.cu:22:30: error: use of undeclared identifier ‘cudaMemcpyHostToDevice’
cudaMemcpyHostToDevice));
^
axpy.cu:25:3: error: use of undeclared identifier ‘axpy’
axpy<<<1, kDataLen>>>(a, device_x, device_y);
^
axpy.cu:28:19: error: use of undeclared identifier ‘cudaDeviceSynchronize’
checkCudaErrors(cudaDeviceSynchronize());
^
axpy.cu:30:30: error: use of undeclared identifier ‘cudaMemcpyDeviceToHost’
cudaMemcpyDeviceToHost));
^
axpy.cu:37:19: error: use of undeclared identifier ‘cudaDeviceReset’
checkCudaErrors(cudaDeviceReset());
^
9 errors generated.
Does this work for you? If not, what platform are you on?
Note that the CUDA implementation in Clang is by no means complete.
It mostly works, but there are lots of edge-cases (e.g. printf) that
we're still working on.
I’ve installed master version from git on two systems. Currently I can thoroughly compile C/C++. But I can’t compile CUDA. I think I can’t show headers to clang while I am compiling cuda
The error what I got at the first machine
~/LLVM$ clang++ axpy.cu
In file included from :620:
In file included from :1:
In file included from /home/Computational/appbin/llvm-git/bin/…/lib/clang/3.8.0/include/__clang_cuda_runtime_wrapper.h:47:
In file included from /usr/include/stdlib.h:24:
/usr/include/features.h:374:12: fatal error: ‘sys/cdefs.h’ file not found
include <sys/cdefs.h>
^
Second machine
~/workspace/eclipse/TEST/llvm$ clang++ axpy.cu /usr/local/cuda-7.0/include/ -include cuda_runtime_api.h -D__CUDACC__ -m64
In file included from axpy.cu:8:
In file included from /usr/include/cuda_runtime.h:76:
In file included from /usr/include/common_functions.h:167:
/usr/include/math_functions.h:7563:10: fatal error: ‘cmath’ file not found #include
^
This compiled successfully for me on Ubuntu 14.04. Note that the
command-line arguments here are *not* optional -- I would not expect
the commands from your e-mail to work, because you were not passing
all of the relevant options. (These are documented at http://llvm.org/docs/CompileCudaWithLLVM.html.)
Maybe this is a dumb question, but are you sure that the clang++
you're invoking is the one you just built? Usually you have to do
path/to/objdir/bin/clang++.
I’m on ubuntu 14.04. I’ve installed CUDA 7.0 and GCC 4.8, 4.9 and 5.x in my system. Sorry for short written terminal output bit it is my clang installation. Here is an output of this:
$:~/workspace/eclipse/TEST/llvm$ clang -v
clang version 3.8.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/workspace/eclipse/llvm-bin/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.1.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.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
As I understand, clang++ what I built can compile C/C++ but when I want to compile CUDA it can’t find essential headers. I put verbose compilation log.
$:~/workspace/eclipse/TEST/llvm$ /home/workspace/eclipse/llvm-bin/bin/clang++ axpy.cu -o axpy -D__CUDA__ -D__CUDACC__ -I/usr/local/cuda-7.0/include -include cuda_runtime.h -I/usr/local/cuda/samples/common/inc/ -I/usr/local/cuda/ -v -L/usr/local/cuda/lib64 axpy.cu -lcudart_static -lcuda -ldl -lrt
clang version 3.8.0 (https://github.com/clang-omp/clang_trunk d2064b019fac6da21dc76067b2c8c547379ddd07) (https://github.com/clang-omp/llvm_trunk 76a27d9c85691eff5dbe18c5253865eb362c4786)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/workspace/eclipse/llvm-bin/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.1.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.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
“/home/workspace/eclipse/llvm-bin/bin/clang-3.8” -cc1 -triple nvptx64-nvidia-cuda -S -disable-free -main-file-name axpy.cu -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -target-cpu sm_20 -v -dwarf-column-info -resource-dir /home/workspace/eclipse/llvm-bin/bin/…/lib/clang/3.8.0 -include cuda_runtime.h -D CUDA -D CUDACC -I /usr/local/cuda-7.0/include -I /usr/local/cuda/samples/common/inc/ -I /usr/local/cuda/ -c-isystem /home/workspace/eclipse/llvm-openmp-build/runtime/src -c-isystem . -cxx-isystem /home/workspace/eclipse/llvm-openmp-build/runtime/src -cxx-isystem . -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/workspace/eclipse/TEST/llvm -ferror-limit 19 -fmessage-length 135 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/axpy-7c49a7.s -x cuda axpy.cu
clang -cc1 version 3.8.0 based upon LLVM 3.8.0svn default target x86_64-unknown-linux-gnu #include “…” search starts here: #include <…> search starts here:
/usr/local/cuda-7.0/include
/usr/local/cuda/samples/common/inc
/usr/local/cuda
/home/workspace/eclipse/llvm-openmp-build/runtime/src
.
/usr/local/include
/home/workspace/eclipse/llvm-bin/bin/…/lib/clang/3.8.0/include
/usr/include
End of search list.
In file included from :299:
In file included from :3:
In file included from /usr/local/cuda-7.0/include/cuda_runtime.h:104:
In file included from /usr/local/cuda-7.0/include/common_functions.h:219:
/usr/local/cuda-7.0/include/math_functions.h:8484:10: fatal error: ‘cmath’ file not found #include
Hi, sorry for the delay getting back to you; I was out for the holidays.
Something weird is going on, but I don't know what...
Stupid question: Are you able to use the clang you built to compile a
regular, non-CUDA C++ file which contains just "#include <cmath>"?
Can you include the -v output of that?
I wanted to see what revision you were building from, but the revs
from your clang++ -v don't seem to exist upstream: