Simulating an AI Engine Graph Application - 2023.1 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
UG1076
Release Date
2023-06-23
Version
2023.1 English

This chapter describes the various execution targets available to simulate AI Engine applications at different levels of abstraction, accuracy, and speed. AI Engine graphs can be simulated in four different simulation environments.

The x86 simulator is a fast-functional simulator as described in x86 Functional Simulator. It should be used to functionally simulate your AI Engine graph and is useful for functional development and verification of kernels and graphs. It, however, does not provide timing, resource, or performance information.

The AI Engine simulator (aiesimulator) models the timing and resources of the AI Engine array, while using transaction-level SystemC models for the NoC, DDR memory. This allows for faster performance analysis of your AI Engine applications and accurate estimation of the AI Engine resource use, with cycle-approximate timing information.

In both x86 functional simulator and AI Engine simulator, PL interface to AI Engine can be exercised through untimed external traffic. Similarly, both use the user graph’s main() function as C-test bench to configure and control the AI Engine. This test bench data input and output is not timed, and the user graph’s main() function acts as a virtual simulation platform.

Tip: In addition to using the x86 functional simulator and AI Engine simulator, it is possible to test the AI Engine graph on a VCK190 board using the precompiled AI Engine test harness. This test harness is designed to provide a very simple and natural transition from the AI Engine simulation environment to testing on hardware. With the test harness, AI Engine graphs running in simulation can be taken to hardware in just a few minutes and with only a few minor modifications. More details about the AI Engine test harness can be found here: https://xilinx.github.io/AI-Engine-Test-Harness/

When you want a fast functional simulation of the entire system including the AI Engine graph, the PL logic along with XRT-based host application to control the AI Engine and PL, you should use the AMD Vitis™ software emulation flow. The software emulation flow enables using HLS-based kernels or C-models of RTL based kernels to be interfaced with AI Engine graph and controlled using host code which can also be run on hardware. This flow includes the x86 functional model of the AI Engine and the PS. The x86 functional model of the PS is the default model in the software emulation flow. The Arm QEMU model is available as an alternative model for the PS as well.

Finally, when you are ready to simulate the entire system including AI Engine graph and PL logic along with XRT-based host application to control the AI Engine and PL, for a specific board and platform, you should use the Vitis hardware emulation flow. This flow includes the SystemC model of the AI Engine, transaction-level SystemC models for the NoC, DDR memory, PL Kernels (RTL), and PS (running on QEMU). You can also include RTL logic and test bench PL logic for your platform or design.

The following table lists the four simulation flows and whether they support functional or performance level debug, and the level of support for source code debug. It also recommends the usage of these simulation flows in appropriate stages of your AI Engine design development.

Table 1. Simulation Flows
Design Development Stage Simulation Tool Flow Source Level Debug Simulation Debug Type
AI Engine kernel and graph debug x86 Simulator Yes AI Engine Functional Debug
AI Engine graph performance debug AI Engine Simulator Allows stepping through the AI Engine compiler generated assembly code which aids in code optimization, however, source level visibility could be limited due to compiler optimization AI Engine Performance Analysis and Debug
System level simulation and functional debug Vitis Software Emulation Yes System Functional Debug
System level simulation and performance debug Vitis Hardware Emulation Possible—however, provides limited source level visibility due to compiler optimization System Performance Analysis and Debug

Simulation Models

The following table lists the simulation flows and recommends the usage of these simulation flows in appropriate stages of your AI Engine design development and the type of simulation model used for the various AMD Versal™ architecture domains. The type of simulation model and the simulation tool flow used determine the accuracy of the simulation results.

Table 2. Simulation Models
Simulation Tool Flow AI Engine Kernels PL Kernels PL I/O Support PL Platform NoC/DDR Model PS Model
x86 Simulator x86 threads N/A File IOs/External Traffic generators N/A N/A N/A
AI Engine Simulator SystemC N/A File IOs/External Traffic generators N/A SystemC N/A
Vitis Software Emulation x86 threads C/SystemC PL Kernels/External Traffic generators N/A N/A x86 (default) QEMU (optional)
Vitis Hardware Emulation SystemC SystemC/RTL/HLS-C PL Kernels/External Traffic generators RTL/SystemC SystemC QEMU

Simulation Features

You can obtain profiling data when you run your design in aiesimulator or hardware emulation. Analyzing this data helps you gauge the efficiency of the kernels, the stall and active times associated with each AI Engine, and pinpoint the AI Engine kernel whose performance might not be optimal. This also allows you to collect data on design latency, throughput, and bandwidth. Details on running and analyzing profile data can be found in Performance Analysis of AI Engine Graph Application during Simulation.

The event trace feature allows you to capture and analyze a system-level view of program execution. It can be helpful in identifying problems during program execution including correctness and performance issues. The AI Engine architecture has direct support for generation, collection, and streaming of events as trace data during simulation and hardware emulation. Details on running and analyzing event trace data can be found in Performance Analysis of AI Engine Graph Application during Simulation.

The x86simulator and aiesimulator simulate the design via the main() function of graph.cpp. QEMU emulation support is available for host applications in software emulation and hardware emulation. Note that QEMU support is optional in software emulation. In software emulation, you can create a host application targeting Linux-XRT and emulate the host application. In hardware emulation, you can create a host application targeting Bare metal or Linux-XRT, and emulate the host application as well. Test bench data can be provided to the x86 simulator and AI Engine simulator via the graph’s main() function which acts like a virtual test bench platform. There are various levels of test bench support available for the simulation flows. Test bench data can either be file based or via an external traffic generator. Additional details on this feature can be found in Generating Traffic for Simulation and Emulation.

The data flowing between the AI Engine kernels is available and can be viewed either as data snapshot files or via the Vitis Analyzer GUI. Additional details on the x86 simulator snapshot feature can be found in Data Snapshots. Additional information on data visualization of trace data on the results of running the AI Engine simulator can be found in Trace View Data Visualization.

The following table lists the type of simulation features supported with the four simulation flows.

Table 3. Simulation Features
Simulation Tool Flow Trace Profile Application main() Test Bench Support AI Engine Data Flow Visibility
x86 Simulator No No The main() function in graph.cpp File-based/External traffic generators Yes (via the snapshot feature)
AI Engine Simulator Yes Yes The main() function in graph.cpp File-based/External traffic generators Yes (via Trace view in Vitis Analyzer)
Vitis Software Emulation No No The main() function in host application targeting Linux-XRT HLS-C/external traffic generators Yes (via the snapshot feature)
Vitis Hardware Emulation Yes Yes The main() function in host application targeting BareMetal or Linux-XRT HLS-C/RTL datamovers/external traffic generators Yes (via Trace view in Vitis Analyzer)
Note: The main function for simulation must have a return value. Otherwise, aiecompiler will error out.