Compiling the Embedded Application for the Cortex-A72 Processor - 2023.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
UG1393
Release Date
2023-12-13
Version
2023.2 English

After linking the AI Engine graph and PL kernels, the focus moves to the embedded application running in the PS that interacts with the AI Engine graph and kernels. The PS application is written in C/C++, using API calls to control the initialization, running, and closing of the AI Engine graph as described in Run-Time Graph Control API in AI Engine Kernel and Graph Programming Guide (UG1079).

For details about compiling and linking host code using the XRT API, see Compiling and Linking Host Code for Linux in the AI Engine Tools and Flows User Guide (UG1076)

$CXX -std=c++17 -O0 -g -Wall -c \
-I./src -I${XILINX_VITIS}/aietools/include -o sw/host.o sw/host.cpp

$CXX -std=c++17 -O0 -g -Wall -c \
-I./src -I${XILINX_VITIS}/aietools/include -o

Many of the options in the preceding command are standard and can be found in a description of the g++ command. The more important options are listed as follows:

  • -std=c++17
  • -I./src
  • -I${XILINX_VITIS}/aietools/include
  • -o sw/host.o sw/host.cpp

aie_control_xrt.cpp is copied from the directory Work/ps/c_rts.

$CXX -lgcc -lc -lpthread -lrt -ldl \
-lcrypt -lstdc++ -lxrt_coreutil \
-L<platform_path>/sysroots/aarch64-xilinx-linux/usr/lib \
-o sw/host.exe sw/host.o sw/aie_control_xrt.o

Note in the preceding linker script that it links the adf_api_xrt libraries, which is necessary for the ADF API to work with the XRT API.

xrt_coreutil are required libraries for XRT and for the XRT API.

While many of the options can be found in a description of the g++ command, some of the more important options are listed in the following table.

If any ADF API is used in the host code, compiling host code requires additional ADF API related include files and libraries files, and also aie_control_xrt.cpp from aiecompiler result, such as:
$CXX -std=c++17 -O0 -g -Wall -c \
-I./src -I${XILINX_VITIS}/aietools/include -o sw/host.o sw/host.cpp

$CXX -std=c++17 -O0 -g -Wall -c \
-I./src -I${XILINX_VITIS}/aietools/include -o sw/aie_control_xrt.o Work/ps/
c_rts/aie_control_xrt.cpp
aie_control_xrt.cpp is copied from the directory Work/ps/c_rts.
$CXX -ladf_api_xrt -lgcc -lc -lpthread -lrt -ldl \
-lcrypt -lstdc++ -lxrt_coreutil \
-L<platform_path>/sysroots/aarch64-xilinx-linux/usr/lib \
-L${XILINX_VITIS}/aietools/lib/aarch64.o -o sw/host.exe sw/host.o sw/
aie_control_xrt.o
Table 1. Command Options
Option Description
-ladf_api_xrt Required for the ADF API.

This is used to control the AI Engine through XRT. If not controlling with XRT, use -ladf_api with the path -L${XILINX_VITIS}/aietools/lib/aarch64none.so. For more information see Host Programming for Bare-Metal in AI Engine Tools and Flows User Guide (UG1076).

-lxrt_coreutil Required for the XRT API.
-L<platform_path>/sysroots/aarch64-xilinx-linux/usr/lib  
-L${XILINX_VITIS}/aietools/lib/aarch64.o  
-o sw/host.exe