跳转至

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.

set(BISHENG_COMPILER_OPTIONS -g --cce-enable-sanitizer)

2. Kernel Launch Symbol Scenario

  1. 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:

    git clone https://gitee.com/ascend/samples.git -b 8.0.RC2
    

    [!NOTE]NOTE
    > This sample project does not support the Atlas A3 training products, Atlas A3 inference products, and Ascend 950 products.

  2. To compile the operator code, add the following compilation options:

    • -g
    • --cce-enable-sanitizer or --sanitizer

    Edit the cmake/npu/CMakeLists.txt file in the sample project directory by referring to the complete sample of kernel function development and running verification.

    target_compile_options(${smoke_testcase}_npu PRIVATE
                        -O2
                        -std=c++17
                        --cce-enable-sanitizer
                        -g
    )
    

    The --cce-enable-sanitizer or --sanitizer option is added to enable exception check.

    The -g option 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-sanitizer and -O0 are enabled, the --cce-ignore-always-inline=false compilation option needs to be added. - The -g compilation 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-sanitizer compilation 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 -O0 compilation options. After the -g compilation 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.

  3. Add target_link_options in the linking phase.

    • Edit the cmake/npu/CMakeLists.txt file in the sample project directory.

      target_link_options(${smoke_testcase}_npu PRIVATE
          --cce-fatobj-link
          --cce-enable-sanitizer
      )
      
    • Edit the cmake/Modules/CMakeCCEInformation.cmake file in the sample project directory.

      if(NOT CMAKE_CCE_LINK_EXECUTABLE)
      set(CMAKE_CCE_LINK_EXECUTABLE
          "<CMAKE_CCE_COMPILER> ${CMAKE_LIBRARY_CREATE_CCE_FLAGS} ${_CMAKE_COMPILE_AS_CCE_FLAG} <FLAGS> <CMAKE_CCE_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICIT_LINKS}")
      endif()
      
  4. To enable the msSanitizer tool, load the executable file _<kernel\_name>__npu on 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

  1. Click AddCustom Code Example and run the install.sh script in the ${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch directory to generate a custom operator project.

    [!NOTE]NOTE
    When downloading the code sample, run the following command to specify the branch version:

    git clone https://gitee.com/ascend/samples.git -b master  
    
    bash install.sh -v Ascendxxxyy    # xxxyy indicates the type of the chip used by the user.
    
  2. Switch to the custom operator project directory.

    cd CustomOp
    
  3. Edit the op_kernel/CMakeLists.txt file in the sample project directory and add the -sanitizer option to the compilation options. For details, see "Operator Compilation and Deployment" > "Custom Compilation Options" in MindStudio Ops Generator User Guide.

add_ops_compile_options(ALL OPTIONS -sanitizer)

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:

export TRITON_ENABLE_SANITIZER=1