且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

cuda.h,cuda_runtime.h,cuda_runtime_api.h之间的区别

更新时间:2023-11-10 16:47:52

非常宽泛的字词:


  • cuda.h 定义了CUDA
    驱动程序API的公共主机
    函数和类型。

  • cuda_runtime_api.h 定义
    CUDA运行时API的public
    主机函数和类型

  • cuda_runtime.h 定义 cuda_runtime_api.h 键入
    用于CUDA语言扩展和
    设备固有函数的定义和函数覆盖。

  • 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 API
  • cuda_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.

主机代码要与包含API调用的主机编译器一起编译,您可以包括 cuda.h cuda_runtime_api.h 。如果您需要其他CUDA语言内置函数(如类型),并且正在使用运行时API并使用主机编译器进行编译,则可以包括 cuda_runtime.h 。如果你编写的代码将使用nvcc编译,这一切都是无关紧要的,因为nvcc会自动处理所有需要的头文件,而无需程序员干预。

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.