已合并
[Profiling]【fix】:兼容驱动不同分支、不同形态修改aicpu通道采集频率 #3944
[Profiling]【fix】:兼容驱动不同分支、不同形态修改aicpu通道采集频率 #3944
已合并
zhengkai创建于 7月30日
zhengkai成员
7月30日

Pull Request

描述

请清晰准确地描述本次 Pull Request 的意图和变更内容。
适配驱动不同分支、不同形态修改aicpu通道采集频率,修复大数据量场景下集合通信算子执行膨胀问题。

变更类型

请选择本次引入的变更类型:

关联的Issue

NA

核对清单

其他信息

在此添加任何其他关于本次 PR 的说明。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhengkai 的贡献)
Zzhengkai成员
7月30日 添加了label:enhancement
Zzhengkai成员
7月30日 创建了 pull request,commit 05bfeead
atomgit-bot
atomgit-bot
7月30日 评论:

变更摘要

本次 PR 主要对 profiling 采集器中驱动版本检查机制进行了统一重构,并新增了 AICPU 采样周期的动态适配能力。通过引入 DrvFunctionVersion 枚举和 IsDrvApiVersionSupport() 辅助函数,将分散的版本常量集中管理,同时修复了 ADPROF_API_VERSION 的版本号错误(由 0x72316 修正为 0x072316)。此外,针对 AICPU 通道的采样周期,新增了根据驱动版本和平台能力动态选择 aicpuDrvSamplePeriod(7 或 10)的逻辑。

主要改动

  • 驱动版本检查机制统一:在 platform.h 中新增 DrvFunctionVersion 枚举,集中定义 OSC_FREQ_API_VERSIONADPROF_API_VERSIONDAVID_AICPU_SAMPLE_PERIOD 三个版本常量;同时新增 IsDrvApiVersionSupport() 函数,在 platform.cpp 中替代原先分散的版本比较逻辑。
  • ADPROF 版本号修正:将 SUPPORT_ADPROF_VERSION 的值从 0x72316 修正为 0x072316,并迁移至 DrvFunctionVersion 枚举中的 ADPROF_API_VERSION
  • AICPU 采样周期动态适配:在 ai_drv_prof_api.cppDrvAicpuStart() 中,根据 IsDrvApiVersionSupport(DAVID_AICPU_SAMPLE_PERIOD) 和平台 PLATFORM_AICPU_SAMPLE_PERIOD 特性,将 aicpuDrvSamplePeriod 在驱动支持时设为 7U,否则回退为 10U
  • 平台特性枚举扩展:在 platform_interface.hPlatformFeature 枚举中新增 PLATFORM_AICPU_SAMPLE_PERIOD 项,并在 david_platform.cppDavidPlatform 构造中将该特性加入支持列表。
likedislike
atomgit-bot
atomgit-bot
7月30日 评论:

代码审查

审查总结

逐文件审查结果:

文件 审查结论
src/dfx/msprof/collector/dvvp/common/platform/platform.cpp 无问题 — IsDrvApiVersionSupport 实现正确,三处调用点的逻辑等价变换无误,版本常量值 (0x723160x072316) 数值等价
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

⛔ 需要修改

likedislike
CANN-robotCANN-robot成员
7月30日 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
7月30日 添加了label:stat/needs-squash
CANN-robot
CANN-robot成员
7月30日 评论:

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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
zhengkai成员
7月30日 评论:

compile

likedislike
Zzhengkai成员
7月30日 update merge request[project id: 8810053, iid: 3944, commit_id: 79a17d1148eda8f375b792f43b06d1a97ff283bf] virtual merging success
CANN-robotCANN-robot成员
7月30日 将wangtao43,zhangpengpeng8,yanmingxiang,Reyn52166,jiangtao_rts,ykl999,houyanbao,hanxiaolong,gcw_kUomxQ2l,Andy-lb,tingwood设为评审人
CANN-robotCANN-robot成员
7月30日 将jiangtao_rts,hanxiaolong,gcw_kUomxQ2l,Andy-lb设为审查人
CANN-robotCANN-robot成员
7月30日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月30日 评论:

流水线任务触发成功
任务链接 [11f33f32d4044f2d8d70f7f1e8f12645][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ❌ FAILED >>>>>
Compile_Ascend_ARM ❌ FAILED >>>>>
pre_comment ✅ SUCCESS >>>>>
likedislike
CANN-robot
CANN-robot成员
7月30日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robotCANN-robot成员
7月30日 删除了label:ci-pipeline-running
此处折叠了6条事件消息 查看更多
Zzhengkai成员
7月30日 update merge request[project id: 8810053, iid: 3944, commit_id: 7ce689bfe8333f967455d71861ed391d64b0b3d4] virtual merging success
atomgit-bot
atomgit-bot7月30日进行代码检视1
src/dfx/msprof/collector/dvvp/driver/channel/ai_drv_prof_api.cpp
@@ -16,6 +16,7 @@
1616#include "ascend_inpackage_hal.h"
1717#include "json_parser.h"
1818#include "validation/nts_metrics_validation.h"
19+#include "platform/platform.h"
1920namespace analysis {
2021namespace dvvp {
2122namespace driver {
@@ -318,7 +319,12 @@ int32_t DrvAicoreTaskBasedStart(int32_t profDeviceId, AI_DRV_CHANNEL profChannel
318319 
319320int32_t DrvAicpuStart(uint32_t profDeviceId, AI_DRV_CHANNEL profChannel)
320321{
321- constexpr uint32_t aicpuDrvSamplePeriod = 7U;
322+ constexpr uint32_t aicpuDrvSamplePeriod = 10U;
323+ if (Analysis::Dvvp::Common::Platform::IsDrvApiVersionSupport(
324+ Analysis::Dvvp::Common::Platform::DAVID_AICPU_SAMPLE_PERIOD) &&
325+ Analysis::Dvvp::Common::Platform::instance()->CheckIfSupport(PLATFORM_AICPU_SAMPLE_PERIOD)) {
326+ aicpuDrvSamplePeriod = 5U;
327+ }
322328 struct prof_start_para profStartPara = { .channel_type = PROF_PERIPHERAL_TYPE,
323329 .sample_period = aicpuDrvSamplePeriod,
324330 .real_time = PROFILE_REAL_TIME,
@@ -326,4 +332,4 @@
326332 .user_data_size = 0 };
atomgit-bot
atomgit-bot7月30日评论:

🔴 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;

likedislike
atomgit-bot
atomgit-bot7月30日进行代码检视2
src/dfx/msprof/collector/dvvp/driver/channel/ai_drv_prof_api.cpp
已过期
@@ -321,1 +322,3 @@
321- constexpr uint32_t aicpuDrvSamplePeriod = 7U;
322+ constexpr uint32_t aicpuDrvSamplePeriod = 10U;
323+ if (Analysis::Dvvp::Common::Platform::IsDrvApiVersionSupport(
324+ Analysis::Dvvp::Common::Platform::DAVID_AICPU_SAMPLE_PERIOD) &&
atomgit-bot
atomgit-bot7月30日评论:

🔴 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::DAVID_AICPU_SAMPLE_PERIOD) &&
324
+ Analysis::Dvvp::Common::Platform::instance()->CheckIfSupport(Dvvp::Collect::Platform::PLATFORM_AICPU_SAMPLE_PERIOD)) {
应用建议
likedislike
System
系统消息系统
7月30日 评论:

changed this line on f6c373ce view diff detail

atomgit-bot
atomgit-bot7月30日进行代码检视1
src/dfx/msprof/collector/dvvp/driver/channel/ai_drv_prof_api.cpp
@@ -322,3 +327,4 @@
327+ }
322328 struct prof_start_para profStartPara = { .channel_type = PROF_PERIPHERAL_TYPE,
323329 .sample_period = aicpuDrvSamplePeriod,
324330 .real_time = PROFILE_REAL_TIME,
atomgit-bot
atomgit-bot7月30日评论:

🔴 Critical

DrvAicpuStart 函数(第 322-328 行)将 constexpr uint32_t aicpuDrvSamplePeriod 声明在 ifelse 代码块内部。在 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
- .real_time = PROFILE_REAL_TIME,
331
+ Analysis::Dvvp::Common::Platform::DAVID_AICPU_SAMPLE_PERIOD) &&
332
+ Analysis::Dvvp::Common::Platform::instance()->CheckIfSupport(PLATFORM_AICPU_SAMPLE_PERIOD)) ? 7U : 10U;
应用建议
likedislike
Zzhengkai成员
7月30日 update merge request[project id: 8810053, iid: 3944, commit_id: b9f22d6c8120be7f376b6bf4189697b6e4a9dcc1] virtual merging success
Zzhengkai成员
7月30日 推送  1 个提交:551abe8b-[Profiling]fix
Zzhengkai成员
7月30日 update merge request[project id: 8810053, iid: 3944, commit_id: 40a618fc3ebf006df26ec8a549e7bbab29f90684] virtual merging success
Zzhengkai成员
7月30日 update merge request[project id: 8810053, iid: 3944, commit_id: 189fd03fa7a50e2150fa8a6ab68dea8127415364] virtual merging success
Zzhengkai成员
7月30日 推送  1 个提交:f6c373ce-[Profiling]fix build
Zzhengkai成员
7月30日 update merge request[project id: 8810053, iid: 3944, commit_id: cf1f8089107ee5993f7998b1543f78a172befdb1] virtual merging success
zhengkai成员
7月30日 评论:

compile

likedislike
Zzhengkai成员
7月30日 update merge request[project id: 8810053, iid: 3944, commit_id: e102e20c60509865ffa6ae9d8c39865f3c6b542f] virtual merging success
CANN-robotCANN-robot成员
7月30日 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
7月30日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月30日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
Zzhengkai成员
7月30日 解决了最后一个问题
CANN-robot
CANN-robot成员
7月30日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robotCANN-robot成员
7月30日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
7月30日 添加了label:ci-pipeline-passed
Zzhengkai成员
7月30日 修改标题为 “[Profiling]【fix】:适配驱动不同分支、不同形态修改aicpu通道采集频率”,原标题为“【PR】: 简要描述”
Zzhengkai成员
7月30日 修改标题为 “[Profiling]【fix】:兼容驱动不同分支、不同形态修改aicpu通道采集频率”,原标题为“[Profiling]【fix】:适配驱动不同分支、不同形态修改aicpu通道采集频率”
Zzhengkai成员
7月30日 修改了pull request 的描述
liulun0308成员
7月30日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
7月30日 添加了label:approved
houyanbao成员
7月30日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
7月30日 添加了label:lgtm
CANN-robotCANN-robot成员
7月30日 合入了pull request