Closed
【2026 HCCL通信库创新大赛-粤港澳赛区】【云上码术】AICPU 拓扑查询示例使用过期的 HcclRankGraphGetTopoTypeByLayer 四参数调用 #732
ivelAdd on  Jul 31Closed at  Aug 14
ivel
ivel
Jul 31 Create

Document Link(文档链接)

https://gitcode.com/cann/hcomm/blob/master/docs/zh/comm_op_dev_guide/aicpu_comm_op_dev/query_topo.md

Issues Section(问题文档片段)

当前 AICPU 拓扑查询示例先获取 topoInsts,随后以 4 个参数调用 HcclRankGraphGetTopoTypeByLayer:

uint32_t topoInstNum = 0;
uint32_t *topoInsts;
ret = HcclRankGraphGetTopoInstsByLayer(comm, 0, &topoInsts, &topoInstNum);
ret = HcclRankGraphGetTopoTypeByLayer(comm, 0, topoInsts[0], &topoInfo.topoType);

但当前公开头文件中的函数签名只有 3 个参数,不接收 topoInst:

extern HcclResult HcclRankGraphGetTopoTypeByLayer(
    HcclComm comm, uint32_t netLayer, CommTopo *topoType);

同仓库的 API 专页、头文件示例、接口实现和 UT 也均使用 3 参数调用。

Existing Issues(存在的问题)

用户直接参考当前示例时会发生编译错误:

error: no matching function for call to 'HcclRankGraphGetTopoTypeByLayer'
note: candidate function not viable: requires 3 arguments, but 4 were provided

示例中的 HcclRankGraphGetTopoInstsByLayer 结果仅用于多传的第四个实参;按当前 API 契约修正后,这段查询和相关注释均无用途,继续保留会误导开发者认为查询层级拓扑类型前必须先查询拓扑实例。

建议删除无用途的 topoInsts 查询,并改为:

ret = HcclRankGraphGetTopoTypeByLayer(comm, 0, &topoInfo.topoType);

验证信息

  • 仓库:cann/hcomm
  • 基线:e70e7ec42a775916012ed75f9766e48a4fd076c5
  • 核验日期:2026-07-31
  • 环境:macOS 26.5.2、arm64、Apple Clang、C++14 语法检查
  • 旧 4 参数调用:编译失败,明确报告“需要 3 个参数,但提供了 4 个”
  • 修正后 3 参数调用:编译通过
  • 已检索当前公开 Issue 和 PR 元数据,未发现相同问题
likedislike
ivelivel
Aug 1 Associated pull request
LeewisCollaborators
Aug 1 Comments:

同学你好,当前所提issue已收到,欢迎提交pr解决该问题;
/label add Accepted

likedislike
CANN-robotCANN-robotCollaborators
Aug 1 Added label: Accepted
LLeewisCollaborators
Aug 1 associated Kanban: HCCL
CANN-robotCANN-robotCollaborators
Aug 14 Close issue
CANN-robotCANN-robotCollaborators
Aug 14 Added label: resolved
LLeewisCollaborators
Sep 2 removed Kanban: HCCL