Merged
feat(machine): Support ASCEND_RT_LAUNCH_BLOCKING for AICPU scheduling blocking #5823
wan_jianfenAdd on Aug 31
feat(machine): Support ASCEND_RT_LAUNCH_BLOCKING for AICPU scheduling blocking #5823
Merged
Merged fromwan_jianfen/pyptobr_blockingintocann/pyptomaster
Pull Request has been successfully merged by CANN-robot.
(Thank you for wan_jianfen's contribution.)Aug 31 Created pull request, commit 10fe44c5
atomgit-bot
Aug 31 Comments:
Aug 31 Comments:
变更摘要
本 PR 主要聚焦于 launch blocking(启动阻塞)能力:新增 AclRtNoBlockingLaunchBegin/AclRtNoBlockingLaunchEnd 运行时接口,并在非 capture 模式下用其包裹 AICore 与 AICPU 内核启动;同时将 DevicePerf 的性能数据初始化改为首次使用时懒加载,并为分配/拷贝失败引入错误码返回与错误日志;DeviceLauncher::SetDevPerfAddr 相应改为返回错误码并向上传递;此外调整了 LaunchAicpuKernel 的调度顺序,并让 AICore 打印由 ENABLE_AICORE_PRINT 编译开关控制。
主要改动
- 新增无阻塞启动接口:在
acl_api.h/acl_api.cpp中新增AclRtNoBlockingLaunchBegin/AclRtNoBlockingLaunchEnd,通过AdapterManager查找并调用运行时适配函数;同时在runtime_adapter_types.h的RuntimeFunc枚举中增加NoBlockingLaunchBegin/NoBlockingLaunchEnd,并映射到aclrtNoBlockingLaunchBeginImpl/aclrtNoBlockingLaunchEndImpl。 - 内核启动包裹 begin/end 调用:
DeviceLauncher::LaunchAicoreKernel与LoadAicpuOp::LaunchWithHostArgs在非 capture 模式下,分别用AclRtNoBlockingLaunchBegin/AclRtNoBlockingLaunchEnd包裹RuntimeKernelLaunchWithHandleV2与RuntimeLaunchKernelWithHostArgs。 - 性能数据懒初始化与错误传播:
DevicePerf::InitPerfData/SetDebugEnable改为返回错误码,perfData_的内存分配延迟到首次SetDebugEnable(由g_isInitPerfData控制),malloc/memcpy 失败时记录错误日志并返回;DeviceLauncher::SetDevPerfAddr返回值由void改为int,LaunchBundleKernelOnce检查其返回值,LaunchKernel对失败进行断言。 - 调整 AICPU 内核启动顺序:
DeviceLauncher::LaunchAicpuKernel将PyptoRun(sche 流)的启动提前到 ctrl 流之前,并在IsAicoreResolveEnabled()时提前返回。 - AICore 打印按编译开关控制:
DeviceDfx::Init仅在ENABLE_AICORE_PRINT开启时初始化 AICore 打印,LaunchAicoreKernel中的同步条件也由该编译期常量控制;相关 UT(test_device_launcher_host.cpp、test_device_launcher_npu.cpp、test_device_runner.cpp)同步适配了sharedBuffer的赋值与清理。


Incorrect?
atomgit-bot
Aug 31 Comments:
Aug 31 Comments:
Aug 31 Added label: stat/needs-squash
Aug 31 Added label: cann-cla/yes
94 messages are collapsed here。 See more
CANN-robot
Sep 3 Comments:
Sep 3 Comments:
The following labels are not ready.
lgtm: Please wait for committers to review the code.
approved: Please wait for committers to review the code.


lidongsheng
Sep 3 Comments:
Sep 3 Comments:
/approve


Sep 3 Added label: lgtmapproved
Sep 3 Closed associated issue
Sep 3 Merged pull request
修改意图
支持通过环境变量
ASCEND_RT_LAUNCH_BLOCKING=1控制 AICPU 调度流阻塞下发,用于调试和时序问题排查场景。修改内容
1. Adapter 层新增 API 加载
AclRtNoBlockingLaunchBegin/End:从libruntime.so加载aclrtNoBlockingLaunchBeginImpl/EndImpl(libascendcl.so未导出这两个符号,实际实现位于libruntime.so)AclRtSetStreamAttribute:从libascendcl.so加载aclrtSetStreamAttribute2. 运行时阻塞控制
common.h新增IsLaunchBlockingEnabled(),读取ASCEND_RT_LAUNCH_BLOCKING环境变量(static 缓存)device_launcher.cpp中LaunchKernel:当!IsCaptureMode() && IsLaunchBlockingEnabled()时,用AclRtNoBlockingLaunchBegin/End包裹 sche stream 上的 AICPU 调度下发3. ST 测试用例
test_blocking_launch.py,通过 spawn 子进程在import torch前继承环境变量验证功能改动文件
framework/src/adapter/api/acl_api.cpp/acl_api.hAclRtSetStreamAttribute、AclRtNoBlockingLaunchBegin/End实现framework/src/adapter/manager/types/acl_adapter_types.hRtSetStreamAttribute枚举与符号映射framework/src/adapter/manager/types/runtime_adapter_types.hNoBlockingLaunchBegin/End枚举,映射到aclrtNoBlockingLaunchBeginImpl/EndImplframework/src/adapter/stubs/acl_stubs.cpp/acl_stubs.hStubRtSetStreamAttributestubframework/src/interface/utils/common.hIsLaunchBlockingEnabled()framework/src/machine/runtime/launcher/device_launcher.cppLaunchKernel中接入阻塞下发控制python/tests/st/test_blocking_launch.py验证
ASCEND_RT_LAUNCH_BLOCKING=1时:sche stream 非阻塞下发Related Issue: #3188