msdebug是用于调试在NPU侧运行的算子程序的一个工具,该工具向算子开发人员提供了在昇腾设备上调试算子的手段。调试手段包括了读写昇腾设备内存与寄存器、暂停与恢复程序运行状态等。
./Ascend-hdk-<chip_type>-npu-driver_<version>_linux-<arch>.run --debug
通过NPU侧可执行文件<kernel_name>_npu或调用算子的python脚本,msdebug工具支持调试Ascend C算子(包括Vector、Cube以及mix融合算子)程序。目前已经支持的功能如下表:
功能 |
链接 |
---|---|
断点设置 |
|
打印变量和内存 |
|
核切换 |
|
调试信息展示 |
命令 |
命令缩写 |
描述 |
示例 |
---|---|---|---|
breakpoint set -f filename -l linenum |
b |
增加断点,filename为算子实现代码文件*.cpp,linenum为代码文件对应的具体行号。 |
b add_custom.cpp:85 |
run |
r |
运行程序。 |
r |
continue |
c |
继续运行。 |
c |
print variable |
p |
打印变量。 |
p zLocal |
frame variable |
var |
显示当前作用域内的所有局部变量。 |
var |
memory read |
x |
读内存。 |
x -m GM -f float16[] 0x00001240c0037000 -c 2 -s 128
|
ascend info devices |
- |
查询device信息。 |
ascend info devices |
ascend info cores |
- |
查询算子所运行的aicore相关信息。 |
ascend info cores |
ascend info tasks |
- |
查询算子所运行的task相关信息。 |
ascend info tasks |
ascend info blocks |
- |
查询算子所运行的block相关信息。 |
显示所运行的blocks相关信息:
ascend info blocks 显示所运行的blocks在当前中断处的代码:
ascend info blocks -d |
ascend info stream |
- |
查询算子所运行的stream相关信息。 |
ascend info stream |
ascend aic id |
- |
切换调试器所聚焦的cube核。 |
ascend aic 1 |
ascend aiv id |
- |
切换调试器所聚焦的vector核。 |
ascend aiv 5 |
target modules add <kernel.o> |
image add [kernel.o] |
导入算子调试信息 。 说明:
当程序执行run命令后,需先执行image add命令导入调试信息。然后,再执行image load命令使导入的调试信息生效。 |
image add xx.o |
target modules load --file <kernel.o> --slide <address> |
image load -f <kernel.o> -s <address> |
加载算子调试信息,使导入的调试信息生效。 |
image load -f xx.o -s 0 |
help msdebug_command |
- |
输出对应工具命令的帮助信息。 |
help run |