Chapter 2. How to Use Power Fortran

This chapter contains the following sections:

Overview of Compilation

Simply running a program through Power Fortran might improve the performance of your program, but you can improve it far more if you understand the Power Fortran listing. From the listing, you can often identify small problems that prevent a loop from running safely in parallel. With a relatively small amount of work, you can remove these data dependencies and dramatically improve the program's performance.

When trying to find loops to run in parallel, focus your efforts on the areas of the code that use the bulk of the run time. Spending time trying to run a routine in parallel that uses only one percent of the run time of the program cannot significantly improve the performance of your program.

To determine where your code spends its time, take an execution profile of the program. Use either pc sampling, through the –p option to f77(1), or basic block profiling, through pixie(1). Refer to the MIPSpro Compiling and Performance Tuning Guide for details about profiling. Alternatively, you can use the WorkShop Pro MPF Parallel Analyzer View to examine the performance of your program. Refer to the Developer Magic: WorkShop Pro MPF User's Guide for details.

There are two schools of thought about profiling: conservative and optimistic. The conservative approach takes a profile of the original (nonparallel) job. You then run in parallel only the loops that account for most of the run time. The more optimistic approach runs the entire program through Power Fortran and then profiles the resulting multiprocessed job. The conservative approach reduces the chances that something might go wrong because it makes fewer changes to the code. It also focuses on the smallest number of lines of code that have the greatest effect.

Use the optimistic approach when you think that Power Fortran will do a good job with the existing program. You will save time by letting Power Fortran do what it can. You can then focus on those routines where Power Fortran had a problem. One situation in which Power Fortran frequently does a good job is when you convert programs that already run well on traditional vector architectures. Many such programs run in parallel without additional effort.

Whichever approach you choose, use the profile to focus your efforts on the most time-consuming routines. Once you find a time-consuming routine, submit that routine alone to Power Fortran. If the routine is in the middle of a large file, consider using fsplit(1) to isolate the individual routine. Compile the routine with the –pfa keep option and examine the listing file. The Power Fortran listing identifies the loops that Power Fortran can and cannot run in parallel. For loops that cannot run in parallel, the listing also tells you why Power Fortran could not convert the loop for parallel execution.

Compiling Programs With Power Fortran

This section describes the command-line syntax for compiling a Fortran 77 program with Power Fortran. You can pass these options to Power Fortran by adding the –pfa option to the f77 command line. It invokes the various processing phases that compile, optimize, assemble, and link the program. For more information about the –pfa option, see the f77(1) reference page.


f77 options -pfa[{list|keep}] [-pfa,option[=value] [,option[=value]]...] filename



Specifies any f77 compiler options. Refer to the f77(1) reference page and the MIPSpro Fortran 77 Programmer's Guide for details.


Requests automatic parallelization of loops, and enables any multiprocessing directives.


Specifies an annotated listing of the parts of the program that can (and cannot) run in parallel on multiple processors. The listing file has the suffix .l.


Generates the listing file (.l), saves the transformed equivalent Fortran 77 program (.m), and creates an output file for use with WorkShop Pro MPF (.anl).


Passes the specified command-line options to Power Fortran. Do not enter spaces between –pfa and any of the hyphens, options, equal signs, and values that follow it.


Specifies a Power Fortran command-line option listed in Table 2-1, for example, –concurrentize.


Specifies a value for a command-line option, for example, 1.


Specifies the Fortran 77 source program. The filename must always use the .f, .F, .for, or .FOR suffix.

Table 2-1 lists the Power Fortran command-line options. Although the table lists the options in lowercase, you can specify them in uppercase as well.

Note: You can replace many of the Power Fortran command-line options listed in Table 2-1 with in-code directives. For information on these directives, see Chapter 7, “Fine-Tuning Power Fortran,” and Appendix B, “Power Fortran Directives.”

Table 2-1. Power Fortran Command-Line Options


Long Name

Short Name

Default Value










(option off)

General Optimization[a]













depends on –Ondepends on –Ondepends on –On

Directive Controla




Inlining and Interprocedural Analysisa



























(option off)

(option off)

(option off)

(option off)

(option off)

(option off)

(option off)

(option off)



(option off)

(option off)











(option off)

Advanced Optimization

–aggressive=letter a–arclimit=n a–cacheline=n a–cachesize=n a–chunk=n a–dpregisters=n a–each_invariant_if_growth=n a–fpregisters=n a


–max_invariant_if_growth=n a–[no]recursiona–setassociativity=n a–unroll=n a–unroll2=n a















(option off)






–each_invariant_if _growth=20








[a] Refer to the MIPSpro Fortran 77 Programmer's Guide for details about this option.

The –pfa option enables Power Fortran, which performs automatic parallelization plus –pfa,–r=0,–so=3,–o=5. This option also enables the multiprocessing directives that you can enable separately with the –mp option.

If you specify the –On option along with –pfa, the compiler performs the greater of the implied options. For example, specifying –O1 (which is the same as –pfa,–r=0, –so=2,–o=1) and –pfa (which is the same as –pfa,–r=0,–so=3,–o=5) has the same effect as –pfa,–r=0, –so=3,–o=5.


To compile the Fortran 77 program prog.f with Power Fortran and the –minconcurrent=0 and –parallelio options, enter

% f77 -pfa -pfa,-minconcurrent=0,-parallelio prog.f

Figure 2-1 shows what happens when you compile a Fortran 77 program with –pfa. The first pass invokes the macro preprocessor cpp to handle cpp directives. (For more information, see the cpp(1) manual page.) The Power Fortran 77 analyzer, pfa, then takes the cpp output and inserts code that runs data-independent loops in parallel. This modified source code is then taken by the MIPSpro Fortran compiler, which generates intermediate code.

In addition to the intermediate code, the Power Fortran analyzer can generate the following files:

  • listing file (.l)

  • equivalent transformed file (.m)

  • file for use with WorkShop Pro MPF (.anl)

For details and an example of the listing file, refer to Chapter 3, “Utilizing Power Fortran Output.”

Finally, the MIPSpro back end, be, processes the intermediate code to produce an object file (.o).

Figure 2-1. Compiling With Power Fortran