6.31. 驱动程序入口点访问

本节介绍CUDA运行时应用程序编程接口的驱动程序入口点访问函数。

Functions

__host__cudaError_t cudaGetDriverEntryPoint ( const char* symbol, void** funcPtr, unsigned long long flags, cudaDriverEntryPointQueryResult ** driverStatus = NULL )
Returns the requested driver API function pointer.
__host__cudaError_t cudaGetDriverEntryPointByVersion ( const char* symbol, void** funcPtr, unsigned int  cudaVersion, unsigned long long flags, cudaDriverEntryPointQueryResult ** driverStatus = NULL )
Returns the requested driver API function pointer by CUDA version.

Functions

__host__cudaError_t cudaGetDriverEntryPoint ( const char* symbol, void** funcPtr, unsigned long long flags, cudaDriverEntryPointQueryResult ** driverStatus = NULL )
返回请求的驱动程序API函数指针。
参数
symbol
- The base name of the driver API function to look for. As an example, for the driver API cuMemAlloc_v2, symbol would be cuMemAlloc. Note that the API will use the CUDA runtime version to return the address to the most recent ABI compatible driver symbol, cuMemAlloc or cuMemAlloc_v2.
funcPtr
- Location to return the function pointer to the requested driver function
flags
- Flags to specify search options.
driverStatus
- Optional location to store the status of finding the symbol from the driver. See cudaDriverEntryPointQueryResult for possible values.
描述

**funcPtr中返回对应请求标志的CUDA驱动函数地址。

对于请求的驱动程序符号,如果引入该驱动程序符号的CUDA版本小于或等于CUDA运行时版本,API将返回指向相应版本驱动程序函数的函数指针。

API返回的指针应转换为与请求的驱动程序函数在API头文件中的定义相匹配的函数指针。函数指针的类型定义可以从相应的类型定义头文件中获取。例如,cudaTypedefs.h包含了cuda.h中定义的驱动程序API的函数指针类型定义。

如果请求的驱动程序函数有效且在该平台上受支持,API将返回cudaSuccess并设置返回的funcPtr

如果请求的驱动程序函数在当前平台不受支持、没有与CUDA运行时版本ABI兼容的驱动程序函数存在,或者驱动程序符号无效,API将返回cudaSuccess并将返回的funcPtr设置为NULL。

它还会将可选的driverStatus设置为cudaDriverEntryPointQueryResult中的某个值,其含义如下:

请求的标志可以是:

Note:

另请参阅:

cuGetProcAddress

__host__cudaError_t cudaGetDriverEntryPointByVersion ( const char* symbol, void** funcPtr, unsigned int  cudaVersion, unsigned long long flags, cudaDriverEntryPointQueryResult ** driverStatus = NULL )
根据CUDA版本返回请求的驱动程序API函数指针。
参数
symbol
- The base name of the driver API function to look for. As an example, for the driver API cuMemAlloc_v2, symbol would be cuMemAlloc.
funcPtr
- Location to return the function pointer to the requested driver function
cudaVersion
- The CUDA version to look for the requested driver symbol
flags
- Flags to specify search options.
driverStatus
- Optional location to store the status of finding the symbol from the driver. See cudaDriverEntryPointQueryResult for possible values.
描述

**funcPtr中返回对应请求标志和CUDA驱动版本的CUDA驱动函数地址。

CUDA版本号的计算公式为(1000 * 主版本号 + 10 * 次版本号),因此CUDA 11.2应表示为11020。对于请求的驱动程序符号,如果指定的CUDA版本号大于或等于该驱动程序符号被引入时的CUDA版本号,此API将返回对应版本函数的指针。

API返回的指针应转换为与请求的驱动程序函数在API头文件中的定义相匹配的函数指针。函数指针的类型定义可以从相应的类型定义头文件中获取。例如,cudaTypedefs.h包含了cuda.h中定义的驱动程序API的函数指针类型定义。

当请求的CUDA版本高于已安装的CUDA工具包时,对应的头文件中可能没有合适的函数指针类型定义,此时可能需要自定义类型定义以匹配驱动程序返回的函数签名。可以通过从更新的工具包获取类型定义,或创建适当匹配的自定义函数类型定义来实现。

如果请求的驱动程序函数有效且在该平台上受支持,API将返回cudaSuccess并设置返回的funcPtr

如果请求的驱动程序函数在当前平台不受支持、没有与请求版本ABI兼容的驱动程序函数存在,或者驱动程序符号无效,API将返回cudaSuccess并将返回的funcPtr设置为NULL。

它还会将可选的driverStatus设置为cudaDriverEntryPointQueryResult中的某个值,其含义如下:

请求的标志可以是:

Note:

另请参阅:

cuGetProcAddress