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

ID 683342
Date 4/22/2019
Public
Document Table of Contents

8.1. 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.