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

Optimizing applications

kt_mic
Beginner
474 Views
At times, I find the behaviour of the optimizer quite unpredictable.

As an example, I attempted to clean up a subprogram by moving part of its code to a subrogram contained in a CONTAINS structure.

Strangely, just including

CONTAINS SUBROUTINE xyz()

...

END SUBROUTINE

without actually calling the contained routine or changing the original in any way led to a substantial increase (50%) in the execution time.

The example is included. It is selfcontained and prints out execution times. Compilation with -QxW. Comment out the CONTAINS
part in the bottom of the program and note the change.


Michael
0 Kudos
2 Replies
Steven_L_Intel1
Employee
474 Views
I don't find this too surprising - the presence of the contained routine means that the arrays V and A are potentially up-level referenced, which can inhibit some optimizations. By the time the compiler realizes that dummy isn't called, it may be too late to undo the damage.

I do know that the next version of the compiler runs some optimization phases in a different order which may help this. I will comment that you should also use /O3.
0 Kudos
kt_mic
Beginner
474 Views
Very helpful, thank you. I provided the CONTAINS part with dummy arguments and could now move the code without any performance loss.
-O3 did not help, though, rather the opposite.

Michael
0 Kudos
Reply