I'm starting to program with CUDA, and in some examples I find the include files cuda.h
, cuda_runtime.h
and cuda_runtime_api.h
included in the code. Can someone explain to me the difference between these files?
In very broad terms:
cuda.h
defines the public host
functions and types for the CUDA
driver API.cuda_runtime_api.h
defines the public
host functions and types for the
CUDA runtime APIcuda_runtime.h
defines everything cuda_runtime_api.h
does, as well as built-in type
definitions and function overlays for the CUDA language extensions and
device intrinsic functions.If you were writing host code to be compiled with the host compiler which includes API calls, you would include either cuda.h
or cuda_runtime_api.h
. If you needed other CUDA language built-ins, like types, and were using the runtime API and compiling with the host compiler, you would include cuda_runtime.h
. If you are writing code which will be compiled using nvcc, it is all irrelevant, because nvcc takes care of inclusion of all the required headers automatically without programmer intervention.