The stable pragma can be used to mark input or output
variables of a dataflow region. Its effect is to remove their corresponding
synchronizations, assuming that the user guarantees this removal is indeed correct.
void dataflow_region(int A[...], ...
#pragma HLS stable variable=A
#pragma HLS dataflow
proc1(...);
proc2(A, ...);
Without the stable pragma, and assuming that
A is read by proc2, then proc2 would be part of the
initial synchronization (via ap_start), for the
dataflow region where it is located. This means that proc1 would not restart until proc2 is
also ready to start again, which would prevent dataflow iterations to be overlapped and
induce a possible loss of performance. The stable pragma indicates that
this synchronization is not necessary to preserve correctness.
In the previous example, without the stable
pragma, and assuming that A is read by proc2 as proc2 is
bypassing the tasks, there will be a performance loss.
stable pragma, the compiler assumes
that:- if
Ais read byproc2, then the memory locations that are read will not be overwritten, by any other process or calling context, whiledataflow_regionis being executed. - if
Ais written byproc2, then the memory locations written will not be read, before their definition, by any other process or calling context, whiledataflow_regionis being executed.
A typical scenario is when the caller updates or reads these variables only when the dataflow region has not started yet or has completed execution.