General Compiler Directives: PREFETCH enables a data prefetch from memory. Prefetching data can minimize the effects of memory latency. NOPREFETCH (the default) disables data prefetching. These directives affect the heuristics used in the compiler.
cDEC$ PREFETCH [var1[: hint1[: distance1]] [,var2[: hint2[: distance2]]]...]
cDEC$ NOPREFETCH [var1[,var2]...]
c |
Is one of the following: C (or c), !, or *. (See Syntax Rules for Compiler Directives.) |
var |
Is an optional memory reference. |
hint |
Is an optional integer initialization expression with the value 0, 1, 2, or 3. These are the same as the values for hint in the intrinsic subroutine MM_PREFETCH. To use this argument, you must also specify var. |
distance |
Is an optional integer initialization expression with a value greater than 0. It indicates the number of loop iterations to perform before the prefetch. To use this argument, you must also specify var and hint. |
To use these directives, compiler option O2 or O3 must be set.
This directive affects the DO loop it precedes.
If you specify PREFETCH with no arguments, all arrays accessed in the DO loop will be prefetched.
If a loop includes expression A(j), placing cDEC$ PREFETCH A in front of the loop instructs the compiler to insert prefetches for A(j + d) within the loop. The d is determined by the compiler.
cDEC$ NOPREFETCH c
cDEC$ PREFETCH a
do i = 1, m
b(i) = a(c(i)) + 1
enddo
The following example is valid on IA-64 architecture:
sum = 0.d0
do j=1,lastrow-firstrow+1
i = rowstr(j)
iresidue = mod( rowstr(j+1)-i, 8 )
sum = 0.d0
CDEC$ NOPREFETCH a,p,colidx
do k=i,i+iresidue-1
sum = sum + a(k)*p(colidx(k))
enddo
CDEC$ NOPREFETCH colidx
CDEC$ PREFETCH a:1:40
CDEC$ PREFETCH p:1:20
do k=i+iresidue, rowstr(j+1)-8, 8
sum = sum + a(k )*p(colidx(k ))
& + a(k+1)*p(colidx(k+1)) + a(k+2)*p(colidx(k+2))
& + a(k+3)*p(colidx(k+3)) + a(k+4)*p(colidx(k+4))
& + a(k+5)*p(colidx(k+5)) + a(k+6)*p(colidx(k+6))
& + a(k+7)*p(colidx(k+7))
enddo
q(j) = sum
enddo