AI Engine Simulator - 2023.2 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
Release Date
2023.2 English

The AMD Versal™ adaptive SoC AI Engine multithreaded simulator (aiesimulator) includes the modeling of the global memory (DDR memory) and the network on chip (NoC) in addition to the AI Engine array. When the application is compiled using the simulation target, the AI Engine multithreaded simulator can be invoked as follows.

aiesimulator –-pkg-dir=./Work

This will run the simulator in multithreaded mode. The number of threads used is based on the number of core available on the machine. The calculation for setting the default number of threads is based on the cores available on the machine and the number of core tiles used in the AI Engine design.

You can also manually configure the number of threads to use. The total number of threads available on a machine is equal to the number of cores available on the machine multiplied by the number of threads supported per core.

  • Total threads available on the machine = Number of cores on the machine * Threads per core
You can manually configure the number of threads to be used if your machine does not support an adequate number of cores, and you want to run the simulation with a limited number of threads. This can be done by setting the MTMAXTHREADS=<n> option in the sim_opts.txt file, where n is the number of threads.
aiesimulator --pkg-dir=./Work -f <sim_opts.txt>
The sim_opts.txt contains:
Note: AMD strongly recommends that you do not assign all available threads to the simulation

The various configuration and binary files are generated by the AI Engine compiler under the Work directory (see Compiling an AI Engine Graph Application) and specified using the --pkg-dir option to the simulator. The graph is initialized, run, and terminated by a control thread specified in the main application. The AI Engine compiler compiles that control thread with a PS IP wrapper to be directly loaded into the simulator.

By default, the option specifies a graph that runs forever. The AI Engine compiler generates code to execute the data flow graph in a perpetual While loop, thus simulation also runs perpetually. To create terminating programs for debugging, specify<number_of_iterations>) in your graph code to limit the execution for the specified number of iterations. The specified number of iterations can be any positive integer value.

Note: graph::run(-1) specifies a graph that runs forever.

The AI Engine simulator command first configures the simulator as specified in the compiler generated Work/config/scsim_config.json file. This includes loading PL IP blocks and their connections, configuring I/O data file drivers, and configuring the NoC and global memory (DDR memory) connections. It then executes the specified PS application and finally exits the simulator.

The AI Engine simulator has an optional --profile option, which enables printfs in kernel code to appear on the console, and also generates profile information. Also, the --dump-vcd <filename> option generates a value change dump (VCD) for the duration of the simulation. The --simulation-cycle-timeout <number-of-cycles> can be used to exit the simulation after a given number of clock cycles.

Important: If you do not provide either the clock cycles or the number of runs to, the simulation runs forever. You need to press Ctrl+c twice to exit the simulator.
Tip: You might observe cycle count differences between simulation runs on the same design. This is because the simulator waits for a few seconds for all pending transactions (such as DMA) to finish. During this wait time, the simulator process is still ticking but can be context-switched by the OS and total cycles can be different for each run. To ensure that the total cycles are the same for each run, you should use the AI Engine simulator --simulation-cycle-timeout option to stop the simulator on the exact cycle. The total cycles that appear on the profiling report are same on each run.
Note: Do not include <iostream> in the kernel code to enable printfs. The use of #include <iostream> in the kernel code results in a compilation error for both the x86 simulator and the aiesimulator simulators.

Graphs and Sub-Graphs Simulation Run Times

On an AI Engine design consisting of a larger graph composed of smaller sub-graphs, it is recommended to simulate the individual sub graphs first. Once the sub-graphs are verified and meet requirements in terms of functionality and performance, simulation of the larger graph can be attempted. Typically, depending on the size of the sub graphs, simulation time for the larger graph might take longer.