CUDA Compiler (nvcc)
Before you even understand how CUDA compilers work, you need to understand how a basic compiler works in the first place mate. Like you don’t know ANYTHING.
How have you neglected this understanding for so long? Because you never needed it I guess.
Resources
From Accelerated Computing Course:
The CUDA platform ships with the NVIDIA CUDA Compiler nvcc, which can compile CUDA accelerated applications, both the host, and the device code they contain. For the purposes of this lab, nvcc discussion will be pragmatically scoped to suit our immediate needs. After completing the lab anyone interested in a deeper dive into nvcc can start with the documentation.
nvcc will be very familiar to experienced gcc users. Compiling, for example, a some-CUDA.cu file, is simply:
nvcc -std=c++11 arch=sm_70 -o out some-CUDA.cu -run
nvccis the command line command for using thenvcccompiler.some-CUDA.cuis passed as the file to compile.- The
oflag is used to specify the output file for the compiled program. -stdspecifies the C++ version- The
archflag indicates for which architecture the files must be compiled. For the present casesm_70will serve to compile specifically for the GPU this lab is running on, but for those interested in a deeper dive, please refer to the docs about thearchflag, virtual architecture features and GPU features. - As a matter of convenience, providing the
runflag will execute the successfully compiled binary.