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

11.3.1.1. Omit Hardware that Generates and Dispatches Kernel IDs

The max_global_work_dim(0) kernel attribute instructs the Intel® FPGA SDK for OpenCL™ Offline Compiler to omit logic that generates and dispatches global, local, and group IDs into the compiled kernel.
Tip: For oneAPI SYCL-specific kernel attribute, refer to Omit Hardware that Generates and Dispatches Kernel IDs topic in the Intel® oneAPI DPC++ FPGA Optimization Guide.

Semantically, the max_global_work_dim(0) kernel attribute specifies that the global work dimension of the kernel is zero. Setting this kernel attribute means that the kernel does not use any global, local, or group IDs. The presence of this attribute in the kernel code serves as a guarantee to the offline compiler that the kernel is a single work-item kernel.

When compiling the following kernel, the offline compiler generates interface hardware as illustrated in Intel® FPGA SDK for OpenCL™ Offline Compiler-Generated Interface Hardware for a Kernel with the max_global_work_dim(0) Attribute.

channel int chan_in;
channel int chan_out;

__attribute__((max_global_work_dim(0)))
__kernel void plusK (int N, int k) {
    for (int i = 0; i < N; ++i) {
	    int data_in = read_channel_intel(chan_in);
	    write_channel_intel(chan_out, data_in + k);	
    }
}
Figure 35.  Intel® FPGA SDK for OpenCL™ Offline Compiler-Generated Interface Hardware for a Kernel with the max_global_work_dim(0) Attribute

If your current kernel implementation has multiple work-items but does not use global, local, or group IDs, you can use the max_global_work_dim(0) kernel attribute if you modify the kernel code accordingly:

  1. Wrap the kernel body in a for loop that iterates as many times as the number of work-items.
  2. Launch the modified kernel with only one work-item.