Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhengkai 的贡献)变更摘要
本次 PR 主要对 profiling 采集器中驱动版本检查机制进行了统一重构,并新增了 AICPU 采样周期的动态适配能力。通过引入 DrvFunctionVersion 枚举和 IsDrvApiVersionSupport() 辅助函数,将分散的版本常量集中管理,同时修复了 ADPROF_API_VERSION 的版本号错误(由 0x72316 修正为 0x072316)。此外,针对 AICPU 通道的采样周期,新增了根据驱动版本和平台能力动态选择 aicpuDrvSamplePeriod(7 或 10)的逻辑。
主要改动
- 驱动版本检查机制统一:在
platform.h中新增DrvFunctionVersion枚举,集中定义OSC_FREQ_API_VERSION、ADPROF_API_VERSION、DAVID_AICPU_SAMPLE_PERIOD三个版本常量;同时新增IsDrvApiVersionSupport()函数,在platform.cpp中替代原先分散的版本比较逻辑。 - ADPROF 版本号修正:将
SUPPORT_ADPROF_VERSION的值从0x72316修正为0x072316,并迁移至DrvFunctionVersion枚举中的ADPROF_API_VERSION。 - AICPU 采样周期动态适配:在
ai_drv_prof_api.cpp的DrvAicpuStart()中,根据IsDrvApiVersionSupport(DAVID_AICPU_SAMPLE_PERIOD)和平台PLATFORM_AICPU_SAMPLE_PERIOD特性,将aicpuDrvSamplePeriod在驱动支持时设为7U,否则回退为10U。 - 平台特性枚举扩展:在
platform_interface.h的PlatformFeature枚举中新增PLATFORM_AICPU_SAMPLE_PERIOD项,并在david_platform.cpp的DavidPlatform构造中将该特性加入支持列表。


代码审查
审查总结
逐文件审查结果:
| 文件 | 审查结论 |
|---|---|
src/dfx/msprof/collector/dvvp/common/platform/platform.cpp |
无问题 — IsDrvApiVersionSupport 实现正确,三处调用点的逻辑等价变换无误,版本常量值 (0x72316 → 0x072316) 数值等价 |
src/dfx/msprof/collector/dvvp/common/platform/platform.h |
无问题 — DrvFunctionVersion 枚举定义和 IsDrvApiVersionSupport 声明正确,注释准确描述了不缓存的理由 |
src/dfx/msprof/collector/dvvp/driver/channel/ai_drv_prof_api.cpp |
1 个 P0 问题 — constexpr 块作用域导致编译错误 |
src/dfx/msprof/collector/dvvp/profimpl/platform/david_platform.cpp |
无问题 — PLATFORM_AICPU_SAMPLE_PERIOD 正确加入特性列表 |
src/dfx/msprof/collector/dvvp/profimpl/platform/platform_interface.h |
无问题 — PLATFORM_AICPU_SAMPLE_PERIOD 正确添加在 PLATFORM_COLLECTOR_TYPES_MAX 之前 |
按优先级统计:
- P0: 1
- P1: 0
- P2: 0
- P3: 0
整体风险评估:🔴 高风险 — 存在一个编译阻断缺陷(DrvAicpuStart 中变量作用域错误),代码无法通过编译,必须在合入前修复。修复方案简单明确:将 aicpuDrvSamplePeriod 的声明提升到 if/else 块外部,使用三元表达式或块外声明+块内赋值。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 3 |
| 🟡 建议 | 0 |
⛔ 需要修改


Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| ** | ✅ 侯延保, gcw_kUomxQ2l (2/2) | ✅ gcw_kUomxQ2l (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
z296249221, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [11f33f32d4044f2d8d70f7f1e8f12645][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ❌ FAILED | >>>>> | |
| Compile_Ascend_ARM | ❌ FAILED | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> |


流水线任务触发成功
任务链接 [bb3cbd3579a244b183dc72cc1633dbc7][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_Check_Pr | ✅ SUCCESS | ||
| codecheck_style | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-07-30 10:43:06] CI执行结束


🔴 Critical
变更行:第 325 行在 if 块内声明 constexpr uint32_t aicpuDrvSamplePeriod = 7U;,第 327 行在 else 块内声明 constexpr uint32_t aicpuDrvSamplePeriod = 10U;,两者均为块作用域局部变量,离开各自块后即销毁。而第 330 行的 prof_start_para 初始化器 .sample_period = aicpuDrvSamplePeriod 在 if/else 之外引用该名称,此时 aicpuDrvSamplePeriod 已不在作用域内,必然导致编译错误(use of undeclared identifier)。
失败模式:任何尝试编译此文件的构建都会失败。
修复方向:将变量声明提升到 if/else 之前,在条件分支内赋值;或使用三元表达式替代 if/else。
建议:将 aicpuDrvSamplePeriod 的声明提升到 if/else 之前,在分支内仅做赋值。或者改为三元表达式:uint32_t aicpuDrvSamplePeriod = (cond) ? 7U : 10U;


🔴 Critical
变更行:第 324 行使用未限定的 PLATFORM_AICPU_SAMPLE_PERIOD 作为 CheckIfSupport 的实参。该枚举值定义在 Dvvp::Collect::Platform 命名空间(platform_interface.h 第 160 行),而调用所在文件 ai_drv_prof_api.cpp 处于 analysis::dvvp::driver 命名空间,且该文件没有 using namespace Dvvp::Collect::Platform; 或 using namespace Analysis::Dvvp::Common::Platform; 指令。platform.h 内部的 using namespace ::Dvvp::Collect::Platform; 仅在其自身命名空间 Analysis::Dvvp::Common::Platform 内生效,不会泄漏到 analysis::dvvp::driver。
失败模式:编译时符号查找失败(undeclared identifier PLATFORM_AICPU_SAMPLE_PERIOD)。
修复方向:将实参改为完整限定名 Dvvp::Collect::Platform::PLATFORM_AICPU_SAMPLE_PERIOD,或在该文件的 analysis::dvvp::driver 命名空间内添加 using namespace Dvvp::Collect::Platform;(参照同仓库其他文件的惯例,推荐添加 using namespace Analysis::Dvvp::Common::Platform;)。
| 324
| - Analysis::Dvvp::Common::Platform:: |
|
324 | + Analysis::Dvvp::Common::Platform::instance()->CheckIfSupport(Dvvp::Collect::Platform::PLATFORM_AICPU_SAMPLE_PERIOD)) { |


🔴 Critical
DrvAicpuStart 函数(第 322-328 行)将 constexpr uint32_t aicpuDrvSamplePeriod 声明在 if 和 else 代码块内部。在 C++ 中,块内声明的变量其作用域仅限于该块,离开块后即不可见。第 330 行在 if/else 块之外使用 aicpuDrvSamplePeriod 会导致编译错误:use of undeclared identifier 'aicpuDrvSamplePeriod'。
证据链:
影响:代码无法通过编译,属于 P0 构建失败级别的问题。
建议:将变量声明移到 if/else 块外部,在块内赋值(不能使用 constexpr,改用 const 或普通变量),或使用三元表达式一步完成。
|
330 | + const uint32_t aicpuDrvSamplePeriod = (Analysis::Dvvp::Common::Platform::IsDrvApiVersionSupport( |
| 330
| - |
|
331 | + Analysis::Dvvp::Common::Platform::DAVID_AICPU_SAMPLE_PERIOD) && |
|
332 | + Analysis::Dvvp::Common::Platform::instance()->CheckIfSupport(PLATFORM_AICPU_SAMPLE_PERIOD)) ? 7U : 10U; |


流水线任务触发成功
任务链接 [7df01506e65c45c3979672fe4670315f][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| UT_Test_acl | ✅ SUCCESS | >>>>> | |
| UT_Test_rts_v201 | ✅ SUCCESS | >>>>> | |
| UT_Test_rts_c | ✅ SUCCESS | >>>>> | |
| UT_Test_rts_david | ✅ SUCCESS | >>>>> | |
| UT_Test_rts_910b | ✅ SUCCESS | >>>>> | |
| UT_Test_rts_common | ✅ SUCCESS | >>>>> | |
| UT_Test_platform | ✅ SUCCESS | >>>>> | |
| UT_Test_qs | ✅ SUCCESS | >>>>> | |
| UT_Test_aicpusd | ✅ SUCCESS | >>>>> | |
| UT_Test_tsd | ✅ SUCCESS | >>>>> | |
| UT_Test_error_manager | ✅ SUCCESS | >>>>> | |
| UT_Test_slog | ✅ SUCCESS | >>>>> | |
| UT_Test_atrace | ✅ SUCCESS | >>>>> | |
| UT_Test_adump | ✅ SUCCESS | >>>>> | |
| UT_Test_mmpa | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> | |
| UT_Test_msprof | ✅ SUCCESS | >>>>> | |
| UT_Test_rts_report | ✅ SUCCESS | >>>>> | |
| UT_Test_msprof_report | ✅ SUCCESS |
[2026-07-30 11:48:43] CI执行结束


流水线任务触发成功
任务链接 [3e6e6b14fb40467db893a89b74fabeb2][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_Check_Pr | ✅ SUCCESS | ||
| codecheck_style | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-07-30 11:43:45] CI执行结束


/approve


Pull Request
描述
请清晰准确地描述本次 Pull Request 的意图和变更内容。
适配驱动不同分支、不同形态修改aicpu通道采集频率,修复大数据量场景下集合通信算子执行膨胀问题。
变更类型
请选择本次引入的变更类型:
关联的Issue
NA
核对清单
其他信息
在此添加任何其他关于本次 PR 的说明。