Intel® FPGA SDK for OpenCL™ Standard Edition: Cyclone® V SoC Getting Started Guide

ID 683030
Date 4/20/2022
Document Table of Contents

3.8.4. Emulating Your OpenCL Kernel

To emulate your OpenCL™ kernel, run the emulation .aocx file on the platform on which you built your kernel. The OpenCL Emulator uses a different OpenCL platform than when targeting FPGA hardware.

To emulate your kernel, perform the following steps:

  1. Run the utility command aocl linkflags to find out which libraries are necessary for building a host application. The software lists the libraries for both emulation and regular kernel compilation flows.
  2. Build a host application and link it to the libraries from Step 1.
    Note: To emulate multiple devices alongside other OpenCL SDKs, link your host application to the Khronos ICD Loader Library before linking it to the host runtime libraries. Link the host application to the ICD Loader Library by modifying the Makefile for the host application. Refer to Linking Your Host Application to the Khronos ICD Loader Library for more information.
  3. If necessary, move the <your_kernel_filename>.aocx file to a location where the host can find it easily, preferably the current working directory.
  4. To run the host application for emulation:
    • For Windows, first define the number of emulated devices by invoking the set CL_CONTEXT_EMULATOR_DEVICE_INTELFPGA=<number_of_devices> command and then run the host application. After you run the host application, invoke set CL_CONTEXT_EMULATOR_DEVICE_INTELFPGA= to unset the variable.
    • For Linux, invoke the env CL_CONTEXT_EMULATOR_DEVICE_INTELFPGA=<number_of_devices> <host_application_filename> command.
    This command specifies the number of identical emulation devices that the Emulator needs to provide.
    Note: When the environment variable CL_CONTEXT_EMULATOR_DEVICE_INTELFPGA is set, only the emulated devices are available, i.e., access to all physical boards is disabled.
  5. If you change your host or kernel program and you want to test it, only recompile the modified host or kernel program and then rerun emulation.
Each invocation of the emulated kernel creates a shared library copy called <process_ID> in a default temporary directory, where <process_ID> is a unique numerical value assigned to each emulation run. You may override the default directory by setting the TMP or TEMP environment variable on Windows, or setting TMPDIR on Linux.

Did you find the information on this page useful?

Characters remaining:

Feedback Message