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

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

5.4.5.2. Implementing Blocking Channel Writes

The write_channel_intel API call allows you to send data across a channel.
To implement a blocking channel write, use the following write_channel_intel function signature:
void write_channel_intel (channel <type> channel_id, const <type> data);

Where:

channel_id identifies the buffer to which the channel connects, and it must match the channel_id of the corresponding read channel (read_channel_intel).

data is the data that the channel write operation writes to the channel.

<type> defines a channel data width. Follow the OpenCL™ conversion rules to ensure that data the kernel writes to a channel is convertible to <type>.

The following code snippet demonstrates the implementation of the write_channel_intel API call:
//Defines chan, a kernel file-scope channel variable.
channel long chan;

/*Defines the kernel which reads eight bytes (size of long) from global memory, and passes this data to the channel.*/ 
__kernel void kernel_write_channel( __global const long * src ) {
  for (int i = 0; i < N; i++) {
     //Writes the eight bytes to the channel.
     write_channel_intel(chan, src[i]);
  }
}
CAUTION:
When you send data across a channel using the write_channel_intel API call, keep in mind that if the channel is full (that is, if the FIFO buffer is full of data), your kernel will stall and wait until at least one data slot becomes available in the FIFO buffer. Use the Intel® FPGA dynamic profiler for OpenCL™ to check for channel stalls.