3. Compile the A72 Host Application - 2023.1 English

Vitis Tutorials: AI Engine Development

Document ID
Release Date
2023.1 English

When all the new AI Engine outputs are created, you can compile your host application by following the 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.

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.

  • GCC_FLAGS: Self-explanatory that you will be compiling this code with C++ 14. More explanation will be provided in the packaging step.

  • GCC_INCLUDES: Contains the list of all the necessary include files from the SDKTARGETSYSROOT as well as the AI Engine tools.

c. Close the Makefile, and run the command:

     make host


     cd ./sw

     aarch64-xilinx-linux-g++ -Wall -c -std=c++14 -D__PS_ENABLE_AIE__ -Wno-int-to-pointer-cast --sysroot=$SDKTARGETSYSROOT -I$SDKTARGETSYSROOT/usr/include/xrt -I$SDKTARGETSYSROOT/usr/include -I./ -I../aie -I$XILINX_VITIS/aietools/include -I$XILINX_VITIS/include -o host.o host.cpp
     aarch64-xilinx-linux-g++ host.o -lxrt_coreutil -L$SDKTARGETSYSROOT/usr/lib --sysroot=$SDKTARGETSYSROOT -L$XILINX_VITIS/aietools/lib/aarch64.o -o host.exe

cd ..

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

Flag Description
-Wall Print out all warnings.
-Wno-int-to-pointer-cast Warn about an integer to pointer cast.
--sysroot Tells the compiler where to find the headers/libs for cross-compile.
-std=c++14 This is required for Linux applications using XRT.