Optimization reports
IBM® Open XL Fortran provides access to optimization reports via the LLVM remarks framework.
The LLVM remarks framework and options are documented in https://ibm.biz/openxl-1712-llvm-remarks. Each option must be passed to one of ibm-opt, ibm-llc, or LTO via the -X or -W options. IBM Open XL Fortran also provides the -qreport option, which generates a report in the listing file that includes LLVM remarks for function inlining and loop transformations. If you specify the -qreport option, do not also specify any other options from the LLVM remarks framework because they will interfere with report generation.
- If you use the
--pass-remarks-output=<filename> option to
save the optimization remarks to a file, make sure that you request remarks from only one of
ibm-opt, ibm-llc, or LTO, or to save the remarks from each component in a separate
file. For example, the following command saves the remarks from ibm-opt to
file.opt.yaml and the remarks from ibm-llc to
file.llc.yaml:
The following command writes remarks from ibm-opt to file.yaml and then overwrites the file with the remarks from ibm-llc:xlf95 file.f -O3 \ -Xopt --pass-remarks-output=file.opt.yaml \ -Xllc --pass-remarks-output=file.llc.yamlxlf95 file.f -O3 -mllvm --pass-remarks-output=file.yaml - You must enable debug line number generation (-g1 or -g) to get line numbers in the optimization remarks, or to use external visualization tools like opt-viewer.py.
- Many LLVM optimizations produce remarks. You can use the filtering options to control the amount of information presented.
$ cat loop.f
module m
contains
subroutine sub(a, b, c)
real a(160), b(160), c(160)
integer i
do i = 1, 160
a(i) = b(i) + c(i)
end do
do i = 1, 8
a(i) = a(i) * 3
end do
end
subroutine sub2(a, b, c)
real a(160), b(160), c(160)
call sub(a, b, c)
end subroutine
end module
program main
use m
real a(160), b(160), c(160)
read(*, *) b, c
call sub2(a, b, c)
print *, a
end program
$Optimization report using -qreport
xlf95 loop.f -c -O3 -qarch=pwr9 -qreport
loop.lst contains the following optimization
report:>>>>> LOOP TRANSFORMATION SECTION <<<<<
< loop.f
1 | module m
2 | contains
3 | subroutine sub(a, b, c)
4 | real a(160), b(160), c(160)
5 | integer i
6 |
7 U5V4,8 | do i = 1, 160
8 | a(i) = b(i) + c(i)
9 | end do
10 |
11 U8 | do i = 1, 8
12 | a(i) = a(i) * 3
13 | end do
14 | end
15 |
16 | subroutine sub2(a, b, c)
17 | real a(160), b(160), c(160)
18 I | call sub(a, b, c)
19 | end subroutine
20 | end module
21 |
22 | program main
23 | use m
24 | real a(160), b(160), c(160)
25 | read(*, *) b, c
26 | call sub2(a, b, c)
27 | print *, a
28 | end programThe letters in the left margin indicate the transformation
performed. U<iterations> means the loop was unrolled with
unroll factor <iterations>. V<width,
count> means the loop was auto-vectorized with vector width
<width> and interleaved count <count>.
I means the function call was inlined.Optimization report using LLVM remarks
xlf95 loop.f -c -O3 -qarch=pwr9 -g1 \
-Xopt --pass-remarks-output=loop.opt.yaml \
-Xllc --pass-remarks-output=loop.llc.yamlInstall python3. Download the opt-viewer tool from https://llvm.org.
python3 -m virtualenv optviewer_env
. optviewer_env/bin/activate
python3 -m pip install pyyaml pygmentsUse opt-viewer.py to
generate the HTML
report:opt-viewer/opt-viewer.py --demangler cat -source-dir $PWD *.yaml -o reportThe
commands above generate a report directory containing optimization report
loop.f.html. The report includes annotated source with transformation reports
from ibm-opt and ibm-llc. Transformations that
were performed are highlighted in green. Transformations that were missed are highlighted in
red.