Specifying the Device ID and Loading the XCLBIN - 2023.2 English

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

Document ID
Release Date
2023.2 English

To use the Xilinx Runtime (XRT) environment properly, the software application needs to identify the accelerator card, or target platform, and the device ID that the kernel will run on. Then it needs to load the device binary (.xclbin) into the device to program the PL kernels.

The XRT API includes a Device class (xrt::device) that can be used to specify the device ID on the target platform, and an XCLBIN class (xrt::xclbin) that defines the hardware and PL kernels for the runtime. You must use the following #include statements in your source code to load these classes:
#include <xrt/xrt_device.h>
#include <experimental/xrt_xclbin.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 card or hardware platform.