4
votes

I am using CUDA 4.0 on Ubuntu 10.10 with GTX 570 (compute capcability 2.0), with the GCC compiler suite. As I understand it, during compilation the CUDA compiler driver nvcc splits the .cu files into host code and device code and calls the host compiler to compile the host code and compiles the device code separately. Finally it merges the generated host object code and the device PTX code into a single executable.

For Linux systems what is the default compiler that is invoked for compiling the host code? Is it the C compiler (gcc) or the C++ compiler (g++) of the GCC suite?

2
perhaps it can be overridden by a CC environment variable (like make usually does)? - Basile Starynkevitch
And you can strace programs (even proprietary ones like nvcc) to understand the syscalls (and external programs) they are using. - Basile Starynkevitch
With the verbose flag (-v) the nvcc will dump all of the executed commands during the compilation. So it will show you whether gcc or g++ is invoked. - tbalazs

2 Answers

15
votes

You want the -ccbin option for nvcc, e.g. to use icpc (the Intel C++ compiler), use nvcc -ccbin=icpc (assuming the icpc is available in your $PATH).

Note that you should always pass a C++ compiler (g++, icpc, etc.), since nvcc treats the code as C++, even when it's C code.

5
votes

AFAIK it uses g++ (to be more precise it uses gcc with language set to c++) and of course g++ for final linking. Run nvcc with --verbose option to see more detail if you want.