speculated_iterations Attribute
speculated_iterations
AttributeUse the
speculated_iterations
attribute to direct the
Intel® oneAPI
to improve the performance of pipelined loops. The
DPC++/C++
Compilerspeculated_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
Where, the integer argument[[intel::speculated_iterations(N)]]
N
The
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 f
Intel® oneAPI
generates hardware to run
DPC++/C++
CompilerN
max
. 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
.
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
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.
N
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.