6.33. 驱动程序入口点访问

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

Functions

CUresult cuGetProcAddress ( const char* symbol, void** pfn, int  cudaVersion, cuuint64_t flags, CUdriverProcAddressQueryResult* symbolStatus )
Returns the requested driver API function pointer.

Functions

CUresult cuGetProcAddress ( const char* symbol, void** pfn, int  cudaVersion, cuuint64_t flags, CUdriverProcAddressQueryResult* symbolStatus )
返回请求的驱动程序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 and cudaVersion would be the ABI compatible CUDA version for the _v2 variant.
pfn
- 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.
symbolStatus
- Optional location to store the status of the search for symbol based on cudaVersion. See CUdriverProcAddressQueryResult for possible values.
描述

**pfn中返回指定CUDA版本和标志对应的CUDA驱动程序函数地址。

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

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

如果请求的驱动程序函数在当前平台不受支持、没有针对指定cudaVersion的ABI兼容驱动程序函数存在,或者驱动程序符号无效,该API将返回CUDA_SUCCESS并将返回的pfn设置为NULL。

它还会将可选的symbolStatus设置为CUdriverProcAddressQueryResult中的以下值之一,其含义如下:

请求的标志可以是:

Note:

强烈不建议混合使用CUDA定义的类型和驱动API版本,这样做可能导致未定义的行为。更多信息

另请参阅:

cudaGetDriverEntryPoint