Compile the Embedded Application for the Cortex-A72 Processor - 2021.2 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
Release Date
2021.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.

You compile the embedded application by following the typical cross-compilation flow for the Arm Cortex-A72 processor. The following are example commands for compiling and linking the PS application:

aarch64-xilinx-linux-g++ -std=c++14 -O0 -g -Wall -c \
-I<platform_path>/sysroots/aarch64-xilinx-linux/usr/include/xrt \
--sysroot=<platform_path>/sysroots/aarch64-xilinx-linux/ \
-I./ -I./src -I${XILINX_HLS}/include/ -I${XILINX_VITIS}/aietools/include -o sw/host.o sw/host.cpp

aarch64-xilinx-linux-g++ -std=c++14 -O0 -g -Wall -c \
-I<platform_path>/sysroots/aarch64-xilinx-linux/usr/include/xrt \
--sysroot=<platform_path>/sysroots/aarch64-xilinx-linux/ \
-I./ -I./src -I${XILINX_HLS}/include/ -I${XILINX_VITIS}/aietools/include -o sw/aie_control_xrt.o Work/ps/c_rts/aie_control_xrt.cpp

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++14
  • -I<platform_path>/sysroots/aarch64-xilinx-linux/usr/include/xrt
  • --sysroot=<platform_path>/sysroots/aarch64-xilinx-linux/
  • -I./ -I./src
  • -I${XILINX_HLS}/include/
  • -I${XILINX_VITIS}/aietools/include
  • -o sw/host.o sw/host.cpp

The cross compiler aarch64-xilinx-linux-g++ is used to compile the Linux host code. aie_control_xrt.cpp is copied from the directory Work/ps/c_rts.

aarch64-xilinx-linux-g++ -ladf_api_xrt -lgcc -lc -lpthread -lrt -ldl \
-lcrypt -lstdc++ -lxrt_coreutil \
-L<platform_path>/sysroots/aarch64-xilinx-linux/usr/lib \
--sysroot=<platform_path>/sysroots/aarch64-xilinx-linux \
-L${XILINX_VITIS}/aietools/lib/aarch64.o -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.

Table 1. Command Options
Option Description
-ladf_api_xrt Required for the ADF API. For more information, see Host Programming on Linux.

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/ For more information see Host Programming for Bare-Metal Systems.

-lxrt_coreutil Required for the XRT API.
-o sw/host.exe