Macros - 2023.2 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
UG1076
Release Date
2023-12-04
Version
2023.2 English

AMD provides several predefined compiler macros to help using the x86 simulator. In your top level graph test bench (usually called graph.cpp) it can be useful to use the following pre-processor macros with a conditional #if to help 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 used in the AI Engine simulator only and __X86SIM__ is applicable for the x86 simulator.

The previous example shows the __X86SIM__ macro surrounding the main() which is used by a graph.cpp file. This main() must be excluded from emulation flows and these macros provide that flexibility. Additionally, consider using the __X86SIM__ macro to selectively enable debug instrumentation only during x86 simulation.