Specifying the Device ID and Loading the XCLBIN - 2023.1 English

Vitis Tutorials: Hardware Acceleration (XD099)

Document ID
XD099
Release Date
2023-08-02
Version
2023.1 English
    // Read settings
    std::string binaryFile = "./vadd.xclbin";
    auto xclbin = xrt::xclbin(binaryFile);
    int device_index = 0;

    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);

In the Vitis application acceleration development flow, you must specify a Xilinx device binary file, or xclbin. This is an executable to be loaded into the AMD device and run by the accelerator card or platform. You must also identify the AMD device to load the xclbin into. In some systems there may be multiple accelerator cards with multiple devices. So you must specify the device as well as the xclbin.

There are a number of ways to identify both the device and binary file during execution. You can hard code them, as has been done for the device in this tutorial, specify them from the command line as as been done for the .xclbin file here, or you can specify them in other ways as demonstrated in the Vitis_Accel_Examples.

In the above code example, taken from the user-host.cpp file in this tutorial, the device is simply device_index 0, and the binary file is passed from the command line. The code:

  1. Identifies the Xilinx binary file: xrt::xclbin(binaryFile)

  2. Opens the device: xrt::device(device_index)

  3. Loads the xclbin into the device: device.load_xclbin(binaryFile)