Compilation Options

Common compilation options are described as follows.

Table 1 Common 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 3.

Currently, only --npu-arch=dav-2201 is supported.

--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 product

    Atlas inference series 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 series products/Atlas A3 inference series products

-o <file>

No

Specifies the name and location of the output file.

-c

No

Compiles and generates the target file.

-O

No

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

-fPIC

No

Instructs the compiler to generate location-independent code.

-shared, --shared

No

Compiles and generates dynamic link libraries. For details, see Compilation, Link, and Library Usage.

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

No

Compiles and generates static link libraries. 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. For details, see Compilation, Link, and Library Usage.

--cce-auto-sync

No

Enables automatic synchronization. The execution units in the AI Core are asynchronous and parallel. The read and write operations of the LocalTensor may depend on data. You can use this option to perform automatic synchronization without manually inserting the synchronization by calling the API. For details, see Automatic Synchronization.

--cce-auto-sync-log

No

Outputs the synchronization insertion information to the <file> file by configuring --cce-auto-sync-log to <file>.

--std=c++17

No

Configures the C++ standard. This option is required for the Ascend C operator compilation which uses the C++17 standard. If the file name extension is asc, the default value of std is c++17.

-x

No

Parses and compiles the input file following this option based on the specific syntax API. The file name extension can be cce, asc, or aicpu. Ccache compilation cache acceleration is not supported. If Ccache is required, use --cce-aicore-lang instead.

--cce-aicore-lang

No

Compiles the input file following this option in CCE heterogeneous language mode. Ccache compilation cache acceleration is supported. (This option cannot be used together with -xcce.) For details about the cache acceleration effect, see the Ccache official website.

-g

No

Adds debugging information during compilation.

--sanitizer, --cce-enable-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.

Table 2 Compilation options to be deprecated

Option

Required (Yes/No)

Description

--cce-soc-version

No

This option will be deprecated in later versions. Do not use this compilation option. Use --npu-arch or --npu-soc instead.

Specifies the Ascend AI processor model. If this option is set, the related binary file will be generated.

If the AI processor model cannot be determined, run the npu-smi info command on the server where the AI processor is installed. Add the prefix Ascend to the queried Name. For example, if the value of Name is xxxyy, the actual value is Ascendxxxyy.

--cce-soc-core-type

No

This option will be deprecated in later versions. Do not use this compilation option. Use --npu-arch or --npu-soc instead.

Generates binary file of the core. The value can be VecCore, CubeCore, or AICore.

  • VecCore: written Vector code only.
  • CubeCore: written Cube code only.
  • AICore: written Vector and Cube code.
Table 3 Mapping between Ascend AI Processor models and __NPU_ARCH__

Ascend AI Processor Model

__NPU_ARCH__

Atlas A3 training series products/Atlas A3 inference series products

2201

Atlas A2 training products/Atlas A2 inference products

2201

Atlas 200I/500 A2 inference product

3002

Atlas inference series products

2002

Atlas training products

1001