Ambiguous explanation of the default value/behavior of -O


in the PGI reference manual on page 46 the default of -O is explained as: “The compiler optimizes at level 2.”

In fact there should be two entries for the default for the optimization flag.

  • Default for the compiler: -O1 (i.e. no -O given at all), this is also stated on page 47 and pgfortran -show confirms it.

  • Default for the optimization -O flag if no level is given: level 2.

For now the reference manual causes some confusion to my users - what’s really the default if no -O is given?

– Reuti

The lowest optimization level is -O0, which
does not optimize beyond the basic block. This is default when compiling
with -g for debugging.

The next level is the default -O1, what is used when no optimization
switches appear.

The next level of optimization -O2, is also what is set when you use
-O or -fast. -fast includes other specific optimizations judged by PGI
to be correct and effective on most cases we look at.

-O3 and -O4 are also available, which include optimizations that are new and should be
correct and should be effective, but do not always result in faster code than
lower optimizations, or may be a problem where results are sensitive to
small changes in data or operation order.

Thx for confirming by interpretation of the reference manual. Nevertheless I suggest to change the entry of “-O”, i.e. “Default: The compiler optimizes at level 2.” should read “Default: The compiler optimizes at level 1.”

At least all other entries list what action will be taken when the option in question isn’t given at all. Not the default in case the option gets no argument.

– Reuti

Just to be clear.

No -O, implies -O1, unless -g is set, which implies -O0

Using -O implies -O2