Preprocessor Considerations - 2023.2 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
Release Date
2023.2 English

When running the AI Engine compiler with a target of x86sim the compiler ignores the --Xchess option. 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 using 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");
    printf("Default Mode\n");

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

aiecompiler -target=hw -Xchess="example_kernel:-DSIM"

Because the -Xchess argument is ignored when the compilation target is set to x86sim, SIM is not defined for the x86 simulator case and the output of the kernel is Default Mode.

If you need to specify preprocessor options with the x86 simulator you can do so using aiecompiler -target=x86sim --Xpreproc instead of -Xchess. It is important to note that any options passed in this manner applies to all source code and all target flows.

Table 1. AI Engine Compiler Command Line Options
Option Description

Can be used to pass kernel specific options to the CHESS compiler that is used to compile 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.

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