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. |
|
__DAV_CUBE__ |
- |
Isolates Cube-side code. |
|
__DAV_VEC__ |
- |
Isolates Vector-side code. |
|
__NPU_ARCH__ |
- |
Distinguishes between device-side and host-side code, while isolating code for different architectures on the device side. |
|
AI processor Model |
__NPU_ARCH__ |
|---|---|
|
Atlas 350 Accelerator Card |
3510 |
|
|
2201 |
|
|
2201 |
|
|
3002 |
|
|
2002 |
|
|
1001 |
Note:
- Tightly coupled cores (CUBE and VEC not separated): The compiler defines both __DAV_CUBE__ and __DAV_VEC__.
- Loosely coupled cores (CUBE and VEC separated): The compiler defines __DAV_CUBE__ when compiling CUBE and __DAV_VEC__ when compiling VEC.
- CUBE-only cores: Only __DAV_CUBE__ is defined.
- VECTOR-only cores: Only __DAV_VEC__ is defined.
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.