Identifying nvcc compilation steps in nsight output

I’ve recently been reading about the compilation phases in the NVCC documentation and I’m interested in identifying the compilation steps/phases generated by the nsight (EE) IDE

/usr/bin/nvcc -G -g -O0 -gencode arch=compute_30,code=sm_30  -odir "src" -M -o "src/TestTrust.d" "../src/TestTrust.cu"
/usr/bin/nvcc -G -g -O0 --compile --relocatable-device-code=true -gencode arch=compute_30,code=compute_30 -gencode arch=compute_30,code=sm_30  -x cu -o  "src/TestTrust.o" "../src/TestTrust.cu"
/usr/bin/nvcc --cudart static --relocatable-device-code=true -gencode arch=compute_30,code=compute_30 -gencode arch=compute_30,code=sm_30 -link -o  "TestTrust"  ./src/TestTrust.o

In addition what is the .d file extension? I can’t find any information about this file extension in the documentation.

.d is just a file extension. You could name that output file anything you want.

It is a dependency generation step, triggered by the -M switch, and the -M switch is documented in the nvcc documentation.

http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#options-for-specifying-compilation-phase

The gnu toolchain has a similar switch with a similar purpose:

https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html

The other two steps are the compile (–compile) and link (-link) phases.

Thanks.

Two other questions:

  1. How does NVCC find the correct GCC compiler to use? I’ve got GCC 5 (which CUDA 8.0 requires/is compatible with) and GCC 6.

  2. What does NVCC assume when I don’t compile with the gencode option? For example:

nvcc -I../../common/inc  -m64 -o simpleMPI.o -c simpleMPI.cu

This appears to work. Just curious.

The nvcc manual provides answers to questions like these.

Unfortunately the docs don’t. My reading of the docs may be wrong but, I cannot find a default option given for the switch -gencode.

As for the correct GCC compiler, again no default is given for the switch -ccbin, even though the name of the host compiler alone may be specified “to ensure that the correct host compiler is selected”. And as I’m sure NVCC was not build with an explicit dependency on GCC 5, I’m worried that NVCC may be selecting GCC 6, because that’s what the Linux command: which g++ returns.

gencode:

with CUDA 8, the default is to compile for a compute capability 2.0 device, if nothing is specified.
this default is actually indicated in the nvcc ptxas options section

ccbin:

Then use the ccbin option to direct your nvcc to use the gcc version that you want.

From the nvcc doc:

http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#supported-host-compilers

“On all platforms, the default host compiler executable (gcc and g++ on Linux, clang and clang++ on Mac OS X, and cl.exe on Windows) found in the current execution search path will be used, unless specified otherwise with appropriate options (see File and Path Specifications).”