Predefined Macros and Built-in Variables

Predefined Macros

Like other language compilers, the BiSheng Compiler has some predefined macros for developers to write programs.

Predefined Macros

Default Value

Description

__CCE_IS_AICORE__

1

The value is 1 on the device, which can be used to distinguish device code from host code.

Built-in Variables

The following variables are built-in variables of the BiSheng Compiler. The variable names defined by developers in programs cannot be the same as the built-in variable names. Additionally, built-in variables are usually used by the framework and remain imperceptible to developers. To obtain the core ID or number of cores, use the corresponding Ascend C API.

Table 1 Built-in variable list

Built-in Variable

Description

block_idx

Current core ID, which is a logical value in the core and remains imperceptible to developers. The core ID used during programming can be obtained by calling GetBlockIdx.

block_num

Number of used cores, which is a logical value in the core and remains imperceptible to developers. The number of cores used for programming can be obtained by calling GetBlockNum.