Using optimization remarks with Arm Fortran Compiler

This short tutorial describes how to enable and use optimization remarks with Arm Fortran Compiler.

Overview

Optimization remarks provide you with information about the choices made by the compiler. They can be used to see which code has been inlined or to understand why a loop has not been vectorized.

By default, Arm Fortran Compiler prints compilation information to stderr. Using optimization remarks prints this optimization information to the terminal, or it can be piped to an output file.

Enabling optimization remarks

To enable optimization remarks, pass the following  -Rpass options to armflang as required:

Flag Description
 -Rpass=<regexp>  Request information about what Arm Compiler has optimized.
 -Rpass-analysis=<regexp>  Request information about what Arm Compiler has analyzed.
 -Rpass-missed=<regexp>  Request information about what Arm Compiler failed to optimize.

For each flag, replace <regexp> with an expression for the type of remarks you wish to view.

Recommended <regexp> queries are:

  • -Rpass=\(loop-vectorize\|inline\)
  • -Rpass-missed=\(loop-vectorize\|inline\)
  • -Rpass-analysis=\(loop-vectorize\|inline\)

where loop-vectorize will filter remarks regarding vectorized loops, and inline for remarks regarding inlining.

To search for all remarks, use the expression .*. However, this expression should be used with care because a lot of information may be printed depending on the size of your code and the level of optimization performed. 

Generate debug information

To generate the required debug information, you must combine the -Rpass flag with any of the following -g options:

Flag Description
-g  Emits debug information into the binary.
-gline-tables-only  Only emits line table debug information into the binary.
-insight  Only emits Arm Compiler insights into the binary.

Fortran example using armflang

To pass -Rpass with the regular expression loop-vectorize to armflang, use:

armflang -O3 -Rpass=loop-vectorize example.F90 -gline-tables-only

This results in the following example output in the terminal:

example.F90:21: vectorized loop (vectorization width: 2, interleaved count: 1) 
[-Rpass=loop-vectorize] END DO

Piping optimization remarks to a file

To pipe loop vectorization optimization remarks to a file called vecreport.txt, use:

armflang -O3 -Rpass=loop-vectorize -Rpass-analysis=loop-vectorize -Rpass-missed=loop-vectorize example.F90 -gline-tables-only 2> vecreport.txt

Related information