6 Performance and optimization
This chapter describes how to use different features of HP Fortran to tune your program for optimum performance. The most important of these features is the optimizer. You invoke the optimizer when compiling your program by specifying either +On(where nrepresents the level of optimization to be applied to your program) or the
+O2 option.The following command line compiles , usingprog.f90 the default level of optimization:
$ f90
For most applications,
•Using profilers
•Using options to control optimization
•Conservative vs. aggressive optimization
•Parallelizing HP Fortran programs
•Vectorization
•Controlling code generation for performance
For information about getting the best performance from
Using profilers
A profiler is a tool for sampling a program during execution so that you can determine where your program spends most of its time. After examining the data provided by a profiler, you can decide whether to redesign parts of the program to improve their performance or to
The following sections describe the HP Caliper performance analysis tool, which is bundled with HPFortranas well as the two UNIX profilers,gprof and prof.
NOTE: As described in “Stripping debugging information” (page 76), all programs compiled by HP Fortran include symbol table information in the executable file, unless you compile with the +stripoption or have removed the symbol table with the strip utility. This information must be present in the executable in order to use the profiling tools.
HP Caliper
HP Caliper works with your compiler to perform Profile Based Optimization (PBO).
The compiler option +Oprofile=collectuses HP Caliper in the background to collect profile information for your entire application. This is equivalent to the +Ioption on HP
Using profilers 87