5.10. CUPTI 分析 API

实现 CUPTI 分析 API 的函数、类型和枚举。

数据结构

CUpti_Profiler_BeginPass_Params

cuptiProfilerBeginPass 的参数。

CUpti_Profiler_BeginSession_Params

cuptiProfilerBeginSession 的参数。

CUpti_Profiler_CounterDataImageOptions

用于定义 counterDataImage 的输入参数。

CUpti_Profiler_CounterDataImage_CalculateScratchBufferSize_Params

cuptiProfilerCounterDataImageCalculateScratchBufferSize 的参数。

CUpti_Profiler_CounterDataImage_CalculateSize_Params

cuptiProfilerCounterDataImageCalculateSize 的参数。

CUpti_Profiler_CounterDataImage_InitializeScratchBuffer_Params

cuptiProfilerCounterDataImageInitializeScratchBuffer 的参数。

CUpti_Profiler_CounterDataImage_Initialize_Params

cuptiProfilerCounterDataImageInitialize 的参数。

CUpti_Profiler_DeInitialize_Params

cuptiProfilerDeInitialize 的默认参数。

CUpti_Profiler_DeviceSupported_Params

cuptiProfilerDeviceSupported 的参数。

CUpti_Profiler_DisableProfiling_Params

cuptiProfilerDisableProfiling 的参数。

CUpti_Profiler_EnableProfiling_Params

cuptiProfilerEnableProfiling 的参数。

CUpti_Profiler_EndPass_Params

cuptiProfilerEndPass 的参数。

CUpti_Profiler_EndSession_Params

cuptiProfilerEndSession 的参数。

CUpti_Profiler_FlushCounterData_Params

cuptiProfilerFlushCounterData 的参数。

CUpti_Profiler_GetCounterAvailability_Params

cuptiProfilerGetCounterAvailability 的参数。

CUpti_Profiler_Initialize_Params

cuptiProfilerInitialize 的默认参数。

CUpti_Profiler_IsPassCollected_Params

cuptiProfilerIsPassCollected 的参数。

CUpti_Profiler_PopRange_Params

CUpti_Profiler_PushRange_Params

CUpti_Profiler_SetConfig_Params

cuptiProfilerSetConfig 的参数。

CUpti_Profiler_UnsetConfig_Params

cuptiProfilerUnsetConfig 的参数。

枚举

CUpti_ProfilerRange

分析器范围属性。

CUpti_ProfilerReplayMode

分析器重放属性。

CUpti_Profiler_API

分析器 API 类型。

CUpti_Profiler_Support_Level

CUPTI 的通用支持级别枚举。

函数

CUptiResult cuptiProfilerBeginPass(CUpti_Profiler_BeginPass_Params *pParams)

重放 API:用于多通道收集。

CUptiResult cuptiProfilerBeginSession(CUpti_Profiler_BeginSession_Params *pParams)

开始分析会话,在设备上设置分析。

CUptiResult cuptiProfilerCounterDataImageCalculateScratchBufferSize(CUpti_Profiler_CounterDataImage_CalculateScratchBufferSize_Params *pParams)

CounterData 图像的临时存储空间,内部操作需要。

CUptiResult cuptiProfilerCounterDataImageCalculateSize(CUpti_Profiler_CounterDataImage_CalculateSize_Params *pParams)

CounterData 图像为每个范围的每个计数器值分配空间。

CUptiResult cuptiProfilerCounterDataImageInitialize(CUpti_Profiler_CounterDataImage_Initialize_Params *pParams)

CUptiResult cuptiProfilerCounterDataImageInitializeScratchBuffer(CUpti_Profiler_CounterDataImage_InitializeScratchBuffer_Params *pParams)

CUptiResult cuptiProfilerDeInitialize(CUpti_Profiler_DeInitialize_Params *pParams)

取消初始化分析器接口。

CUptiResult cuptiProfilerDeviceSupported(CUpti_Profiler_DeviceSupported_Params *pParams)

查询设备与分析 API 的兼容性。

CUptiResult cuptiProfilerDisableProfiling(CUpti_Profiler_DisableProfiling_Params *pParams)

禁用分析。

CUptiResult cuptiProfilerEnableProfiling(CUpti_Profiler_EnableProfiling_Params *pParams)

启用分析。

CUptiResult cuptiProfilerEndPass(CUpti_Profiler_EndPass_Params *pParams)

重放 API:用于多通道收集。

CUptiResult cuptiProfilerEndSession(CUpti_Profiler_EndSession_Params *pParams)

结束分析会话。

CUptiResult cuptiProfilerFlushCounterData(CUpti_Profiler_FlushCounterData_Params *pParams)

解码所有提交的通道。

CUptiResult cuptiProfilerGetCounterAvailability(CUpti_Profiler_GetCounterAvailability_Params *pParams)

查询计数器可用性。

CUptiResult cuptiProfilerInitialize(CUpti_Profiler_Initialize_Params *pParams)

初始化分析器接口。

CUptiResult cuptiProfilerIsPassCollected(CUpti_Profiler_IsPassCollected_Params *pParams)

异步调用以查询提交到 GPU 的通道是否已收集。

CUptiResult cuptiProfilerPopRange(CUpti_Profiler_PopRange_Params *pParams)

范围 API:弹出用户范围。

CUptiResult cuptiProfilerPushRange(CUpti_Profiler_PushRange_Params *pParams)

范围 API:推入用户范围。

CUptiResult cuptiProfilerSetConfig(CUpti_Profiler_SetConfig_Params *pParams)

设置要分析的指标配置。

CUptiResult cuptiProfilerUnsetConfig(CUpti_Profiler_UnsetConfig_Params *pParams)

取消设置分析的指标配置。

5.10.1.

CUpti_Profiler_BeginPass_Params_STRUCT_SIZE
CUpti_Profiler_BeginSession_Params_STRUCT_SIZE
CUpti_Profiler_CounterDataImageOptions_STRUCT_SIZE
CUpti_Profiler_CounterDataImage_CalculateScratchBufferSize_Params_STRUCT_SIZE
CUpti_Profiler_CounterDataImage_CalculateSize_Params_STRUCT_SIZE
CUpti_Profiler_CounterDataImage_InitializeScratchBuffer_Params_STRUCT_SIZE
CUpti_Profiler_CounterDataImage_Initialize_Params_STRUCT_SIZE
CUpti_Profiler_DeInitialize_Params_STRUCT_SIZE
CUpti_Profiler_DeviceSupported_Params_STRUCT_SIZE
CUpti_Profiler_DisableProfiling_Params_STRUCT_SIZE
CUpti_Profiler_EnableProfiling_Params_STRUCT_SIZE
CUpti_Profiler_EndPass_Params_STRUCT_SIZE
CUpti_Profiler_EndSession_Params_STRUCT_SIZE
CUpti_Profiler_FlushCounterData_Params_STRUCT_SIZE
CUpti_Profiler_GetCounterAvailability_Params_STRUCT_SIZE
CUpti_Profiler_Initialize_Params_STRUCT_SIZE
CUpti_Profiler_IsPassCollected_Params_STRUCT_SIZE
CUpti_Profiler_PopRange_Params_STRUCT_SIZE
CUpti_Profiler_PushRange_Params_STRUCT_SIZE
CUpti_Profiler_SetConfig_Params_STRUCT_SIZE
CUpti_Profiler_UnsetConfig_Params_STRUCT_SIZE

5.10.2. 枚举

enum CUpti_ProfilerRange

分析器范围属性。

会话配置中启用的指标在通道中为每个唯一的范围堆栈单独收集。这是一个属性,用于收集分析会话中或用户定义的范围中每个内核周围的指标。

enumerator CUPTI_Range_INVALID

无效值。

enumerator CUPTI_AutoRange

范围在分析会话中的每个内核周围自动定义。

enumerator CUPTI_UserRange

要收集指标数据的范围由用户定义。

enumerator CUPTI_Range_COUNT

范围计数。

enum CUpti_ProfilerReplayMode

分析器重放属性。

对于需要多通道收集的指标,需要重放 GPU 内核。这是一个属性,用于指定如何完成要测量的内核重放。

enumerator CUPTI_Replay_INVALID

无效值。

enumerator CUPTI_ApplicationReplay

重放由 CUPTI 用户在进程周围完成。

enumerator CUPTI_KernelReplay

重放由 CUPTI 隐式地在内核周围完成。

enumerator CUPTI_UserReplay

重放由 CUPTI 用户在进程内完成。

enumerator CUPTI_Replay_COUNT

重放计数。

enum CUpti_Profiler_API

分析器 API 类型。

enumerator CUPTI_PROFILER_RANGE_PROFILING

用于基于范围的分析的 CUPTI API (cuptiProfiler*)

enumerator CUPTI_PROFILER_PC_SAMPLING

CUPTI API 收集 pc 采样数据 (cuptiPcSampling*)

enumerator CUPTI_PROFILER_SASS_METRICS

CUPTI API 收集 SASS 指标数据 (cuptiSassMetrics*)

enumerator CUPTI_PROFILER_PM_SAMPLING

CUPTI API 收集 PM 采样数据 (cuptiPmSampling*)

enumerator CUPTI_PROFILER_UNKNOWN
enum CUpti_Profiler_Support_Level

CUPTI 的通用支持级别枚举。

enumerator CUPTI_PROFILER_CONFIGURATION_UNKNOWN

配置支持级别未知 - 检测代码在设置此值之前出错,或者无法确定。

enumerator CUPTI_PROFILER_CONFIGURATION_UNSUPPORTED

分析不可用。对于特定功能字段,这意味着此功能的当前配置不适用于分析。例如,启用 SLI 的设备不支持分析,并且此值将针对启用 SLI 的设备上的 SLI 返回。

enumerator CUPTI_PROFILER_CONFIGURATION_DISABLED

分析可能适用于此配置,但已被系统禁用。

enumerator CUPTI_PROFILER_CONFIGURATION_SUPPORTED

支持分析。对于特定功能字段,这意味着此功能的当前配置适用于分析。例如,启用 SLI 的设备不支持分析,并且此值仅针对未启用 SLI 的设备返回。

5.10.3. 函数

CUptiResult cuptiProfilerBeginPass(CUpti_Profiler_BeginPass_Params *pParams)

重放 API:用于多通道收集。

如果用户选择自行重放 CUPTI_UserReplayCUPTI_ApplicationReplay 以进行指标配置的多通道收集,则使用这些 API。在 CUPTI_KernelReplay 的情况下,它是无操作。

CUptiResult cuptiProfilerBeginSession(CUpti_Profiler_BeginSession_Params *pParams)

开始分析会话,在设备上设置分析。

虽然它不启动分析,但会分配分析所需的 GPU 资源。在会话之外,GPU 将返回其正常运行状态。

CUptiResult cuptiProfilerCounterDataImageCalculateScratchBufferSize(CUpti_Profiler_CounterDataImage_CalculateScratchBufferSize_Params *pParams)

CounterData 图像的临时存储空间,内部操作需要。

使用这些 API 来计算分配大小并初始化 counterData 图像暂存缓冲区。

CUptiResult cuptiProfilerCounterDataImageCalculateSize(CUpti_Profiler_CounterDataImage_CalculateSize_Params *pParams)

CounterData 图像为每个范围的每个计数器值分配空间。

用户承担管理 counterDataImage 分配的责任。 CounterDataPrefix 包含有关将存储在 counterDataImage 中的指标的元数据。使用这些 API 来计算分配大小并初始化 counterData 图像。

CUptiResult cuptiProfilerCounterDataImageInitialize(CUpti_Profiler_CounterDataImage_Initialize_Params *pParams)
CUptiResult cuptiProfilerCounterDataImageInitializeScratchBuffer(CUpti_Profiler_CounterDataImage_InitializeScratchBuffer_Params *pParams)
CUptiResult cuptiProfilerDeInitialize(CUpti_Profiler_DeInitialize_Params *pParams)

取消初始化分析器接口。

CUptiResult cuptiProfilerDeviceSupported(CUpti_Profiler_DeviceSupported_Params *pParams)

查询设备与分析 API 的兼容性。

使用此调用来确定计算设备和配置是否与 Profiling API 兼容。如果配置不支持 profiling,则会使用多个标志之一来指示原因。

CUptiResult cuptiProfilerDisableProfiling(CUpti_Profiler_DisableProfiling_Params *pParams)

禁用分析。

CUPTI_AutoRange 中,这些 API 用于启用/禁用在 profiling 会话中执行的内核的 profiling。

CUptiResult cuptiProfilerEnableProfiling(CUpti_Profiler_EnableProfiling_Params *pParams)

启用分析。

CUPTI_AutoRange 中,这些 API 用于启用/禁用在 profiling 会话中执行的内核的 profiling。

CUptiResult cuptiProfilerEndPass(CUpti_Profiler_EndPass_Params *pParams)

重放 API:用于多通道收集。

如果用户选择自行重放 CUPTI_UserReplayCUPTI_ApplicationReplay 以进行指标配置的多遍收集,则使用这些 API。在 CUPTI_KernelReplay 的情况下,它是一个空操作。返回下一遍的信息。

CUptiResult cuptiProfilerEndSession(CUpti_Profiler_EndSession_Params *pParams)

结束分析会话。

释放为 profiling 获取的 GPU 资源。在会话之外,GPU 将恢复到其正常运行状态。

CUptiResult cuptiProfilerFlushCounterData(CUpti_Profiler_FlushCounterData_Params *pParams)

解码所有提交的通道。

刷新计数器数据 API,以确保每个 pass 都被解码到在 beginSession 处传递的 counterDataImage 中。这将导致 CPU/GPU 同步收集所有未解码的 pass。

CUptiResult cuptiProfilerGetCounterAvailability(CUpti_Profiler_GetCounterAvailability_Params *pParams)

查询计数器可用性。

使用此 API 查询缓冲区中的计数器可用性信息,该缓冲区可用于在主机上过滤不可用的原始指标。注意:如果指定的上下文或其设备上存在任何 profiling 或采样会话,则此 API 可能会失败。

CUptiResult cuptiProfilerInitialize(CUpti_Profiler_Initialize_Params *pParams)

初始化分析器接口。

在进程地址空间中加载所需的库。设置与 CUDA 驱动程序的挂钩。

CUptiResult cuptiProfilerIsPassCollected(CUpti_Profiler_IsPassCollected_Params *pParams)

异步调用以查询提交到 GPU 的通道是否已收集。

CUptiResult cuptiProfilerPopRange(CUpti_Profiler_PopRange_Params *pParams)

Range API’s : 弹出用户范围。

计数器数据是按唯一的范围堆栈收集的。由用户传递的字符串标签标识。在 CUPTI_AutoRange 的情况下,这是一个无效的操作。

CUptiResult cuptiProfilerPushRange(CUpti_Profiler_PushRange_Params *pParams)

Range API’s : 推送用户范围。

计数器数据是按唯一的范围堆栈收集的。由用户传递的字符串标签标识。在 CUPTI_AutoRange 的情况下,这是一个无效的操作。

CUptiResult cuptiProfilerSetConfig(CUpti_Profiler_SetConfig_Params *pParams)

设置要分析的指标配置。

使用这些 API 在会话中设置要 profiling 的配置。它可用于高级情况,例如在需要时将多个配置收集到单个 CounterData Image 中,而无需重新启动会话。

CUptiResult cuptiProfilerUnsetConfig(CUpti_Profiler_UnsetConfig_Params *pParams)

取消设置分析的指标配置。