Running an Application

TIP: Set up the command shell or window as described in Setting up the Vitis Environment prior to running the builds.
As explained in Build Targets, there are three different types of builds you can target in the Vitis core development kit: software emulation, hardware emulation, and the system hardware build. Each of these build targets offers advantages, and limitations, and it is recommended that you work your way through building and running each of these targets.
  • Software emulation: The software emulation build compiles and links quickly, runs on the x86 system as a compiled C-model, and lets you quickly iterate on both the host code and kernel logic.
  • Hardware emulation: The host program runs as before, but the kernel code is compiled into an RTL behavioral model which is run in the Vivado simulator. This build and run loop takes longer but provides a cycle-accurate view of the kernel logic.
  • System hardware: The host program runs as before, but this time connected with the actual accelerator card, running the FPGA binary produced for your application. The performance data and results you capture here are the actual performance of your accelerated application. Yet this run might still reveal opportunities to optimize your design.

Running Emulation Builds

  1. Edit the xrt.ini file required by XRT. Optional, but recommended.

    As described in xrt.ini File, the xrt.ini file specifies various parameters to control debugging, profiling, and message logging in XRT when running the host application and kernel execution. This enables the runtime to capture debugging and profile information as the application is running. The Emulation group in the xrt.ini provides features that affect your emulation run.

    TIP: Be sure to use the v++ -g option when compiling your kernel code for emulation mode.
  2. Create the emconfig.json file required for running emulation as described in emconfigutil Utility. Required.

    The emulation configuration file, emconfig.json, is generated from the specified platform using the emconfigutil command, and provides information used by the Xilinx runtime library during emulation. The following example creates the emconfig.json file for the specified target platform:

    emconfigutil --platform xilinx_u200_xdma_201830_2
    TIP: It is mandatory to have an up-to-date .json file for running emulation on your target platform.
  3. Set the XCL_EMULATION_MODE environment variable to sw_emu (software emulation) or hw_emu (hardware emulation) as appropriate. This changes the application execution to emulation mode. In emulation mode, the runtime looks for the emconfig.json file in the same directory as the host executable, and reads in the target configuration for the emulation runs. Required.
    Use the following syntax to set the environment variable for C target platform:
    setenv XCL_EMULATION_MODE sw_emu
    Bash target platform:
    export  XCL_EMULATION_MODE=sw_emu
    IMPORTANT: The emulation targets will not run if the XCL_EMULATION_MODE environment variable is not properly set.
  4. Run the application.

    With the runtime initialization (xrt.ini), emulation configuration file (emconfig.json), and the XCL_EMULATION_MODE environment set, run the host executable with the desired command line argument, as you normally would run it if it was not an emulation run.. For example:

    ./host.exe kernel.xclbin
    TIP: This command line assumes that the host program is written to take the name of the xclbin file as an argument, as most Vitis examples and tutorials do. However, your application may have the name of the xclbin file hard-coded into the host program, or may require a different approach to running the application.

Running the System Hardware Build

Running the system hardware build will let you see the actual application running on an accelerator card, such as the Alveo Data Center accelerator card, or perhaps a prototype of an embedded processor platform. In order to use the accelerator card, you must have it installed as described in Getting Started with Alveo Data Center Accelerator Cards (UG1301).

Beyond the installation of the accelerator and XRT, you must unset the XCL_EMULATION_MODE environment variable prior to running the system hardware build. If you had it set for running emulation, you will need to unset it now.

With the runtime initialization (xrt.ini), and the XCL_EMULATION_MODE environment unset, run the application on hardware. For example:

./host.exe kernel.xclbin