Compiling an Embedded Application for PS on x86 - 2023.2 English

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

Document ID
Release Date
2023.2 English

In order to compile an embedded application to run on an x86 processor, as described in Embedded Processor Emulation Using PS on x86 you must use the x86 version of gcc or g++ compiler version 8.3 or later.

Tip: x86 compilation is supported for the software emulation flow only, and requires the x86 installation of XRT as described in Installing Xilinx Runtime and Platforms. This sets the LD_LIBRARY_PATH variable to point to XRT libraries.

Compile and Link the Host Application Against Required XRT APIs and Generate the Executable

g++ -Wall -c -std=c++17 -Wno-int-to-pointer-cast -I${XILINX_XRT}/include \
-I./src/aie -I./ -I${XILINX_VITIS}/aietools/include \
-o aie_control_xrt.o ./Work/ps/c_rts/aie_control_xrt.cpp $(HOST_SRCS) -o main.o
g++ *.o -lxrt_coreutil -ladf_api_xrt -L${XILINX_VITIS}/aietools/lib/lnx64.o \
Note: For ps_on_x86 compilation, you must set the GCC path from the Vitis Install:
setenv PATH $XILINX_VITIS/aietools/tps/lnx64/gcc/bin:$PATH

If you want to switch between the embedded (ARM-GCC) flow and x86 compilation flow on the same setup (terminal), you need to explicitly specify ARM-GCC and SYSROOT paths for compiling and linking the application for ARM-GCC based flow. The scenario is applicable if you are trying to run the emulation using cross compilation of the host application and simultaneously want to run software emulation using native x86 compilation of the host application on the same shell (terminal).

Note: After running native x86 compilation, if you are trying to compile the host application using ARM-GCC compiler in the same terminal, you will source the environment setup script xilinx-versal-common-v2023.1/environment-setup-cortexa72-cortexa53-xilinx-linux. Ensure the LD_LIBRARY_PATH variable is not set because a warning will be issued if this variable is set. You must then unset the LD_LIBRARY_PATH and re-run the environment setup script.

For information on how to run PS on x86 for an AI Engine kernel, see the AIE Adder example on GitHub.


Arm-only data types or libraries are not supported in the host code while running the x86 compilation.

Below is the host code example using _fp16 (floating point 16) data types which is only supported in the ARM-GCC based compiler. The x86 compiler issues error while compiling the same host code. In such situation, AMD recommends using the QEMU model of the PS and compiling the PS application with ARM-GCC based compiler.

#define LENGTH (1024)
#define HALF __fp16
int main(int argc, char* argv[])
unsigned fileBufSize;
std::string binaryFile = argv[1];
size_t vector_size_bytes = sizeof(HALF) * LENGTH;
//Source Memories
std::vector<HALF> source_a(LENGTH);
std::vector<HALF> source_b(LENGTH);
std::vector<HALF> result_sim (LENGTH);
std::vector<HALF> result_krnl(LENGTH);
/* Create the test data and golden data locally */
for(int i=0; i < LENGTH; i++){
source_a[i] = i;
source_b[i] = i*2;
result_sim[i] = source_a[i] + source_b[i];
Tip: As described in Compiling the Embedded Application for the Cortex-A72 Processor, you can also target the QEMU model of the PS by compiling the embedded application in software emulation flow using the ARM-GCC compiler.