Intel® High Level Synthesis Compiler Pro Edition: Best Practices Guide

ID 683152
Date 4/01/2024
Public
Document Table of Contents

When the critical path that affects II is the computation of the exit condition and not a loop-carried dependency, the Intel® HLS Compiler can attempt to relax this scheduling constraint by speculatively continuing to execute iterations of the loop while the exit condition is being computed.

If it is determined that the exit condition is satisfied, the effects of these extra iterations are suppressed.

Typically, the exit condition for a loop iteration must be evaluated before the program determines whether to start the next loop iteration or continue into the rest of the function. This requirement means that the loop initiation interval (II) cannot be lower than the number of cycles required to compute the exit condition. Speculated iterations can help lower the loop II because operations within the loop can occur in the function pipeline at the same time as the exit condition is evaluated.

This speculative execution can achieve lower II and higher throughput, but it can incur additional overhead between loop invocations (equivalent to the number of speculated iterations). A larger loop trip count helps to minimize this overhead.

For any speculated iteration, instructions with side effects outside of the loop (like writing to memory or a stream) are not completed until the loop exit condition for the iteration has been evaluated. For loop iterations that are in flight but incomplete when the loop exit condition is met, side effect data is discarded.

While speculated iterations can improve loop II, they occupy the pipeline until they are completed. A new loop invocation cannot start until all of the speculated iterations have completed. For example, the next iteration of an outer loop cannot start until all the speculated iterations of an inner loop have completed.

Terminology Reminder
A loop invocation is what starts a series of loop iterations. One loop iteration is one execution of the body of a loop.
Figure 19. Loop Orchestration Without Speculative Execution


Figure 20. Loop Orchestration With Speculative Execution