Enabling Full Check¶
To enable full check, add the corresponding compilation options to the operator code during compilation and recompile the operator. The configuration locations of compilation options vary in different operator projects. The following uses Template Library Scenario, Kernel Launch Symbol Scenario, msOpGen Operator Project Compilation Scenario, and Triton Operator Calling Scenario as examples.
1. Template Library Scenario¶
Modify the examples/CMakeLists.txt file in the template library and add the -g --cce-enable-sanitizer compilation option.
2. Kernel Launch Symbol Scenario¶
-
For details about the sample project code, see the LAddKernelInvocationk code example. Run the following command to download the sample code of the branch version:
[!NOTE]NOTE
> This sample project does not support the Atlas A3 training products, Atlas A3 inference products, and Ascend 950 products. -
To compile the operator code, add the following compilation options:
-g--cce-enable-sanitizeror--sanitizer
Edit the
cmake/npu/CMakeLists.txtfile in the sample project directory by referring to the complete sample of kernel function development and running verification.The
--cce-enable-sanitizeror--sanitizeroption is added to enable exception check.The
-goption is added to enable the compiler to generate location information. The specific location of the exception (file name, line number, and call stack) will be output in the exception report.[!NOTE]NOTE
- --If both--cce-enable-sanitizerand-O0are enabled, the--cce-ignore-always-inline=falsecompilation option needs to be added. - The-gcompilation option will add debugging information to the generated binary file. You are advised to restrict the access permission of user programs with debugging information to ensure that only authorized personnel can access the binary file. - The operator binary file generated by adding the--cce-enable-sanitizercompilation option must be used together with the msSanitizer tool. You are not advised to use this binary file independently. Otherwise, unpredictable problems may occur. - Due to the restrictions of the llvm-symbolizer open-source software, the call stack exception information may fail to be obtained. In this case, you can run the check command again to obtain the exception information about the call stack. - Currently, the Ascend 950 products do not support the--cce-enable-sanitizer,--sanitizer, and-O0compilation options. After the-gcompilation option is added to the kernel, if there is exception information in the operator, the tool displays the call stack information corresponding to the exception information. -
Add
target_link_optionsin the linking phase.-
Edit the
cmake/npu/CMakeLists.txtfile in the sample project directory. -
Edit the
cmake/Modules/CMakeCCEInformation.cmakefile in the sample project directory.
-
-
To enable the msSanitizer tool, load the executable file
_<kernel\_name>__npuon the NPU. For details about how to obtain the file, see "Kernel Launch Operator Development" > "Kernel Launch" in Ascend C Operator Development Guide.
3. msOpGen Operator Project Compilation Scenario¶
-
Click AddCustom Code Example and run the
install.shscript in the${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunchdirectory to generate a custom operator project.[!NOTE]NOTE
When downloading the code sample, run the following command to specify the branch version: -
Switch to the custom operator project directory.
-
Edit the
op_kernel/CMakeLists.txtfile in the sample project directory and add the-sanitizeroption to the compilation options. For details, see "Operator Compilation and Deployment" > "Custom Compilation Options" in MindStudio Ops Generator User Guide.
4. Triton Operator Calling Scenario¶
The Triton operator is developed in Python and the kernel is compiled in just-in-time (JIT) mode. Before executing the operator script, configure the following environment variable to support full check: