已合并
PR#3113-3723合入9.1.0分支 #3737
PR#3113-3723合入9.1.0分支 #3737
已合并
yiming创建于 6月29日
yiming成员
6月29日

描述

Backport the following PRs to 9.1.0 via cherry-pick:

PR Commit Description
#3113 1381a851c 新增/修改部分 A5/A3 的 c_api 实现
#3637 fd1098bf6 fix: 头文件相对路径修改
#3602 1ee235ad3 A5copy 接口文档修正
#3443 be11b347e A3/A5 sync 同步接口更新及 copy_l0c2gm 定义修复
#3723 4efa9bd1dd fix: sync_block_wait 参数名称与文档一致(MR head,master 待合入)

Cherry-pick order: 3113 → 3637 → 3602 → 3443 → 3723

关联的Issue

测试

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 yiming 的贡献)
Yyiming成员
6月29日 创建了 pull request,commit 17d3c198
CANN-robotCANN-robot成员
6月29日 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
6月29日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月29日 评论:

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

likedislike
yiming成员
6月29日 评论:

/compile

likedislike
Yyiming成员
6月29日 预合并成功(commit_id: 37f5caccdac65a21a66e008184e1ba01dd99835f)
atomgit-bot
atomgit-bot
6月29日 评论:

变更摘要

本 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,同步修正所有声明与实现及测试宏中的参数名。

likedislike
不准确?
yiming成员
6月29日 评论:

/compile

likedislike
CANN-robotCANN-robot成员
6月29日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月29日 评论:

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

likedislike
CANN-robot
CANN-robot成员
6月29日 评论:

流水线任务触发成功
任务链接 [0e4672fb8f30423ebd1a3c726c9178a4][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
PreSmoke_A900_npupool ✅ SUCCESS >>>>>

[2026-06-29 15:12:51]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
6月29日 评论:

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

likedislike
atomgit-bot
atomgit-bot
6月29日 评论:

代码审查

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 发现:

  1. 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,且无测试会发现。

  2. test_enable_hf32.cpp:与同类的 test_enable_hif8.cpp、test_set_fp32_mode.cpp 不一致,该测试未 mock sbitset1 且不验证写入 control register 的位值。asc_enable_hf32() 的实现依赖 sbitset1(get_ctrl(), 46),但测试仅验证了 get_ctrl 和 set_ctrl 被调用,未验证中间位操作及最终写入值。

P3 发现:

  1. 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

💬 仅评论

likedislike
不准确?
atomgit-bot
atomgit-bot6月29日进行代码检视1
docs/api/SIMD-API/C-API/Reg矢量计算/reg_store/asc_storeunalign_postupdate.md
@@ -147,0 +151,4 @@
151+ uint32_t repeat = 2;
152+ for (uint32_t i = 0; i < repeat; i++) {
153+ // 准备本次待搬出的src
154+ src = asc_update_src_b16(remain_count);
atomgit-bot
atomgit-bot6月29日评论:

🟡 Medium Priority

在掩码寄存器连续非对齐搬出的调用示例(新增)中,第154行使用了 asc_update_src_b16(remain_count) 来准备源操作数。但在整个代码库(include/ 和 impl/ 目录)中均未找到 asc_update_src_b16 的定义。用户若照搬此示例代码将遇到编译错误(未定义标识符),导致文档的指导价值受损。

触发条件:用户复制粘贴该示例代码进行编译时。

建议:将 asc_update_src_b16 替换为实际存在的函数名,或补充该函数的声明和文档,或在注释中标注该行为示意代码(需用户自行实现)。

likedislike
不准确?
atomgit-bot
atomgit-bot6月29日进行代码检视1
tests/api/c_api/npu_arch_3510/cube_compute/test_enable_hf32.cpp
@@ -0,0 +32,4 @@
32+ MOCKER_CPP(set_ctrl, void(uint64_t)).times(1);
33+ 
34+ asc_enable_hf32();
35+ GlobalMockObject::verify();
atomgit-bot
atomgit-bot6月29日评论:

🟡 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_ctrl receives 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:

likedislike
不准确?
atomgit-bot
atomgit-bot6月29日进行代码检视1
tests/api/c_api/npu_arch_3510/vector_compute/test_asc_create_iter_reg.cpp
@@ -70,0 +97,4 @@
97+TEST_CREATE_ITER_REG_AIV(b16, vag_b16)
98+TEST_CREATE_ITER_REG_AIV(b32, vag_b32)
99+ 
100+#undef TEST_CREATE_ITER_REG_AIV
atomgit-bot
atomgit-bot6月29日评论:

🟡 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.

likedislike
不准确?
CANN-robotCANN-robot成员
6月29日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月29日 添加了label:ci-pipeline-passed
Yyiming成员
6月29日 解决了最后一个问题
munanhw成员
6月29日 评论:

/approve

likedislike
horming成员
6月29日 评论:

/approve

likedislike
pangfd成员
6月29日 评论:

/approve

likedislike
suqwe
suqwe成员
6月29日 评论:

/lgtm

likedislike
wuzhaolin成员
6月30日 评论:

/approve

likedislike
XuebinYang成员
6月30日 评论:

/lgtm
/approve

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