Pull Request已成功合入, 合并人@CANN-robot
(感谢 yiming 的贡献)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 |
|---|---|---|
| docs | ✅ munanhw, 苏建加, XuebinYang (3/2) | ✅ munanhw (1/1) |
| examples | ✅ munanhw, XuebinYang, 苏建加 (3/2) | ✅ munanhw (1/1) |
| impl/c_api | ✅ pangfd, XuebinYang, 苏建加 (3/2) | ✅ pangfd (1/1) |
| include/c_api | ✅ wuzhaolin, XuebinYang, 苏建加 (3/2) | ✅ wuzhaolin (1/1) |
| include/c_api/reg_compute | ✅ XuebinYang, horming, 苏建加 (3/2) | ✅ horming (1/1) |
| repo-cann/asc-devkit | ✅ XuebinYang, 苏建加 (2/2) | ✅ XuebinYang (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
yiming0671, thanks for your pull request. All authors of the commits have signed the CLA. 👍


变更摘要
本 PR 将 5 个上游 PR(#3113、#3637、#3602、#3443、#3723)通过 cherry-pick 合入 9.1.0 分支,主要涉及 A5(npu_arch_3510)新增 C API 实现、A3(npu_arch_2201)bug 修复、API 参数重命名以与文档一致、头文件相对路径修正,以及测试用例的补充与重构。
主要改动
-
A5 新增 Cube 计算控制 API:新增
asc_enable_hf32、asc_enable_hf32_trans、asc_set_fp32_mode、asc_enable_hif8、asc_enable_fp8、asc_set_mmad_direction_m、asc_set_mmad_direction_n及对应的*_impl实现文件,用于控制 3510 架构的 Cube 计算精度和布局模式。 -
A5 新增通用数据搬运 API:新增
asc_copy_gm2ub/asc_copy_ub2gm的void*类型简化接口(仅需 size 参数),以及为asc_copy_gm2ub_align/asc_copy_ub2gm_align增加 size-only 重载版本,降低用户调用复杂度。 -
新增跨核同步原语:在 2201 和 3510 架构下新增
asc_sync_inter_arrive、asc_sync_subblock_arrive宏(底层调用ffts_cross_core_sync)以及asc_sync_subblock_wait宏,扩展了 block 间/子 block 间的同步能力。 -
A3 Cube 控制 API Bug 修复:修正了
asc_set_mmad_direction_m_impl(由sbitset1改为sbitset0)和asc_set_mmad_direction_n_impl(由sbitset0改为sbitset1)的位操作错误,并将asc_enable_hf32_trans_impl重构为使用sbitset1/sbitset0辅助函数替代手动位掩码。 -
API 参数重命名以对齐文档:将
asc_copy_l12l0a_trans/asc_copy_l12l0b_trans系列接口中的addrmode重命名为enable_addr_decrement,asc_copy_gm2ub_align/asc_copy_ub2gm_align中的src_gap/dst_gap重命名为src_stride/dst_stride,同步修正所有声明与实现及测试宏中的参数名。


流水线任务触发成功
任务链接 [b9e94eac522a427da574051f9f150d68][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck | ✅ SUCCESS | >>>>> | |
| codecheck_Pr | ✅ SUCCESS | ||
| pre_comment | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_codestyle | ⚠️ WARNING | >>>>> | |
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
[2026-06-29 15:13:48] CI执行结束


流水线任务触发成功
任务链接 [23a5140d2ac1408c82b4f855b8af411a][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| UT_Test_adv_test_one | ✅ SUCCESS | ||
| UT_Test_adv_test_two | ✅ SUCCESS | ||
| UT_Test_basic_test_one | ✅ SUCCESS | ||
| UT_Test_basic_test_two | ✅ SUCCESS | ||
| UT_Test_basic_test_three | ✅ SUCCESS | ||
| UT_Test_basic_test_four | ✅ SUCCESS | ||
| UT_Test_basic_test_five | ✅ SUCCESS | ||
| UT_Test_arm | ✅ SUCCESS | ||
| UT_Test_report | ✅ SUCCESS | >>>>> |
[2026-06-29 15:22:01] CI执行结束


代码审查
Closing Summary
已审查全部 118 个变更文件。结论如下:
按优先级统计:
- P0: 0
- P1: 0
- P2: 2
- P3: 1
审查结果:
| 文件分类 | 文件数 | 审查结果 |
|---|---|---|
| 文档 (Markdown) | ~40 | 无问题 — API 文档新增/更新/结构调整 |
| 配置文件 (JSON) | 1 | 无问题 — 生成文件,已加入 .gitignore |
| 示例代码 (.asc) | 4 | 无问题 — 格式化调整 + 移除冗余类型转换 |
| 实现头文件 (2201) | 7 | 已审查 — sync arrive 存在 P3 隐式缩窄 |
| 实现头文件 (3510) | 23 | 已审查 — 无新增问题 |
| 公开 API 头文件 | 6 | 已审查 — 声明与实现一致 |
| 测试文件 | 20 | 2 个 P2 问题(见下) |
| 测试工具/桩文件 | 3 | 已审查 — 无问题 |
| .gitignore | 1 | 无问题 |
P2 发现:
-
test_asc_create_iter_reg.cpp:移除了 AIC (Cube) 模式下vag_bxx不应被调用的测试覆盖。旧的TEST_VECTOR_COMPUTE_CREATE_ITER_REG_CUBE宏验证了times(0),新代码不再测试此路径。若if ASC_IS_AIV守卫被误删,AIC 路径将错误调用硬件 intrinsic,且无测试会发现。 -
test_enable_hf32.cpp:与同类的test_enable_hif8.cpp、test_set_fp32_mode.cpp不一致,该测试未 mocksbitset1且不验证写入 control register 的位值。asc_enable_hf32()的实现依赖sbitset1(get_ctrl(), 46),但测试仅验证了get_ctrl和set_ctrl被调用,未验证中间位操作及最终写入值。
P3 发现:
asc_sync_inter_arrive_impl.h/asc_sync_subblock_arrive_impl.h(4 个文件):GetfftsConfigInterArrive和GetfftsConfigSubBlockArrive参数为uint16_t flag_id,但调用方 API 的flag_id类型为int64_t,存在隐式缩窄转换,可能触发-Wconversion警告。
整体风险判断:中低 — 无 P0/P1 的生产缺陷。P2 问题均为测试质量问题,不影响运行时行为。此 backport 合入合理。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 3 |
💬 仅评论


🟡 Medium Priority
在掩码寄存器连续非对齐搬出的调用示例(新增)中,第154行使用了 asc_update_src_b16(remain_count) 来准备源操作数。但在整个代码库(include/ 和 impl/ 目录)中均未找到 asc_update_src_b16 的定义。用户若照搬此示例代码将遇到编译错误(未定义标识符),导致文档的指导价值受损。
触发条件:用户复制粘贴该示例代码进行编译时。
建议:将 asc_update_src_b16 替换为实际存在的函数名,或补充该函数的声明和文档,或在注释中标注该行为示意代码(需用户自行实现)。


🟡 Medium Priority
The test test_enable_hf32.cpp (npu_arch_3510) verifies asc_enable_hf32() by only mocking get_ctrl and set_ctrl. It does NOT mock sbitset1 and does NOT verify which value is written to the control register. Compare with the analogous test_enable_hif8.cpp which mocks sbitset1 with precise bit-position verification, and test_set_fp32_mode.cpp which mocks sbitset0 similarly.
The implementation asc_enable_hf32_impl() sets bit 46 via sbitset1(get_ctrl(), HF32_MODE_BIT). Without mocking sbitset1, the test cannot verify:
- that
set_ctrlreceives the expected result
If sbitset1 is called as a real function during the test (rather than being intercepted by mockcpp), the test might pass even if the bit position is wrong, since set_ctrl is mocked to accept any value via MOCKER_CPP(set_ctrl, void(uint64_t)).times(1).
Changed lines: 28-35 — the test body lacks MOCKER_CPP(sbitset1, ...) and the stubs for sbitset1 / set_ctrl value verification.
建议:Add sbitset1 mock with bit-position verification, and add a set_ctrl stub that verifies the expected value, consistent with test_enable_hif8.cpp:


🟡 Medium Priority
The old test code (test_asc_create_iter_reg.cpp, lines 43-69 in the old version) included TEST_VECTOR_COMPUTE_CREATE_ITER_REG_CUBE tests that set g_coreType = C_API_AIC_TYPE in SetUp and verified that vag_b32/vag_b16/vag_b8 were called zero times (.times(0)). This validated that when ASC_IS_AIC is true, the implementation correctly returns iter_reg{} without calling the hardware intrinsic.
The new code replaces this with TEST_CREATE_ITER_REG_AIV which does NOT set g_coreType (defaulting to AIV) and only tests the AIV path. The AIC path where vag_bxx must NOT be called is now untested. If the if ASC_IS_AIV guard is accidentally removed, the AIC path would incorrectly call vag_bxx and no test would catch it.
Changed lines: entire file rewrite, the old TEST_VECTOR_COMPUTE_CREATE_ITER_REG_CUBE macro and its three instantiations (lines 43-69 old) were removed without replacement.
建议:Add back AIC mode tests. Either: (1) add a macro similar to the old TEST_VECTOR_COMPUTE_CREATE_ITER_REG_CUBE that sets g_coreType = C_API_AIC_TYPE and mocks vag_bxx with .times(0), or (2) add a second macro parameter to the existing TEST_CREATE_ITER_REG_AIV to optionally set coreType and expected call count, so both paths are covered.


/lgtm


/lgtm
/approve


描述
Backport the following PRs to 9.1.0 via cherry-pick:
Cherry-pick order: 3113 → 3637 → 3602 → 3443 → 3723
关联的Issue
测试
文档更新
类型标签