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
MTMAXTHREADS=<n>
option in the sim_opts.txt file, where n
is the number of
threads.aiesimulator --pkg-dir=./Work -f <sim_opts.txt>
MTMAXTHREADS=<n>
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 graph.run()
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 graph.run(<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.
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.
graph.run()
, the simulation runs forever. You need to
press Ctrl+c twice to exit the
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.<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.