- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
-O3 did not help, though, rather the opposite.
Michael

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page