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

ID 683846
Date 12/13/2021
Public

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

Document Table of Contents

11.5. Intra-Kernel Registered Assignment Built-In Function

The Intel® FPGA SDK for OpenCL™ Pro Edition provides the built-in function __fpga_reg() that you can include in your OpenCL kernel code.
The __fpga_reg() function directs the Intel® FPGA SDK for OpenCL™ Offline Compiler to insert at least one register between the operand and the return value of the function call.

In general, it is not necessary to include the __fpga_reg() function in your kernel code to achieve desired performance.

Attention: Intel® strongly recommends that you use the __fpga_reg() function only if you are an experienced user of the Intel® Quartus® Prime Pro Edition software performing advanced optimization for a specific target device. You must have sufficient knowledge about the placement of portions of the data path on the FPGA.

Prototype of the __fpga_reg() built-in function:

T __fpga_reg(T op)

where T may be any sized type, such as standard OpenCL device data types, or a user-defined struct containing OpenCL types.

Use the __fpga_reg() function for the following purposes:

  • Break the critical paths between spatially distant portions of a data path, such as between processing elements of a large systolic array.
  • Reduce the pressure on placement and routing efforts caused by spatially distinct portions of the kernel implementation.

The __fpga_reg() function directs the Intel® FPGA SDK for OpenCL™ Offline Compiler to insert at least one hardware pipelining register on the signal path that assigns the operand to the return value. This built-in function operates as an assignment in the OpenCL programming language, where the operand is assigned to the return value. The assignment has no implicit semantic or functional meaning beyond a standard C assignment. Functionally, you can think of the __fpga_reg() function being always optimized away by the offline compiler.

Note: The offline compiler does not provide feedback on where you should insert the __fpga_reg() function calls in your code. Use the Intel® Quartus® Prime Pro Edition software to determine where you should insert the calls to address specific aspects of performance.

You may introduce nested __fpga_reg() function calls in your kernel code to increase the minimum number of registers that the offline compiler inserts on the assignment path. Because each function call guarantees the insertion of at least one register stage, the number of calls provides a lower limit on the number of registers.

Consider the following example:

int out=__fpga_reg(__fpga_reg(in));

This line of code directs the offline compiler to insert at least two registers on the assignment path. The offline compiler may insert more than two registers on the path.