3. Compile the A72 Host Application - 2023.2 English

Vitis Tutorials: AI Engine (XD100)

Document ID
Release Date
2023.2 English

When all the new AI Engine outputs are created, you can compile your host application using g++(Note: we are not using a typical cross-compilation flow for the Cortex-A72) . As you might notice, the host code uses XRT (Xilinx Run Time) as an API to talk to the AI Engine and PL kernels. Notice that in the linker, it is using the library -lxrt_coreutil. Note that to compile the host code, it is required to use the c++17 package. Ensure your gcc or g++ compiler has the necessary packages installed.

a. Open sw/host.cpp and familiarize yourself with the contents. Pay close attention to API calls and the comments provided.

Note: XRT is used in the host application. This API layer is used to communicate with the PL, specifically the PLIO kernels for reading and writing data. To understand how to use this API in an AI Engine application refer to “Programming the PS Host Application”.

b. Open the Makefile, and familiarize yourself with the contents. Take note of the GCC_FLAGS, GCC_INCLUDES which are self-explanatory that you will be compiling this code with C++ 17. More explanation will be provided in the packaging step.

Note: XRT needs to be installed on the host and the $XILINX_XRT variable should be set by sourcing the /opt/xilinx/xrt/setup.sh.

c. Unset the CXX variable that points to the aarch64-linux-gnu-g++ compiler. Run the following command to set g++ for the x86 process.

d. Close the Makefile, and run the command:

     make host


     cd ./sw

     g++ -Wall -c -std=c++17 -D__PS_ENABLE_AIE__ -Wno-int-to-pointer-cast -I$XILINX_XRT/include -I./ -I../aie -I$XILINX_VITIS/aietools/include  -o host.o host.cpp
     g++ *.o -lxrt_coreutil -std=c++17 -L$XILINX_XRT/lib -o ./host_ps_on_x86

cd ..

The follow table describes some of the GCC options being used.

Flag Description
-Wall Print out all warnings.
-std=c++17 This is required for Linux applications using XRT.
-I$XILINX_XRT/lib This includes the XRT libraries that are used in host code.