已合并
refactor: 重构kernel编译配置体系,将配置从JSON/INI迁移至CMake声明式函数 #3010
songkai111创建于 5月28日
refactor: 重构kernel编译配置体系,将配置从JSON/INI迁移至CMake声明式函数 #3010
已合并
songkai111创建于 5月28日
songkai111成员
5月28日

描述

本 PR 重构了 kernel 二进制编译的配置管理体系,将原来分散在 ascendc_config.json*_simplified_key.iniall_ops_impl_mode.ini 等文件中的编译配置项(simplified_key_mode、impl_mode、auto_sync、compile_options)统一迁移为 CMake 声明式函数 add_kernel_sources() 的方式管理。

改动原因

原有配置方式需要手动维护多处配置文件(JSON/INI),容易遗漏且难以追溯配置来源。通过将配置下沉到各算子目录的 op_kernel/CMakeLists.txt 中,使配置与代码就近维护,降低出错概率。

改动方法

  1. 新增 add_kernel_sources() CMake 函数cmake/func.cmake):算子通过在 op_kernel/CMakeLists.txt 中调用此函数声明编译参数(COMPUTE_UNITS、SIMPLIFIED_KEY、AUTO_SYNC、IMPL_MODE、OPTIONS),函数将配置收集到 CMake CACHE 变量列表中
  2. 新增 gen_ops_compile_ini.py 脚本:在编译阶段将 CMake 收集的配置列表生成 kernel-options-{soc_version}.ini 文件
  3. 修改 build_binary_opc_gen_task.sh:优先从新生成的 kernel-options-*.ini 读取 simplified_key 和 impl_mode 配置,找不到时降级到原有 ini 文件
  4. 修改 gen_compile_option.sh:优先从 kernel-options-*.ini 读取 auto_sync 和 compile_options,降级到 ascendc_config.json
  5. 迁移 Add 算子配置:将 Add 算子从 ascendc_config.json 迁移到 math/add/op_kernel/CMakeLists.txt,删除 math/add/op_host/config/ascend950/add_simplified_key.ini
  6. 重构 get_op_type_from_op_name 函数:从 gen_ops_info.cmake 移至 func.cmake,简化参数签名(移除 OP_DIR 参数)
  7. 其他修复opp_uninstall.sh 修复变量名拼写错误(_module_apth_module_path);gen_binary_info_config.py 将 WARNING 日志降级为 INFO

关联的Issue

  • #1730

测试

  • Add 算子的 kernel 编译配置已通过新的 CMake 方式验证
  • 构建系统全量编译通过
  • binary 编译流程(asc_opc)使用新配置文件生成的参数正确

文档更新

类型标签

  • Bug修复
  • 新特性
  • 性能优化
  • 文档更新
  • 其他,请描述:构建系统重构

Related Roadmap: https://gitcode.com/cann/ops-math/issues/1258

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 songkai111 的贡献)
Ssongkai111成员
5月28日 创建了 pull request,commit 5036cae4
CANN-robot
CANN-robot成员
5月28日 评论:

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
math/add 张磊, 王林木 (2/2) 张磊, 王林木 (2/1)
repo-cann/ops-math 张磊, 王林木 (2/2) 张磊, 王林木 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

songkai111, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
5月28日 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
5月28日 将FelixTang7,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zhangyuxiang0119,llimwang,gubaocheng设为评审人
CANN-robotCANN-robot成员
5月28日 将FelixTang7,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zhangyuxiang0119,llimwang,gubaocheng设为审查人
Ssongkai111成员
5月28日 update merge request[project id: 7649531, iid: 3010, commit_id: 217819fe4d94288fe059af4d0b5ae2a346debd94] virtual merging success
Ssongkai111成员
5月28日 推送  1 个提交:8a034f8d-fix: 修复 get_op_type_from_op_name 调用问题
Ssongkai111成员
5月28日 update merge request[project id: 7649531, iid: 3010, commit_id: 1c63b5a226d8c7e0daa767b606485e713ea795c4] virtual merging success
CANN-robot
CANN-robot成员
5月28日 评论:

The repo or branch is not access to PR-cooperate, please check the current repo https://gitcode.com/cann/ops-math.git, branch=master

likedislike
CANN-robotCANN-robot成员
5月28日 添加了label:stat/needs-squash
CANN-robot
CANN-robot成员
5月28日 评论:

The repo or branch is not access to PR-cooperate, please check the current repo https://gitcode.com/cann/ops-math.git, branch=master

likedislike
songkai111成员
5月29日 评论:

compile

likedislike
Ssongkai111成员
5月29日 update merge request[project id: 7649531, iid: 3010, commit_id: 4f418564dec0e277b24a36e2e42ea4acd1debfde] virtual merging success
CANN-robotCANN-robot成员
5月29日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
5月29日 评论:

流水线任务触发成功
任务链接 [087ca0dcadb248d8bfb5edffda582af1][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-05-29 09:57:31]    CI执行结束

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

流水线任务触发成功
任务链接 [1799802e6d5744649f1dfa0b76a0c786][流水线指导]

任务名称状态日志下载链接
codecheck ❌ FAILED
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Pr ✅ 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 ✅ SUCCESS >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>
likedislike
CANN-robotCANN-robot成员
5月29日 添加了label:api-check-pass
CANN-robotCANN-robot成员
5月29日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
5月29日 添加了label:ci-pipeline-failed
Ssongkai111成员
5月29日 update merge request[project id: 7649531, iid: 3010, commit_id: 3f553ced12cd5d8cf20830f7305db042ee64f694] virtual merging success
Ssongkai111成员
5月29日 强制推送  1 个提交:ac5b39ef-fix: 修复 get_op_type_from_op_name 调用问题
Ssongkai111成员
5月29日 update merge request[project id: 7649531, iid: 3010, commit_id: ffee09b0b3eee8880344c2d88fa608bc927ee3b2] virtual merging success
CANN-robot
CANN-robot成员
5月29日 评论:

The repo or branch is not access to PR-cooperate, please check the current repo https://gitcode.com/cann/ops-math.git, branch=master

likedislike
Ssongkai111成员
5月29日 update merge request[project id: 7649531, iid: 3010, commit_id: 05b53062a2afc1898147a6ab0573846d81d92d1b] virtual merging success
Ssongkai111成员
5月29日 强制推送  1 个提交:766cf22d-fix: 修复 get_op_type_from_op_name 调用问题
Ssongkai111成员
5月29日 update merge request[project id: 7649531, iid: 3010, commit_id: 53ca3ac6cf5d7a6c6bb1fef40b2774a3457554da] virtual merging success
CANN-robot
CANN-robot成员
5月29日 评论:

The repo or branch is not access to PR-cooperate, please check the current repo https://gitcode.com/cann/ops-math.git, branch=master

likedislike
Ssongkai111成员
5月30日 修改标题为 “refactor: 重构kernel编译配置体系,将配置从JSON/INI迁移至CMake声明式函数”,原标题为“kernel编译配置项变更”
Ssongkai111成员
5月30日 修改了pull request 的描述
songkai111成员
5月30日 评论:

compile

likedislike
Ssongkai111成员
5月30日 update merge request[project id: 7649531, iid: 3010, commit_id: 92dc0ade5813b48d13c5bbf541af80537e8f1892] virtual merging success
CANN-robotCANN-robot成员
5月30日 删除了label:ci-pipeline-failedapi-check-pass
CANN-robotCANN-robot成员
5月30日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
5月30日 评论:

流水线任务触发成功
任务链接 [94d1e27f2f4a4a35835e5b16131771bd][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_harmony-infer ✅ SUCCESS >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>

[2026-05-30 10:59:59]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
5月30日 评论:

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

任务名称状态日志下载链接
codecheck ✅ SUCCESS
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
codecheck_Pr ✅ 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 ✅ SUCCESS >>>>>
codecheck_precommit ⚠️ WARNING >>>>> >>>>>

[2026-05-30 10:54:16]    CI执行结束

likedislike
CANN-robotCANN-robot成员
5月30日 添加了label:api-check-pass
CANN-robotCANN-robot成员
5月30日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
5月30日 添加了label:ci-pipeline-passed
RuiWang_成员5月30日进行代码检视1
cmake/variables.cmake
@@ -32,2 +32,4 @@
3232set(COMPILED_OP_DIRS CACHE STRING "Compiled Ops Dirs" FORCE)
3333 
34+# kernel compile options
35+set(simplified_key_list CACHE STRING "kernel compile simplified key list" FORCE)
RuiWang_5月30日评论:

CMAKE全局变量一般使用全大写

likedislike
zl_hw成员
5月30日 评论:

/lgtm
/approve

likedislike
llimwang成员
5月30日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
5月30日 添加了label:lgtmapproved
CANN-robot
CANN-robot成员
5月30日 评论:

The MR can not be merged, because of CodeReview discussion not resolved

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
RuiWang_成员
5月30日 评论:

/lgtm

likedislike
RRuiWang_成员
5月30日 解决了最后一个问题
CANN-robotCANN-robot成员
5月30日 关闭了关联的issue
CANN-robotCANN-robot成员
5月30日 合入了pull request
Ssunday成员
7月2日 修改了pull request 的描述
CANN-robotCANN-robot成员
7月2日 删除了label:ci-pipeline-passed