Macros - 2025.2 English - UG1076

AI Engine Tools and Flows User Guide (UG1076)

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

AMD provides several predefined compiler macros to help using the x86 simulator. In your top level graph test bench (usually graph.cpp) it is useful to use the following pre-processor macros with a conditional #if. Using these macros helps include or exclude appropriate code.

Table 1. Macros
Macro Description
__X86SIM__ Use this predefined macro to designate code that is applicable only for the x86sim flow.
__AIESIM__ Use this predefined macro to designate code that is applicable only for the aiesimulator flow.

X86SIM_KERNEL_NAME

Use this macro with printf() to tag instrumentation text with the kernel instance name.
Note: For macros surrounded with underscores _ there are two underscore characters at the front and behind.

The following is an example of the macro code.

myAIEgraph g;
#if defined(__AIESIM__) || defined(__X86SIM__)
int main()
{
   g.init();
   g.run(4);
   g.end();
   return 0;
}
#endif
Tip: The __AIESIM__ macro is applicable to the AI Engine simulator only. __X86SIM__ is applicable to the x86 simulator.

In the previous example, the __X86SIM__ macro surrounds main() which the graph.cpp file uses. You must exclude main() from emulation flows, and these macros provide that flexibility. Additionally, consider using the __X86SIM__ macro to selectively enable debug instrumentation only during x86 simulation.