prefervector
- Date:
01-09-2012
NAME
prefervector - indicates loop to vectorize within a loop nest
SYNOPSIS
#pragma _CRI prefervector
!DIR$ PREFERVECTOR
IMPLEMENTATION
Cray Linux Environment (CLE)
DESCRIPTION
Scope: Local
The prefervector directive directs the compiler to vectorize the loop that immediately follows the directive if the loop contains more than one loop in the nest that can be vectorized. The directive states a vectorization preference and does not guarantee that the loop has no memory- dependence hazard.
EXAMPLES
Example 1: prefervector directive
The following example illustrates the use of the prefervector directive for C/C++ :
float a[1000], b[100][1000];
void
f(int m, int n)
{
int i, j;
#pragma _CRI prefervector
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
a[i] += b[j][i];
}
}
}
In this example, both loops can be vectorized, but the directive directs the compiler to vectorize the outer for loop. Without the directive and without any knowledge of n and m, the compiler would vectorize the inner loop.
Example 2: PREFERVECTOR directive
The following example illustrates the use of the PREFERVECTOR directive for Fortran:
!DIR$ PREFERVECTOR
DO I = 1, N
!DIR$ IVDEP
DO J = 1, M
A(I) = A(I) + B(J,I)
END DO
END DO
In this example, both loops can be vectorized, but the compiler generates vector code for the outer DO I loop. Note that the DO I loop is vectorized even though the inner DO J loop was specified with an IVDEP directive:
SEE ALSO
intro_directives(1)