Common Compilation Options

The following table describes common compilation options. For details about all compilation options, see Compilation Options.

Option

Required (Yes/No)

Description

-help

No

Displays the help information.

--npu-arch

Yes

Specifies the Ascend AI Processor architecture for compilation. The value is dav-<arch-version>, where <arch-version> indicates the NPU architecture version number. For details about the architecture version number of each product model, see Table 1.

--npu-soc

No

Specifies the Ascend AI Processor model for compilation. If both npu-soc and npu-arch are configured, npu-arch is preferentially enabled.

The Ascend AI Processor model can be obtained in the following ways:

  • For the following products: Run the npu-smi info command on the server where Ascend AI Processor is installed to obtain the Name information. The actual value is AscendName. For example, if Name is xxxyy, the actual value is Ascendxxxyy.

    Atlas A2 training products / Atlas A2 inference products

    Atlas 200I/500 A2 inference products

    Atlas inference products

    Atlas training products

  • For the following products: Run the npu-smi info -t board -i id -c chip_id command on the server where Ascend AI Processor is installed to obtain the Chip Name and NPU Name information. The actual value is Chip Name_NPU Name. For example, if the value of Chip Name is Ascendxxx and the value of NPU Name is 1234, the actual value is Ascendxxx_1234. Note that:
    • id: device ID, which is the NPU ID obtained by running the npu-smi info -l command.
    • chip_id: chip ID, which is obtained by running the npu-smi info -m command.

    Atlas A3 training products / Atlas A3 inference products

-x

No

Specifies the compilation language.

If this parameter is set to asc, the Ascend C programming language is used.

-o <file>

No

Specifies the name and location of the output file.

-c

No

Compiles and generates the target file.

-shared, --shared

No

Compiles and generates a dynamic link library.

-lib, --cce-build-static-lib

No

Compiles and generates a static link library. The compiler compiles and links the code on the device to generate a binary file on the device, uses the file as the input for compilation on the host, and links the file to generate a static link library.

-g

No

Adds debugging information during compilation.

--sanitizer

No

Adds code correctness verification information during compilation. When the sanitizer option is used, the -g option must be added and cannot be used in the -O0 scenario.

-fPIC

No

Instructs the compiler to generate location-independent code.

-O

No

Specifies the optimization level of the compiler. Currently, -O3, -O2, and -O0 are supported.