用户需要了解代码执行具体情况时,可使用thread step-over命令使用示例逐行执行以进行单步调试,或执行step in命令可进入函数内部进行调试,或可执行finish(step out)命令返回函数调用点的下一行继续调试。
算子编译时,使用--cce-ignore-always-inline=true的编译选项。
(msdebug) r // 运行
Process 177943 launched: '${INSTALL_DIR}/projects/mix/matmul_leakyrelu.fatbin' (aarch64)
[Launch of Kernel matmul_leakyrelu_custom on Device 1]
Process 177943 stopped
[Switching to focus on Kernel matmul_leakyrelu_custom, CoreId 44, Type aiv]
* thread #1, name = 'matmul_leakyrel', stop reason = breakpoint 1.2
frame #0: 0x000000000000f01c device_debugdata`_ZN17MatmulLeakyKernelIDhDhffE10CalcOffsetEiiRK11TCubeTilingRiS4_S4_S4__mix_aiv(this=0x0000000000217b60, blockIdx=0, usedCoreNum=2, tiling=0x0000000000217e28, offsetA=0x00000000002175c8, offsetB=0x00000000002175c4, offsetC=0x00000000002175c0, offsetBias=0x00000000002175bc) at matmul_leakyrelu_kernel.cpp:129:15
126
127 offsetA = mCoreIndx * tiling.Ka * tiling.singleCoreM;
128 offsetB = nCoreIndx * tiling.singleCoreN;
-> 129 offsetC = mCoreIndx * tiling.N * tiling.singleCoreM + nCoreIndx * tiling.singleCoreN; //断点位置
130 offsetBias = nCoreIndx * tiling.singleCoreN;
131 }
132
(msdebug)
(msdebug) n Process 177943 stopped [Switching to focus on Kernel matmul_leakyrelu_custom, CoreId 44, Type aiv] * thread #1, name = 'matmul_leakyrel', stop reason = step over // 通过回显可查看pc的位置,表示单步成功 frame #0: 0x000000000000f048 device_debugdata`_ZN17MatmulLeakyKernelIDhDhffE10CalcOffsetEiiRK11TCubeTilingRiS4_S4_S4__mix_aiv(this=0x0000000000217b60, blockIdx=0, usedCoreNum=2, tiling=0x0000000000217e28, offsetA=0x00000000002175c8, offsetB=0x00000000002175c4, offsetC=0x00000000002175c0, offsetBias=0x00000000002175bc) at matmul_leakyrelu_kernel.cpp:130:18 127 offsetA = mCoreIndx * tiling.Ka * tiling.singleCoreM; 128 offsetB = nCoreIndx * tiling.singleCoreN; 129 offsetC = mCoreIndx * tiling.N * tiling.singleCoreM + nCoreIndx * tiling.singleCoreN; -> 130 offsetBias = nCoreIndx * tiling.singleCoreN; 131 }
(msdebug) ascend info cores CoreId Type Device Stream Task Block PC stop reason 12 aic 1 3 0 0 0x12c0c00f03b0 breakpoint 1.2 * 44 aiv 1 3 0 0 0x12c0c00f8048 step over //* 代表当前正在运行的核 45 aiv 1 3 0 0 0x12c0c00f801c breakpoint 1.2
(msdebug) q Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] y
(msdebug) r // 运行
Process 180938 launched: '${INSTALL_DIR}/test/mstt/sample/normal_sample/mix/matmul_leakyrelu.fatbin' (aarch64)
[Launch of Kernel matmul_leakyrelu_custom on Device 1]
Process 180938 stopped
[Switching to focus on Kernel matmul_leakyrelu_custom, CoreId 46, Type aiv]
* thread #1, name = 'matmul_leakyrel', stop reason = breakpoint 1.1
frame #0: 0x000000000000e948 device_debugdata`_ZN17MatmulLeakyKernelIDhDhffE7ProcessEPN7AscendC5TPipeE_mix_aiv(this=0x000000000021fb60, pipe=0x000000000021f6a8) at matmul_leakyrelu_kernel.cpp:83:9
80 while (matmulObj.template Iterate<true>()) {
81 MatmulCompute();
82 LeakyReluCompute();
-> 83 CopyOut(computeRound);
84 computeRound++;
85 }
86 matmulObj.End();
(msdebug) s Process 180938 stopped [Switching to focus on Kernel matmul_leakyrelu_custom, CoreId 46, Type aiv] * thread #1, name = 'matmul_leakyrel', stop reason = step in frame #0: 0x000000000000febc device_debugdata`_ZN17MatmulLeakyKernelIDhDhffE7CopyOutEj_mix_aiv(this=0x000000000021fb60, count=0) at matmul_leakyrelu_kernel.cpp:106:5 103 template <typename aType, typename bType, typename cType, typename biasType> 104 __aicore__ inline void MatmulLeakyKernel<aType, bType, cType, biasType>::CopyOut(uint32_t count) 105 { -> 106 reluOutQueue_.DeQue<cType>(); 107 const uint32_t roundM = tiling.singleCoreM / tiling.baseM; 108 const uint32_t roundN = tiling.singleCoreN / tiling.baseN; 109 uint32_t startOffset = (count % roundM * tiling.baseM * tiling.N + count / roundM * tiling.baseN);
(msdebug) ascend info cores CoreId Type Device Stream Task Block PC stop reason 13 aic 1 3 0 0 0x12c0c00f1f88 breakpoint 1.1 * 46 aiv 1 3 0 0 0x12c0c00f8ebc step in //*代表当前正在运行的核 47 aiv 1 3 0 0 0x12c0c00f8d3c breakpoint 1.1
当前核的停止原因既有调试函数又有断点时,将展示为breakpoint。
(msdebug) finish Process 180938 stopped [Switching to focus on Kernel matmul_leakyrelu_custom, CoreId 46, Type aiv] * thread #1, name = 'matmul_leakyrel', stop reason = step out frame #0: 0x000000000000e950 device_debugdata`_ZN17MatmulLeakyKernelIDhDhffE7ProcessEPN7AscendC5TPipeE_mix_aiv(this=0x000000000021fb60, pipe=0x000000000021f6a8) at matmul_leakyrelu_kernel.cpp:84:21 81 MatmulCompute(); 82 LeakyReluCompute(); 83 CopyOut(computeRound); -> 84 computeRound++; 85 } 86 matmulObj.End(); 87 }