Writing a Custom Makefile - 2023.2 English

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

Document ID
Release Date
2023.2 English

Your custom Makefile should provide similar functions as the template Makefile. The basic steps to compile in VSC are similar to other Vitis tool flows, as shown below:

v++ --compile my_acc.cpp -o my_acc.o
v++ --link my_acc.o -o hw.xclbin # also outputs hw.o
g++ -c main.cpp -o main.o
g++ -o host.exe main.o my_acc.o hw.o -lvpp_acc -lxrt_core -lpthread
Some things to notice in these commands:
  1. The v++ compile command does not use the -k option to specify a kernel name. This is because the source code defines a class derived from the VPP_ACC class that enables the Vitis tools to compile the VSC system.
  2. The v++ --compile compile command produces .o files instead of .xo files. These files are used by Vitis compiler and g++ to build the hardware and host systems.
  3. The v++ --link command will use the .o files as inputs and generate both an .xclbin for the hardware accelerator, and a hw.o which contains compiled objects for the VSC hardware-software interfaces required by the host application and used by g++.
  4. The commands will also need to have specific options for the respective tools and modes, for example --platform and --target.

Alternatively, you can create a shared (dynamically loadable) library to let the accelerator be easily integrated into a third-party application. For example, libmy_acc.so as given below:

v++ -c my_acc.cpp -o my_acc.o
v++ -l my_acc.o kernel.xo -o hw.xclbin # also produces hw.o
g++ -c -fPIC app.cpp -o app.o 
## Command to create the shared library:
g++ -shared -fPIC -o libmy_acc.so app.o my_acc.o \
    -Wl,--whole-archive ${XILINX_VITIS}/system_compiler/lib/x86/libvpp_acc.a \
## The link command using the shared library
g++ -o host.exe main.o -lmy_acc -lxrt_hw -lpthread