Merged
fix(machine): Split runtime headers and use secure bundle functions #6422
fix(machine): Split runtime headers and use secure bundle functions #6422
Merged
W4termyAdd on Sep 17
W4termy
W4termyCollaborators
Sep 17
cleancode
超大头文件、不安全函数修改
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for W4termy's contribution.)
W4termyW4termyCollaborators
Sep 17 Created pull request, commit 4359cf42
W4termyW4termyCollaborators
Sep 17 Associated issue: [Task|任务跟踪]: Machine Cleancode告警清理
atomgit-bot
atomgit-bot
Sep 17 Comments:

变更摘要

本 PR 主要对 machine 模块进行两方面的重构:一是拆分运行时头文件,将原本内联在 wrap_manager.h 与 dev_encode_function.h 中的枚举、位图操作等内联函数抽取到独立的新头文件 wrap_task_utils.h 与 dev_encode_function_bitmap.h 中,原文件改为通过 #include 引入并仅保留声明;二是将 bundle 相关代码中的 std::memcpy、std::snprintf 等替换为安全版本 MemcpyS、snprintf_s,并补充断言与失败日志,提升内存拷贝与格式化操作的安全性。

主要改动

  • 抽取 wrap 任务工具函数到新头文件:在新增的 wrap_task_utils.h 中定义 MixResourceType、DieId 枚举及 WrapInfoQueueLock、WrapInfoQueueUnLock、GetTaskNumByMixResType、IsWrapTaskReady 等内联函数,wrap_manager.h 删除原内联定义并改为包含该头文件。
  • 拆分 DevAscendFunction 位图操作:将 IsDeadEndHub、IsTailTask、ClearTailTask、ClearDeadEndHub、PropagateDeadHubClear、GetBitmapByteSize、BackupBitmapTo、RestoreBitmapFrom 等内联位图函数从 dev_encode_function.h 移入新增的 dev_encode_function_bitmap.h,原头文件保留声明并在末尾包含新头文件。
  • bundle 加载/打包改用安全内存拷贝:kernel_bundle_loader.cpp 与 kernel_bundle_packer.cpp 将 std::memcpy 替换为 MemcpyS,并新增对 machine/runtime/runner/runtime_utils.h 的引用。
  • AICPU 操作名格式化改用安全函数:kernel_bundle_launch.cpp 将 std::snprintf 替换为 snprintf_s,并通过 MACHINE_ASSERT 对格式化返回值进行校验,失败时输出 [kernel-bundle] 相关错误日志。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 17 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 17 Added label: cann-cla/yes
W4termy
W4termyCollaborators
Sep 17 Comments:

compile

likedislike
CANN-robot
CANN-robotCollaborators
Sep 17 Comments:

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
framework/src/machine ✅ gaoxingwang, jason_yuan_ye (2/2) ✅ jason_yuan_ye (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robotCollaborators
Sep 17 Comments:

CLA Signature Pass

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

likedislike
W4termyW4termyCollaborators
Sep 17 Pre merge succeeded (commit_id: 0fc4902ffba86989abc0da86d3d49691fc68958c)
CANN-robotCANN-robotCollaborators
Sep 17 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 17 Set jason_yuan_ye,yinjie27_,tsungl4,gaoxingwang,linjiashu as approver
W4termyW4termyCollaborators
Sep 17 Modify description of pull request
CANN-robot
CANN-robotCollaborators
Sep 17 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 17 Added label: ci-pipeline-running
7 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Sep 17 Added label: cann-cla/yes
W4termy
W4termyCollaborators
Sep 17 Comments:

compile

likedislike
W4termyW4termyCollaborators
Sep 17 Pre merge succeeded (commit_id: a6a783b704449e8e7b7223cdd6eec4be4350cf3b)
CANN-robot
CANN-robotCollaborators
Sep 17 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 17 Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
Sep 17 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 17 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 17 Added label: ci-pipeline-passed
W4termyW4termyCollaborators
Sep 17 Change title to "fix(machine): Split runtime headers and use secure bundle functions", originally titled "refactor(machine): split runtime headers and use secure bundle functions".
gaoxingwang
gaoxingwangCollaborators
Sep 17 Comments:

/lgtm

likedislike
袁野
袁野Collaborators
Sep 17 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 17 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Sep 17 Merged pull request