Versal AI Engine Development Tool Flow Explained: Enhancing Your Development Journey

In this post, we’ll explore the AMD Versal AI Engine Development Tool Flow, and how to get started programming the Versal AI Engines using the Vitis IDE. We’ll look at the interaction between Vivado, Vitis and Petalinux. Additionally, we’ll cover how to use the AI Engine Simulators to quickly develop and test your Versal AI Engine designs. This streamlined flow helps developers efficiently harness the power of AMD Versal AI Engines.

Versal AI Engine Development Tool Flow

The figure below shows how Vivado, Vitis, and Petalinux tools interact with each other. The first step is creating an extensible platform from Vivado (in the form of an .xsa file) that Vitis can later use to re-create the project in its own instance of Vivado. Vitis will use this to add features, connections, and Versal AI Engine binaries. Because Vitis is going to re-create the Vivado project, there is no need to run implementation and create a bitstream from your Vivado project before exporting the .xsa platform – Vitis is going to complete those steps for you. 

Versal AI Engine
Figure 3 1: High Level Tool Flow for AI Engine Development

Create an SDK Package

The next step is to use that .xsa platform in Petalinux to create an SDK package. This helps set up the compiler, OS environment, and other resources you will need to write code to run on the AI Engines.

Vitis Tool Flow

Now we switch to the Vitis tool. The figure below gives a graphical overview of the Vitis flow. Vitis lets us write any kind of code for Versal devices, in particular for this post, the AI Engines. We start by writing kernel code. A kernel is a program that targets the specialized vector processors in AI Engine hardware. We will write the code with C++ but using a special library and pragmas (a pragma is a compiler directive, which tells the compiler tool to modify its default behavior in some way).

The code is going to be compiled with the AI Engine compiler – a custom compiler from AMD that can make full use of the AI Engine hardware.

Vitis Tool Flow
Figure 3 2: Vitis Tool Flow

In addition to kernel code we must write graphs, captured in adf files (Adaptive Flow Graph). Graphs, also written in C++, describe how different kernels are connected to each other within the AI Engine array. We can compile multiple kernels into the AI Engine array and configure them to either work together or perform entirely separate functions with their own connections to the NOC (Network on Chip) or PL.

Versal AI Engine Compiler

The AI Engine compiler will ingest kernel code and graphs to create a libadf.a binary file. This is what will be used to program the AI Engines. The binary file is then passed back to Vitis to build the final system.

AMD Versal AI Engine
Click on the image to watch the on-demand webinar.

Simulation

All experienced engineers will know that it is irresponsible to throw untested code over the fence without testing it first, so let’s also discuss how to simulate your AI Engine code. AMD provides three main options for this step: x86simulator, aiesimulator, and Co-Simulation.

x86simulator

The x86simulator, also labeled as Emulation-SW in Vitis, allows for a functional test of the kernel code but does not compile the kernels into AIE binaries. This makes it significantly faster to run than the other simulation options but doesn’t give us any performance analysis as the simulation is not cycle accurate.

aiesimulator

The aiesimulator, also labeled as Emulation-AIE in Vitis, compiles the real binary files used to program the AI Engines and simulates with that. So more representative of what will actually happen in hardware, but more time consuming for the simulator to run. This simulation is cycle accurate, allowing users to evaluate the expected performance of their kernel code.

Vitis Hardware Emulation / co-simulation

With both x86simulator and aiesimulator options, the simulator can only run AI Engine code. It does not run PS code or simulate PL circuits. In order to truly simulate the whole system together, we would use Vitis Hardware Emulation, also called co-simulation. Co-simulation takes significantly longer to run however and can be more difficult to set up properly.

When working with Vitis, the flow can be done through the Vitis GUI, but it is also completely scriptable. It should be noted however that there are several options and settings that are only available through the scripting interface, so users will really want to script their project flow rather than completely relying on the GUI.

Conclusion

In this post we covered the basic steps to take and tools to use when developing applications using the new AI Engines and AMDs Versal devices. The learning curve to properly setup and run all these tools can be steep, but the performance boost to some applications is well worth the cost.

 

Additional Resources

Fortunately, BLT offers our Swift Launch Developer’s Kit to help clients get started much faster.

LEARN MORE: https://bltinc.com/swift-launch-developers-kit/

 

BLT also offers design services for clients that would like one of our experts to help complete your next project.

LEARN MORE: https://bltinc.com/design-services/

 

The following are some relevant documents from AMD related to developing with the Versal AI Engine:
  • AI Engine Tools and Flows User Guide (UG1076)
  • Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)
  • AI Engine Kernel and Graph Programming Guide (UG1079)
AMD Versal AI Engine Tool Flow Explained