Developer Guide

Intel oneAPI DPC++/C++ Compiler Handbook for Intel FPGAs

ID 785441
Date 5/08/2024
Public

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

Document Table of Contents

speculated_iterations Attribute

Use the speculated_iterations attribute to direct the Intel® oneAPI DPC++/C++ Compiler to improve the performance of pipelined loops. The speculated_iterations attribute is applied to loops and hence, it must appear directly before the loop (the same place as other loop attributes). For more information, refer to Optimize Loops With Loop Speculation.

Syntax

[[intel::speculated_iterations(N)]]
Where, the integer argument N specifies the permissible number of iterations to speculate.

The Intel® oneAPI DPC++/C++ Compiler generates hardware to run N extra iterations of the loop while ensuring the extra iterations do not affect anything. This allows either reducing the II of the loop or increasing the fmax. The deciding factor is how quickly the exit condition of the loop is calculated. If the calculation takes many cycles, it is better to have larger speculated_iterations.

NOTE:

Extra iterations increase the time before the next invocation of the loop can begin. This may be a factor if the actual number of iterations of the loop is very small (less than 5 to 10 or similar). In this case, specify the N value as 0 to allow subsequent loop iterations to start immediately but at the cost of a larger II to allow more time to evaluate the exit condition. Refer to the Loop Analysis report to identify whether the exit condition is a bottleneck for II.

Example

[[intel::speculated_iterations(1)]]
  while (m*m*m < N) {
    m += 1;
  }
  dst[0] = m;

The loop in this example will have one speculated iteration.

NOTE:

For additional information, refer to the FPGA tutorial sample "Speculated Iterations" listed in the Intel® oneAPI Samples Browser on Linux* or Windows*, or access the code sample in GitHub.