swp/noswp

Indicates a preference for loops to be software pipelined or not pipelined.

Syntax

#pragma swp

#pragma noswp

Arguments

None

Description

The swp pragma indicates a 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 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 the 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.

The noswp pragma is used to instruct the compiler not to software pipeline that loop. This may be advantageous for loops that iterate few times, as pipelining introduces overhead in executing the prolog and epilog code sequences.

Example

Example: Using swp pragma

The following example demonstrates one way of using the pragma to instruct the compiler to attempt software pipelining.

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;

}

See Also