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

info on undocumented difference between /O1 and /O2 please

grant8
Beginner
1,062 Views

The help page for compiler option O describes the following for the shortcut options /O1 and /O2 on IA32:

/O1:

/Qunroll0, /nofltconsistency (same as /Op-), /Oy, /Os, /Ob2, /Qftz

/O2:

/Og, /Ot, /Oy, /Ob2, /Gs, and /Qftz ... but with the added note This option sets other options that optimize for code speed. The options set are determined by the compiler depending on which architecture and operating system you are using.

I have a situation where the /O1 vs /O2 setting is changing numerical results. Id like to track down exactly which optimization is doing it, so that I can choose one way or the other which setting to use. None of the above-listed /O1 or /O2 settings seems to be the cause ofthis. Is there any way to know what other stuff gets changed by /O1 vs /O2?

I am compiling on an EM64T Windows7 machine, for IA32 and EM64T target machines.

Thanks!!

0 Kudos
8 Replies
TimP
Honored Contributor III
1,062 Views
The biggest difference between -O1 and -O2 is the latter enables auto-vectorization. You would get information on where this occurs by setting /Qvec-report or /Qopt-report. If you have set /arch:ia32, which implies double precision evaluation of scalar single precision expressions, auto-vectorization should not occur. You should identify where you require double precision and write it into the source code.
If you depend on the order of evaluation of expressions, you should take care with use of parentheses, and set /assume:protect_parens.
0 Kudos
Steven_L_Intel1
Employee
1,062 Views
There are not distinct options to turn on and off all optimizations that are collected under the O1, O2 levels. I agree with Tim that vectorization is the most likely candidate.
0 Kudos
TimP
Honored Contributor III
1,062 Views
If the differences arise from latent bugs such as uninitialized or incorrectly declared variables, it's simply not feasible to document the ways in which changing optimization could expose problems.
0 Kudos
grant8
Beginner
1,062 Views

I have plenty of warnings and checks turned on. As the compiler is not reporting any such nasties, I hope that there are none.

0 Kudos
grant8
Beginner
1,062 Views
I have discovered that /O2 with /fp:strict is giving me the same results as /O1 for 32-bit. This is good because now it seems like our Debug and Release builds are going to be able to give us the same numerical results, which should be very helpful for debugging problems that come in from the field.

So far, I haven't beenso lucky for 64-bit. /O2 with /fp:strict is stillgiving different results from /O1.
0 Kudos
grant8
Beginner
1,062 Views
Is there any other setting that I can change in order to reduce the effect of vectorization on numerical results, e.g. a particular alignment ? Thanks
0 Kudos
strohhaecker
Beginner
1,062 Views
Did you try /fp:source (floating point model source) along with /Qfp-speculation=off (floating-point speculation turned off)?
0 Kudos
Steven_L_Intel1
Employee
1,062 Views
You could always try /arch:ia32 and see what it gets you (other than lower performance).
0 Kudos
Reply