Stack Frame Size Exceeds the Upper Limit When msDebug Uses -O0 -g to Compile Operators

Symptom

The following error information is displayed:

1
2
3
error: stack frame size (16024) exceeds limit (16000) in function '_ZN7AscendC9ReduceSumIDhEEvRKNS_11LocalTensorIT_EES5_S5_i'
error: stack frame size (16024) exceeds limit (16000) in function '_ZN7AscendC9ReduceSumIDhEEvRKNS_11LocalTensorIT_EES5_S5_i'
2 errors generated.

Solution

This error occurs if the stack space used by the kernel function is too large and exceeds the hardware limit. You can use either of the following methods to solve the problem:

  • Manually add the --cce-ignore-always-inline=true compilation option to remove the inline attribute set during the declaration of Ascend C-related functions so that the functions can run properly and the stack space used can be reduced.
  • Update the compiler version. When the compilation option is -O0 -g, the compiler automatically enables --cce-ignore-always-inline=true.

    You can run the ccec -v command to query the compiler version. You are advised to use the compiler of 2024-07 or later.