Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide

ID 683846
Date 3/28/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

8.2. Modifying Channels Kernel Code for Emulation

The Emulator emulates kernel-to-kernel channels. It does not support the emulation of I/O channels that interface with input or output features of your FPGA board. To emulate applications with a channel that reads or writes to an I/O channel, modify your kernel to add a read or write channel that replaces the I/O channel, and make the source code that uses it is conditional.
The Intel® FPGA SDK for OpenCL™ does not set the EMULATOR macro definition. You must set it manually either from the command line or in the source code.
Consider the following kernel example:
channel unlong4 inchannel __attribute__((io("eth0_in")));

__kernel void send (int size) {
    for (unsigned i = 0; i < size; i++) {
        ulong4 data = read_channel_intel(inchannel);
        //statements
    }
}

To enable the Emulator to emulate a kernel with a channel that interfaces with an I/O channel, perform the following tasks:

  1. Modify the kernel code in one of the following manner:
    • Add a matching write_channel_intel call such as the one shown below.
      #ifdef EMULATOR
      
      __kernel void io_in (__global char * restrict arr, int size) {
          for (unsigned i = 0; i < size; i++) {
              ulong4 data = arr[i]; //arr[i] being an alternate data source
              write_channel_intel(inchannel, data);
          }
      }
      #endif
    • Replace the I/O channel access with a memory access, as shown below:
      __kernel void send (int size) { 
          for (unsigned i = 0; i < size; i++) {
              #ifndef EMULATOR 
      
                  ulong4 data = read_channel_intel(inchannel); 
      
              #else 
                  ulong4 data = arr[i]; //arr[i] being an alternate data source
      
              #endif 
              //statements
          }
      }
  2. Modify the host application to create and start this conditional kernel during emulation.