Preprocessor Considerations - 2025.2 English - UG1076

AI Engine Tools and Flows User Guide (UG1076)

Document ID
UG1076
Release Date
2025-11-20
Version
2025.2 English

When running the AI Engine compiler with a target of x86sim the compiler ignores the --Xchess option. Ignoring this means that the x86sim flow does not support kernel-specific compile options.

To understand this better consider the following example. A common method of making compile-time modifications to C code is to use preprocessor directives such as #ifndef. To control these preprocessor directives it is helpful to pass #defines through the command line compiler options. The following example code block takes two different actions based on a preprocessor directive.

void example_kernel()
{
  #ifdef SIM
    printf("Simulation Mode\n");
  #else
    printf("Default Mode\n");
  #endif
}

To define the SIM macro at compile time with the AI Engine compiler targeting hardware (hw) you can do the following.

v++ -c --mode aie -target=hw -Xchess="example_kernel:-DSIM"

When you set the compilation target to x86sim, the -Xchess argument is ignored. Because the x86 simulator case does not define SIM, the output of the kernel is Default Mode.

If you need to specify preprocessor options with the x86 simulator you can do so using v++ -c --mode aie -target=x86sim --Xpreproc instead of -Xchess. Any options passed in this manner apply to all source code and all target flows.

Table 1. AI Engine Compiler Command Line Options
Option Description
--Xchess=<string>

Can be used to pass kernel-specific options to the CHESS compiler that compiles code for each AI Engine.

The option string is specified as <kernel-function>:<optionid>=<value>. This option string is included during compilation of generated source files on the AI Engine where the specified kernel function is mapped.
--Xpreproc=<string>

Pass general option to the PREPROCESSOR phase for all source code compilations (AIE/PS/PL/x86sim). For example:

--Xpreproc=-D<var>=<value>