Understanding Code Setup with Host and Kernel - 2023.1 English

Vitis Tutorials: Hardware Acceleration (XD099)

Document ID
Release Date
2023.1 English

The source code for each module is located under their local ./src directory:

  • Take a look at the host code and notice the several APIs that are used. Notice how the data is transferred back and forth to the kernel and back. The execution model can be broken down into the following steps:

    • The host program writes the data needed by a kernel into the global memory of the attached device through the PCIe® interface on an AMD Alveo™ Data Center accelerator card or through the AXI bus on an embedded platform.

      • The host program sets up the kernel with its input parameters.

      • The host program triggers the execution of the kernel function on the FPGA.

      • The kernel performs the required computation while reading data from global memory, as necessary.

      • The kernel writes data back to global memory and notifies the host that it has completed its task.

      • The host program reads data back from global memory into the host memory and continues processing as needed.

    • Take a look at the kernel code. This code is compiled by the Vitis tools and transformed into an hardware description that the AMD Vivado™ tool implements onto AMD devices. Since the the host and kernel code are developed and compiled independently, wrap the kernel function declaration with the extern “C” linkage in the header file, or wrap the whole function in the kernel code.

      extern "C" {
                   void kernel_function(int *in, int *out, int size);