Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ifx -O3 acts as ifort -Ofast

foxtran
New Contributor I
222 Views

Hello!

With the following code:

program main
  implicit none
  integer :: ivert, nvert, nxy
  integer, parameter :: nequ = 24
  real(8), parameter :: pi = 4E0_8 * atan(1E0_8)
  real(8) :: angz, scalexy
  nvert = nequ / 2
  do ivert = 0, nvert
    angz = dble(ivert) / nvert * pi
    scalexy = dsin(angz)
    nxy = int(nequ * scalexy)
    if (scalexy > 0.49 .and. scalexy < 0.51) &
      print *, nxy, scalexy
  end do
end program main

 

Ifort, run as:

$ ifort -O3 test.f90 -o ifort && ./ifort

prints:

          11  0.500000000000000
          11  0.500000000000000


At the same, ifx, run as:

$ ifx -O3 test.f90 -o ifx && ./ifx

prints:

          11  0.500000000000000
          12  0.500000000000000

 
With `ifort -Ofast`, I can achieve the same output as for `ifx -O3`:

$ ifort -Ofast test.f90 -o ifort && ./ifort

 The output:

          11  0.500000000000000
          12  0.500000000000000


Used versions:

$ ifort --version -diag-disable=10448
ifort (IFORT) 2021.12.0 20240222
Copyright (C) 1985-2024 Intel Corporation.  All rights reserved.

$ ifx --version
ifx (IFX) 2024.1.0 20240308
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

 

0 Kudos
1 Reply
Steve_Lionel
Honored Contributor III
182 Views

Different optimizer. -Ofast is only there because gcc has it. According to the docs, "It sets compiler options -O3, -no-prec-div, and -fp-model fast=2."  Modifying the code to show the hex values, I get:

ifx -O3:

11 0.500000000000000 3FDFFFFFFFFFFFFF
12 0.500000000000000 3FE0000000000003

ifort -Ofast

11 0.500000000000000 3FDFFFFFFFFFFFFF
11 0.500000000000000 3FDFFFFFFFFFFFFF

I have not investigated further.

Reply