The loop count (n) directive indicates the loop count is likely to be n, where n is an integer constant.
The syntax for this directive is:
Syntax |
|---|
|
#pragma loop count (n) |
The value of loop count affects heuristics used in software pipelining and data prefetch.
Example 1 |
|---|
|
#pragma loop count (10000) for(i=0; i<m; i++) { //swp likely to occur in this loop a[i]=b[i]+1.2; } |
The distribute point directive indicates a preference for performing loop distribution. The syntax for this directive is:
Syntax |
|---|
|
#pragma distribute point |
Loop distribution may cause large loops be distributed into smaller ones. This may enable more loops to get software-pipelined.
If the directive is placed inside a loop, the distribution is performed after the directive and any loop-carried dependency is ignored.
If the directive is placed before a loop, the compiler will determine where to distribute and data dependency is observed. Multiple distribute directives are supported if they are placed inside the loop. When they are placed inside the loop, they cannot be put inside an IF statement.
Example 2: Example of distribute point Directive |
|---|
|
#pragma distribute point for(i=1; i<m; i++) { b[i]=a[i]+1 ... // Compiler will automatically decide where to distribute. // Data dependency is observed. c[i]=a[i]+b[i]; ... d[i]=c[i]+1; } for(i=1; i<m; i++) { b[i]=a[i]+1; ... #pragma distribute point // Distribution will start here, // ignoring all loop-carried dependency. sub(a,n); c[i]=a[i]+b[i]; ... d[i]=c[i]+1; } |