If you compile with the -g debugging option, you can view source code annotations generated by the compiler by using the er_src(1) utility, part of the Sun Studio Performance Analysis Tools. This utility can also be used to view the source code annotated with the generated assembly language. Here is an example of the commentary produced by er_src on a simple do loop:
demo% f95 -c -g -O4 do.f
demo% er_src do.o
Source file: /home/user21/do.f
Object file: do.o
Load Object: do.o
1. program do
2. common aa(100),bb(100)
Function x inlined from source file do.f into the code for the following line
Loop below pipelined with steady-state cycle count = 3 before unrolling
Loop below unrolled 5 times
Loop below has 2 loads, 1 stores, 0 prefetches, 1 FPadds, 1 FPmuls, and 0 FPdivs per iteration
3. call x(aa,bb,100)
4. end
5. subroutine x(a,b,n)
6. real a(n), b(n)
7. v = 5.
8. w = 10.
Loop below pipelined with steady-state cycle count = 3 before unrolling
Loop below unrolled 5 times
Loop below has 2 loads, 1 stores, 0 prefetches, 1 FPadds, 1 FPmuls, and 0 FPdivs per iteration
9. do 1 i=1,n
10. 1 a(i) = a(i)+v*b(i)
11. return
12. end
|
Commentary messages detail the optimization actions taken by the compiler. In the example we can see that the compiler has inlined the call to the subroutine and unrolled the loop 5 times. Reviewing this information might provide clues as to further optimization strategies you can use.
For detailed information about compiler commentary and disassembled code, see the Sun Studio Performance Analyzer manual.