Pull Request has been successfully merged by CANN-robot.
(Thank you for zhongyu's contribution.)变更摘要
此 PR 为 CCU 资源管理引入了动态资源申请能力。在 CANN 9.1.0+ 环境下,新流程支持算子按需创建 CcuIns 并绑定到通信域,首算子根据"算子诉求与 1/5 资源量取最大"的原则申请资源,后续算子复用已有 CcuIns 并校验资源容量是否充足;资源不足或旧版 hcomm 包时自动回退到原有预分配流程。为此新增了 HcommCcuInsResDescCreate 等 8 个动态资源接口的弱符号声明与支持标记,以及对应的类型回退定义。
主要改动
-
新增动态 CCU 资源接口层:在
ccu_res_dl.h/ccu_res_dl.cc中声明并定义了HcommCcuInsResDescCreate、HcommCcuInsResDescDestroy、HcommCcuInsResDescSetNum、HcommCcuInsResDescQueryNum、HcommCcuInsCreate、HcommCcuInsDestroy、HcommCcuInsQueryResDesc、HcommCcuKernelQueryResReq共 8 个弱符号函数及对应支持标记,用于运行时检测新接口可用性;同时在hccl_ccu_res_dl.h/hccl_ccu_res_dl.cc中新增HcclCommAssignCcuIns弱符号及支持标记。 -
新增类型回退定义文件:添加
ccu_res_defs_dl.h,在旧版 hcomm 包缺少ccu_res_defs.h时,提供本地 fallback 的HcommCcuResDescHandle类型(uint64_t)和HcommCcuResType枚举(涵盖 Loop、CCU Buffer、Variable、Address、Event、CCU Thread、Instruction 七种资源类型)。 -
实现动态资源申请新流程:在
op_common.cc中新增HcclGetCcuKernelDynamic函数,实现三步逻辑——调用CalcKernelsAggregatedResReq按 resGroup 聚合所有 kernel 资源诉求(同 group 相加、跨 group 取最大);查询通信域现有CcuIns,若存在则调用IsResCapSufficient逐项比较资源容量是否满足诉求;若为首算子则通过CalcMaxResReqWithDefault取 max(算子诉求, 1/5 固定资源量) 后调用HcommCcuInsCreate创建新实例并HcclCommAssignCcuIns绑定。 -
重构
HcclGetCcuKernel入口:原函数改为根据IsCcuDynamicResApiSupported检测结果分流——新接口全部可用时走HcclGetCcuKernelDynamic动态流程,否则回退到旧有的通信域预分配 + 直接 queryinsHandle模式;同时将原有 kernel 注册逻辑抽取为RegisterCcuKernels供新旧流程复用,并移除了CCU_E_UNAVAIL的分散处理,统一由上层判断回退。


代码审查
Based on my thorough review of all 6 changed files, I find the diff to be well-implemented. The dynamic CCU resource allocation logic is correct, resource cleanup is comprehensive on all code paths, and the fallback behavior (HCCL_E_UNAVAIL) is properly preserved throughout. The RegisterCcuKernels function correctly reuses the extracted kernel registration logic, and the CCU_E_UNAVAIL → HCCL_E_UNAVAIL conversion via ConvertCcuToHccl ensures the old fallback contract is maintained. No correctness, security, reliability, or breaking-change issues were identified.
Closing Summary
| Priority | Count |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 0 |
| P3 | 0 |
Per-file review confirmation:
src/common/hcomm_dlsym/ccu/ccu_res_defs_dl.h— reviewed, no issuessrc/common/hcomm_dlsym/ccu_res_dl.cc— reviewed, no issuessrc/common/hcomm_dlsym/ccu_res_dl.h— reviewed, no issuessrc/common/hcomm_dlsym/hccl_ccu_res_dl.cc— reviewed, no issuessrc/common/hcomm_dlsym/hccl_ccu_res_dl.h— reviewed, no issuessrc/ops/op_common/op_common.cc— reviewed, no issues
Overall risk judgment: 低风险。变更结构清晰,资源管理完整,回退路径正确保留,新增的动态资源申请流程与旧流程隔离良好。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


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 |
|---|---|---|
| src | ✅ chengym, chenyia (2/2) | ✅ chengym (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhongyu1, thanks for your pull request. All authors of the commits have signed the CLA. 👍


代码审查
审查总结
逐文件确认
| 文件 | 审查结果 |
|---|---|
src/common/hcomm_dlsym/ccu/ccu_res_defs_dl.h |
✅ 无问题 |
src/common/hcomm_dlsym/ccu_res_dl.cc |
✅ 无问题 |
src/common/hcomm_dlsym/ccu_res_dl.h |
✅ 无问题 |
src/common/hcomm_dlsym/hccl_ccu_res_dl.cc |
✅ 无问题 |
src/common/hcomm_dlsym/hccl_ccu_res_dl.h |
✅ 无问题 |
src/ops/op_common/inc/alg_param.h |
✅ 无问题 |
src/ops/op_common/op_common.cc |
⚠️ 1 个 P3 问题 |
src/ops/op_common/op_common.h |
✅ 无问题 |
按优先级统计
- P0: 0
- P1: 0
- P2: 0
- P3: 1
上一轮审查问题回查
上一轮的三个资源泄漏问题均已修复:
BuildAggregatedResReq中HcommCcuInsResDescCreate失败时已通过DestroyAllDescs(reqDescs)清理 ✅- 同上(重复问题)✅
HcclGetCcuKernelDynamic中BuildAggregatedResReq失败时已通过DestroyAllDescs(reqDescs)防御性清理 ✅
整体风险评估
低风险。本次改动整体质量较高:新增的 CCU 动态资源申请流程设计清晰,资源生命周期管理(DestroyAllDescs、RAII 风格的句柄销毁)严谨;头文件类型定义与 dlsym 弱符号声明一致;上一轮审查的资源泄漏问题全部修复。唯一发现的问题是 RegisterCcuKernels 共享函数中对 CCU_E_UNAVAIL 的日志级别从 WARNING 变为 ERROR —— 返回值语义不变、回退行为不变,仅影响旧路径的可观测性,属于低优先级的回归。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


/lgtm


/approve


描述
关联的Issue
测试
文档更新
类型标签