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

ID 767251
Date 11/07/2023
Public

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

Document Table of Contents

ASSUME

General Compiler Directive: Provides heuristic information to the compiler optimizer.

!DIR$ ASSUME (scalar-logical-expression)

scalar-logical-expression

Is any expression that evaluates to .TRUE. or .FALSE. at runtime.

At compile time, the scalar-logical-expression is always presumed to be true and may be used by the optimizer to generate better code.

At runtime, the ASSUME directive is evaluated at the point where it is located in the source.

If the check assume option is specified and scalar-logical-expression does not evaluate to .TRUE. at runtime, an error message is displayed and execution is aborted. If the check assume option is not specified and scalar-logical-expression does not evaluate to .TRUE. at runtime, program behavior is undefined.

Example

In the example below, the compiler is told that A is aligned on a 32-byte boundary using the ASSUME_ALIGNED directive. The ASSUME directive says that the length of the first dimension of A is a multiple of 8. Therefore the optimizer knows that A(I,J+1) and A(I,J-1) are 0 mod 64 bytes away from A(I,J) and are therefore also aligned on 32-byte boundaries. This information helps the optimizer in generating efficiently vectorized code for these loops.

SUBROUTINE F (A, NX,NY,I1,I2,J1,J2)
REAL (8) :: A (NX,NY)
!DIR$ ASSUME_ALIGNED A:32
!DIR$ ASSUME (MOD(NX,8) .EQ. 0)
! ensure that the first array access in the loop is aligned
!DIR$ ASSUME (MOD(I1,8) .EQ. 1)
DO J=J1,J2
  DO I=I1,I2
     A(I,J) = A(I,J) + A(I,J+1) + A(I,J-1)
  ENDDO
ENDDO
END SUBROUTINE F

See Also