TRACE_STOP

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

Function Usage

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 end point. This API is used together with TRACE_START.

This function is mainly used for debugging and performance analysis. Enabling this function will affect the operator performance. This function is usually used in the debugging 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 by using the following method:

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

Prototype

1
2
#define TRACE_STOP(TraceId apid)
#define TRACE_STOP(pipe_t pipe, TraceId apid)// This API supports only Atlas 350 Accelerator Card.

Parameters

Parameter

Input/Output

Description

apid

Input

The value must be the same as that of TRACE_START. Otherwise, the logging result is affected.

pipe

Input

The value must be the same as that of TRACE_START. Otherwise, the logging result is affected.

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 logging function can be enabled only in kernel launch projects and is not supported in custom operator projects.

Examples

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

1
2
3
TRACE_START(0x1);
DataCopy(zGm, zLocal, this->totalLength);
TRACE_STOP(0x1);