Host Code Updates - 2023.2 English

Vitis Tutorials: Hardware Acceleration (XD099)

Document ID
XD099
Release Date
2023-11-13
Version
2023.2 English

To access the RTL-based kernel, the host code needs to be updated. The updates have been done in the xrt-host_step2.cpp file located in the following directory.

./reference-files/src/host/

The updates includes additional XRT API calls briefly described below. The additional API calls are identical to the ones used for the C++ based kernel with the arguments changed for the RTL-based kernel.

  std::string binaryFile;
  std::cout << "argc = " << argc << std::endl;
  for(int i=0; i < argc; i++){
  std::cout << "argv[" << i << "] = " << argv[i] << std::endl;
  }
  if (argc > 1) {
  binaryFile = argv[1];
  } else {
  binaryFile = "./krnl_vadd.hw_emu.xclbin";
  }

The following code gets the rtl_kernel_wizard_0 object from the device binary (.xclbin) and assigns the name krnlRTL on line 41. The rtl_kernel_wizard_0 object name matches the name of the RTL kernel.

    auto krnlRTL = xrt::kernel(device, uuid, "rtl_kernel_wizard_0");

NOTE: In the host code, the boOut buffer is passed directly from the C++ kernel to the RTL kernel through DDR without being moved back to the host memory. This results in better performance, and allows the buffer to be shared between the two kernels. This occurs when running the kernels as seen on lines 70 to 75.

    std::cout << "Execution of the vadd kernel\n";
    auto run1 = krnl(boIn1, boIn2, boOut, DATA_SIZE); //DATA_SIZE=size
    run1.wait();
    std::cout << "Execution of the RTL  kernel\n";
    auto run2 = krnlRTL(boOut); 
    run2.wait();