Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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

!$OMP 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:

  • 0: no-op

  • 1: L1 uncached and L3 uncached

  • 2: L1 uncached and L3 chached

  • 3: l1 cached and L3 uncached

  • 4: L1 cached and L3 cached

  • 5: L1 streaming load and L3 uncached

  • 6: L1 streaming load and L3 cached

  • 7: L1 invalidate-after-read and L3 cached

array-section

Is a contiguous array section (stride value is either 1 or not specified).

clause

Is the following:

IF (scalar-logical-expression)

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..

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 DATA (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