Zephyrnet Logosu

AI Engine Series 10 – AI Engine'i çalıştıran tam sistem (bölüm 2)

Tarih:


Giriş

içinde previous article of the AI Engine Series we had a look at the Vitis full system example which includes an AI Engine application.

In this new entry, we will build the system, look at some of the generated outputs and run the system in hardware emulation using QEMU.

AI Engine Application build

First open the Vitis workspace created in the önceki makale.

To make sure that the system is configured to be built for hardware emulation, open the full_system_app_system.sprj configuration file and check that the active build configuration is set to Emulation-HW.

florentw_0-1625569695320.jpeg

To build the AI Engine application, right click on the full_system_app_aie application project and click Proje Oluştur.

florentw_1-1625569695327.jpeg

If we look at the console window, we can see that the following command has been run:

aiecompiler -v -Xchess=main:darts.xargs=-nb -include="<Installation path>/Vitis/2021.1/aietools/include" include=<Installation path>/Vitis_HLS/2021.1/include" -include="../" -include="../src" -target=hw --pc-srcmapping -platform=<Platform Repo Path>/xilinx_vck190_base_202110_1/xilinx_vck190_base_202110_1.xpfm -workdir=. /Work <workspace>/full_system_app_aie/src/graph.cpp

This is the basic command to build an AI engine application for Hardware emulation. We have already looked at the options in the AI Engine Series 5 article.

When the build is complete, open the Vitis analyzer summary file by double-clicking on it (full_sysetem_app_aie/Emulation-AIE/Work/graph.aiecompile_summary).

In the graph tab we can see a view of the graph:

florentw_2-1625569695340.jpeg

We can see that the 2 kernels (interpolator and classify) represented by a white square with a blue lightning symbol are implemented in the array in 2 different tiles. We can also see the connections from the graph to the PL and from the PL to the graph.

PL kernels build

The next step is to build the C/C++ kernels which will be implemented in the Programmable Logic (PL) and connected to the AI Engine graph.

Notlar 1: in this system, all of the C/C++ kernels are connected to the AI Engine array. However, this is not a rule. Kernels are simply functions which are accelerated (i.e. implemented) in the PL, so kernels might have no connection with the AI Engine.

Notlar 2: In these examples, the AI Engine is connected to the PL using kernels. However, this is not a requirement. It is possible to connect AXI4-Stream interfaces present in the platform directly to the AI Engine (refer to bu örnek) or to connect the AI Engine to the NoC using GMIO interfaces.

To build the PL kernels, right click on the the full_system_app_kernels uygulama ve tıklayın Proje Oluştur.

florentw_3-1625569695376.jpeg

If we look in the console we can see that the following command has been run:

v++ --package --config package.cfg ../../full_system_app_aie/Emulation-AIE/libadf.a ../../full_system_app_system_hw_link/Emulation-HW/binary_container_1.xclbin -o binary_container_1.xclbin

We can see that the v++ tool is used to compile the kernels and that the output of this compilation is a .xo file. For more details about the v++ command to compile C/C++ kernels, refer to the Vitis documentation.

The kernel compilation results in the generation of one .xo file per kernel:

florentw_4-1625569695386.jpeg

HW Link Build

The next step is to integrate the PL kernels and the AI Engine into the Hardware platform. This step is called system HW link.

Run the HW link build by right clicking on the full_system_app_system_hw_link ve tıklayarak Proje Oluştur.

florentw_5-1625569695392.jpeg

not: This step is calling Vivado under the hood, so you will need a valid license to run synthesis and implementation and to generate a bitstream for Versal devices.

If we look at the console, we can see that the following command has been run:

v++ --target hw_emu --link --config binary_container_1-link.cfg -o"binary_container_1.xclbin" ../.. /full_system_app_kernels/Emulation-HW/build/mm2s.xo ../../full_system_app_kernels/Emulation-HW/build/polar_clip. xo ../../full_system_app_kernels/Emulation-HW/build/s2mm.xo ../../full_system_app_aie/Emulation-AIE/libadf.a

We can see that the v++ tool is used with the option –link and has the compiled kernels (mm2s.xo, polar_clip.xo and s2mm.xo) and compiled aie application (libadf.a) as inputs. This steps will generate a XCLBIN file using Vivado.

Once the application has been built successfully, it is possible to see the the design used to generate the XCLBIN in Vivado.

The Vivado project named prj.xpr should be located in the following directory:

<workspace>/full_system_app_system_hw_link/Emulation-HW/binary_container_1.build/link/vivado/vpl/prj/

In Vivado 2021.1, if you open the Block Design xilinx_vck190_base in the prj.xpr project you will see that the MM2S, S2MM, and polar_clip kernels have been added as IP blocks and connected to AXI4-Stream interfaces of the AI Engine.

florentw_6-1625569695407.jpeg

PS Application Build

The next step is to build the application for a Linux system. To successfully build it, Vitis requires some options that we have to set: the paths to the sysroot, Root FS, and kernel image.

For this we can use the prebuilt Linux kernel and root file system that can be used with any Versal board. This can be downloaded from the following page (Versal Common tarball):

https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-platforms.html

Once you have downloaded the Versal Common, you will need to build the sysroot by running the following script from the extracted folder using a Linux terminal:

xilinx-versal-common-v2020.2/sdk.sh -y -dir <dir path to install> -p

Once the sysroot is built, open the full_system_app_system.sprj configuration file in the Vitis IDE and set the paths to the sysroot, Root FS and kernel image.

florentw_7-1625569695416.jpeg

We can now build the PS application by right clicking on the application full_system_app [xrt] and clicking Proje Oluştur

florentw_8-1625569695423.jpeg

This will generate a binary called full_system_app under  full_system_app/Emulation-HW.

Packaging the system

The last step is to package the system. This step will create the boot image.florentw_9-1625569695433.jpeg

seçmek full_system_app_system ve tıklayın Proje Oluştur.

not: Building the full system will also build the aie application, ps application and kernels and link the system if these steps have not been done individually as we did previously.

11.jpg

In the console we can see that the following command has been executed:

v++ --package --config package.cfg ../../full_system_app_aie/Emulation-AIE/libadf.a ../../full_system_app_system_hw_link/Emulation-HW/binary_container_1.xclbin -o binary_container_1.xclbin

We can see that the v++ tool is called with the option –package and with the XCLBIN file created during the Hardware link and the compiled aie application (libadf.a).

The file package.cfg contains additional options for the v++ command including the complied ps application (full_system_app)

Running the system in Hardware Emulation

The last step is to test the system in Hardware Emulation.

To launch HW emulation for the system, right click on the full_system_app_system ve tıklayın koşmak Gibi… > Launch HW Emulator

florentw_10-1625569695442.jpeg

A window will pop-up asking us if we want to use the GUI mode. While the GUI mode is useful to see the signals going in and out of the AI Engine we will not look at this in this article (we will come back to this in a later one).

Keep the “Launch Emulator in GUI mode to display waveforms” option unchecked and click Start Emulator and Run.

florentw_11-1625569695446.jpeg

This will open an Emulation Console window in which we can see the system booting:

florentw_12-1625569695449.jpeg

When launched, use the presented Linux prompt to run the design.

Execute the following commands when the emulated Linux prompt displays to set up the environment:

cd /mnt/sd-mmcblk0p1
export XILINX_XRT=/usr
dmesg -n 4 && echo "Hide DRM messages..."

Finally, execute the following command to run the application:

./full_system_app ./binary_container_1.xclbin

In the console window, you should see the following output which indicates that the application was run successfully:

Loading: './binary_container_1.xclbin'
TEST PASSED

15.JPG

Plato Ai. Web3 Yeniden Düşünüldü. Güçlendirilmiş Veri Zekası.
Erişmek için buraya tıklayın.

Kaynak: https://forums.xilinx.com/t5/Design-and-Debug-Techniques-Blog/AI-Engine-Series-10-Full-system-running-the-AI-Engine-part-2/ba- p/1261009

spot_img

En Son İstihbarat

spot_img

Bizimle sohbet

Merhaba! Size nasıl yardım edebilirim?