Visible to Intel only — GUID: GUID-54CBE318-D1A6-4BF8-BB37-86763618830B
Visible to Intel only — GUID: GUID-54CBE318-D1A6-4BF8-BB37-86763618830B
PREFETCH Directive for OpenMP
OpenMP* Fortran Compiler Directive: Suggests to the compiler to preload data into cache. Preloading data in cache minimizes the effects of memory latency. This feature is only available for ifx.
Syntax
!$OMPX PREFETCH ([prefetch-hint-modifier:] array-section [, array-section] ...) [clause]
prefetch-hint-modifier |
Is an positive integer literal constant whose value is between 0 and 7, inclusive. If not specified, the default value is 0. The values indicate the following:
|
array-section |
Is a contiguous array section (stride value is either 1 or not specified). |
clause |
Is the following: |
Description
The PREFETCH directive issues a prefetch to preload the data specified by array-section. If the IF clause is present, the prefetch is done only when the scalar-logical-expression evaluates to .TRUE..
The PREFETCH directive is a pure directive, so it can appear in a Fortran PURE procedure.
Example
The following code prefetches and caches elements 17 thru 1024 of the arrays y and z to L1 and L3 cache. Each element is prefetched 16 iterations prior to its use in the computation y(i) + z(i).
SUBROUTINE sub ()
IMPLICIT NONE
REAL,DIMENSION(1024) :: y, x, z
INTEGER :: i
. . .
DO m = 1, 1024
!$omp PREFETCH (4: y(i+16), z(i+16)) &
!$omp& IF ((MOD(i, 16) .eq. 1) .and. ((i+15 .le. 1024))
x(i) = y(i) + z(i)
END DO
. . .
END SUBROUTINE