TRACE_START

Supported Products

Product

Supported/Unsupported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference product's AI Core

Atlas inference product's Vector Core

x

Atlas training products

Functions

Performs logging in any running phase of the operator when the CAModel is used for operator performance simulation. This helps to analyze the pipelines of different instructions for further performance optimization.

Indicates logging from the start point. This API is used together with TRACE_STOP.

This function is mainly used for debugging and performance analysis. After this function is enabled, the operator performance is affected. This function is usually used in the commissioning phase. You are advised to disable this function in the production environment.

By default, this function is disabled. You can enable the logging function as required.

Modify the npu_lib.cmake file in the CMake directory of the kernel direct debugging project and add the -DASCENDC_TRACE_ON compilation option to the ascendc_compile_definitions command to enable the dotting function. The following is an example:
1
2
3
4
// Enable the dotting function of the operator.
ascendc_compile_definitions(ascendc_kernels_${RUN_MODE} PRIVATE
    -DASCENDC_TRACE_ON
)

Prototype

1
#define TRACE_START(TraceId apid)

Parameters

Parameter

Input/Output

Description

apid

Input

Currently, the following 10 user-defined types are reserved:

  • 0x0: USER_DEFINE_0
  • 0x1: USER_DEFINE_1
  • 0x2: USER_DEFINE_2
  • 0x3: USER_DEFINE_3
  • 0x4: USER_DEFINE_4
  • 0x5: USER_DEFINE_5
  • 0x6: USER_DEFINE_6
  • 0x7: USER_DEFINE_7
  • 0x8: USER_DEFINE_8
  • 0x9: USER_DEFINE_9

Returns

None

Restrictions

  • TRACE_START and TRACE_STOP must be used together. If no log is displayed on the trace chart, they are not paired.
  • This API cannot be used across cores. For example, if TRACE_START is logged in the AI Cube, TRACE_STOP must also be recorded in the AI Cube instead of the AI Vector.
  • This macro supports all product models. However, the actual product models must be the same as those supported by the debugging tool.
  • The dotting function can be enabled only in the kernel direct debugging project. It cannot be enabled in the custom operator project.

Examples

Add TRACE_START and TRACE_STOP to the specific instruction position in the kernel code.

1
2
3
TRACE_START(0x2);
Add(zLocal, xLocal, yLocal, dataSize);
TRACE_STOP(0x2);