The swp pragma indicates preference for loops to be software pipelined. The pragma does not help data dependency, but overrides heuristics based on profile counts or unequal control flow.
The syntax for this pragma is shown below:
Syntax |
---|
#pragma swp #pragma noswp |
The Software Pipelining optimization triggered by the swp pragma applies instruction scheduling to certain innermost loops, allowing instructions within a loop to be split into different stages, allowing increased instruction level parallelism.
This strategy can reduce the impact of long-latency operations, resulting in faster loop execution. Loops chosen for software pipelining are always innermost loops that do not contain procedure calls that are not inlined. Because the optimizer no longer considers fully unrolled loops as innermost loops, fully unrolling loops can allow an additional loop to become the innermost loop (see loop unrolling options).
You can view an optimization report to see whether software pipelining was applied (see Optimizer Report Generation).
The following example demonstrates on way of using the pragma to instruct the compiler to attempt software pipeling.
Example: Using SWP |
---|
void swp(int a[], int b[]) { #pragma swp for (int i = 0; i < 100; i++) if (a[i] == 0) b[i] = a[i] + 1; else b[i] = a[i] * 2; } |