Executing Step-by-Step Debugging
To learn about code execution details, run Example for Running the thread step-over Command line by line for step-by-step debugging, run the step in command to start debugging in a function, or run the finish command to return to the next line of the function call point for further debugging.
Prerequisite
During operator compilation, --cce-ignore-always-inline=true is enabled.
Example for Running the thread step-over Command
- Set a breakpoint to the position to be debugged and run the program. For details about how to set a breakpoint, see Setting Breakpoints.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(msdebug) r // Running 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; // Breakpoint position 130 offsetBias = nCoreIndx * tiling.singleCoreN; 131 } 132 (msdebug)
- Enter the next or n command for step-by-step execution.
1 2 3 4 5 6 7 8 9 10
(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 // If the PC location is displayed in the command output, the step-by-step execution is successful. 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 }
- Run the ascend info cores command to view the PC information and stop causes of all cores.
(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 //* indicates the running core. 45 aiv 1 3 0 0 0x12c0c00f801c breakpoint 1.2
- If the current core is stopped due to both step-by-step debugging and breakpoints, "breakpoint" is displayed.
- If the program suspends, enter CTRL+C to stop the program. The possible causes are as follows:
- The user program itself has an infinite loop, which needs to be rectified by repairing the program.
- An operator uses synchronization instructions.
- After the debugging is complete, run the q command and enter Y or y to end the debugging.
(msdebug) q Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] y
Example for Running the thread step-in and thread step-out Commands
- Set a breakpoint to the position to be debugged and run the program. For details about how to set a breakpoint, see Setting Breakpoints.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
(msdebug) r // Running 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();
- Input step in or s to call the function for debugging.
1 2 3 4 5 6 7 8 9 10 11 12
(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);
- Run the ascend info cores command to view the PC information and stop causes of all cores.
1 2 3 4 5
(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 //* indicates the running core. 47 aiv 1 3 0 0 0x12c0c00f8d3c breakpoint 1.1
If the current core is stopped due to both function debugging and breakpoints, "breakpoint" is displayed.
- After debugging the copyout function, run the finish command to exit the copyout function and return to the main program to continue execution.
1 2 3 4 5 6 7 8 9 10 11 12
(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 }
Parent topic: msDebug (Operator Debugging)