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