Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
29305 Discussions

IFORT bug report: wrong result (optimisation problem?) when using -fPIC -qopenmp together

raf3
Beginner
735 Views

Hello,

I encountered a strange behavior when using -fPIC and -qopenmp together with ifort (ifort (IFORT) 2021.9.0 20230302 and ifort (IFORT) 2021.10.0 20230609 at least).

I have attached a minimal reproducible example to this message.

A .sh file is used to compile and execute the test with different compiler options:

 

#!/bin/bash

\rm -f *.o *.mod *.exe
ifort -O2 my_test.f90 -o test.exe
./test.exe

\rm -f *.o *.mod *.exe
ifort -O2 -fPIC my_test.f90 -o test.exe
./test.exe

\rm -f *.o *.mod *.exe
ifort -O2 -qopenmp my_test.f90 -o test.exe
./test.exe

\rm -f *.o *.mod *.exe
ifort -O2 -fPIC -qopenmp my_test.f90 -o test.exe
./test.exe

 

The expected result is 1.0, but when the two options are used together, the result is 5.0.

Adding a "magic print" works around the problem.

My questions are:

  • Are you able to reproduce the behavior?
  • Can you confirm that this is a real bug in the compiler (or have I missed something)?
  • Is it possible to fix it in the next release?

Best regards,

Raphaël

0 Kudos
2 Replies
Mark_Lewy
Valued Contributor I
704 Views

I note that this still outputs 5.0 with "ifort -O2 -fPIC -qopenmp my_test.f90", but 1.0 with ifx and the same options in the current OneAPI:  ifort 2021.12.0 20240211 / ifx 2024.1.2 20240508.  Given that ifort is deprecated, it's unlikely that Intel will fix this with ifort; you are better off switching to ifx, if possible.

raf3
Beginner
693 Views

Ok, thank you for this answer. I will look to switch my code to ifx.

0 Kudos
Reply