Specifying the Device ID and Loading the XCLBIN - 2021.2 English

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

Document ID
UG1393
ft:locale
English (United States)
Release Date
2021-12-15
Version
2021.2 English

To use the Xilinx runtime (XRT) environment properly, the host application needs to identify the accelerator card and device ID that the kernel will run on, and load the device binary (.xclbin) into the device.

The XRT API includes a Device class (xrt::device) that can be used to specify the device ID on the accelerator card, and an XCLBIN class (xrt::xclbin) that defines the program for the runtime. You must use the following include statement in your source code to load these classes:
#include <xrt/xrt_kernel.h>

The following code snippet creates a device object by specifying the device ID from the target platform, and then loads the .xclbin into the device, returning the UUID for the program.

//Setup the Environment
unsigned int device_index = 0;
std::string binaryFile = parser.value("kernel.xclbin");
std::cout << "Open the device" << device_index << std::endl;
auto device = xrt::device(device_index);
std::cout << "Load the xclbin " << binaryFile << std::endl;
auto uuid = device.load_xclbin(binaryFile);
Tip: The device ID can be obtained using the xbutil command for a specific accelerator.