Pull Request已成功合入, 合并人@CANN-robot
(感谢 liyonghong 的贡献)变更摘要
本次 PR 新增了 Ascend 驱动设备管理相关的示例代码与批量运行脚本。核心内容是设备 P2P(Peer-to-Peer)直连互通的示例程序,演示了通过 ascend_hal 接口查询设备数量、SOC 版本、物理 ID,以及检测、启用和禁用设备间 P2P 通信的完整流程。同时提供了配套的构建运行脚本和统一的示例批量执行框架。
主要改动
- 新增 P2P 设备互通示例
main.c:实现了完整的设备管理示例流程,依次调用drvGetDevNum、drvGetDevIDs、halGetSocVersion查询设备基础信息,再通过drvDeviceGetPhyIdByIndex获取物理 ID,调用halDeviceCanAccessPeer检测 P2P 可达性,并在可访问时依次执行halDeviceEnableP2P和halDeviceDisableP2P完成 P2P 的启用与禁用验证。 - 新增示例构建运行脚本
run.sh:从/etc/ascend_install.info读取驱动安装路径,设置相关库路径环境变量,使用cmake构建示例并执行,同时将输出重定向到output_msg.txt并通过PIPESTATUS捕获主程序的退出码。 - 新增批量示例运行框架
run_all_examples.sh:定义了RUN_TARGETS数组来管理各示例的运行状态,通过run_one_script函数统一执行每个示例脚本并收集结果,最终输出 PASS/FAIL 汇总和成功/失败计数,当前已激活devmng/0_device_p2p/run.sh作为首个批量运行目标。


代码审查
Closing Summary
| 文件 | 审查结果 |
|---|---|
examples/devmng/0_device_p2p/CMakeLists.txt |
无问题 |
examples/devmng/0_device_p2p/main.c |
3 个问题(P2 × 2, P3 × 1) |
examples/devmng/0_device_p2p/run.sh |
3 个问题(P2 × 2, P3 × 1) |
examples/run_all_examples.sh |
3 个问题(P2 × 2, P3 × 1) |
总计:9 个发现(P2 × 6, P3 × 3),P0 × 0,P1 × 0。
整体风险判断:中等风险。main.c 的格式化字符串不匹配(%d vs unsigned int)属于未定义行为,但触发概率低(仅在单设备场景输出日志时触发)。run.sh 中 cmake 和 source 退出码未检查会导致失败时根因被掩盖,但最终会通过下游步骤失败间接暴露。run_all_examples.sh 中 cd 失败未处理及 cp 前缺少 mkdir -p 在首次部署或异常环境下会直接导致脚本失败。所有问题均为新增代码引入,无已有代码的回归。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 5 |
💬 仅评论


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


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.


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