Intel® FPGA SDK for OpenCL™ Pro Edition: Best Practices Guide

ID 683521
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

3.4.1. Trade-Off Between Initiation Interval and Maximum Frequency

The offline compiler attempts to achieve an II value of 1 for a given loop whenever possible. In some cases, the offline compiler might strive for an II of 1 at the expense of a reduced fMAX.

Consider the following example:

kernel void lowered_fmax (global int *dst, int N) {
     int res = N;
     #pragma unroll  9
     for (int i = 0; i < N; i++) {
 	    res += 1;
 	    res ^= i;
     }
     dst[0] = res;
 }

The following figure shows the datapath of the loop in kernel lowered_fmax. The loop is partially unrolled by a factor of 9, so the datapath contains nine copies of the original loop's body. To save space, only three of these copies are depicted in the following figure:

Figure 53. Datapath of the Partially Unrolled Loop in Kernel lowered_fmax
The loop in kernel lowered_fmax has a loop-carried dependence involving the res variable. This loop carried dependence forms a cycle in the loop's datapath, as shown in Datapath of the Partially Unrolled Loop in Kernel lowered_fmax .
Note: The value of res from one iteration must be available when the next iteration is launched. Therefore, if the loop is to achieve II=1, this cycle must contain at most one register. This cycle contains a chain of nine additions and XORs, so fMAX must be lowered in order for this chain of operations to complete within one clock cycle. The offline compiler may lower the kernel's fMAX to achieve II=1, since II is an important factor to achieving good performance. Consult the HTML report to find loops whose loop carried dependencies limit fMAX.