This chapter presents an interactive tutorial using the Fortran 90 compiler. It illustrates how the MIPSpro auto-parallelizing compiler transforms Fortran 90 arrays into loops.
Analyzing a Fortran 90 program is very similar to analyzing a Fortran 77 program. See the previous chapter for reference information that applies to both compilers.
This chapter describes the following:
How to set up the sample session. See “Setting Up the Sample Session”.
Compiling the code. See “Compiling the Sample Code”.
Starting the parallel analyzer. See “Starting the Parallel Analyzer View”.
Demonstrating array statement transformations. See “Demonstrating Array Statement Transformations”.
Exiting from the session. See “Exiting From the Session”.
Before starting this sample session, make sure ProMP.sw.demos is installed. The sample session uses the source file f90_tutorial_f90_orig in the directory /usr/demos/ProMP/f90_tutorial. The file Makefile compiles the source file.
The source file contains array statements, each of which exemplifies an aspect of the parallelization process.
Prepare for the session by entering the following in a shell window:
% cd /usr/demos/ProMP/f90_tutorial % make |
This creates the following files:
f90_tutorial.f90 | A copy of the demonstration program created by copying f90_tutorial.f90_orig | |
f90_tutorial.m | A transformed source file, which you can view with the Parallel Analyzer View and print | |
f90_tutorial.l | A listing file | |
f90_tutorial.anl | An analysis file used by the Parallel Analyzer View |
For more information about these files, see the MIPSpro Auto-Parallelizing Option Programmer's Guide.
Once you have created the files, start the session by entering the cvpav(1) command. The command opens the main window of the Parallel Analyzer View and loads the sample file data.
% cvpav -f f90_tutorial.f90 |
Open the Source View window by clicking the Source button once the main window opens.
This section demonstrates the following transformations:
Transforming a simple array statement into a DO loop. See “Transforming an Array Statement into a DO Loop”.
Transforming a single array statement into nested DO loops. See “Transforming an Array Statement in Nested DO Loops”.
Transforming a simple array statement into a subroutine. See “Transforming an Array Statement into a Subroutine”.
To continue the tutorial begun in the last section, go to loop 5 in the Parallel Analyzer View window and double-click the highlighted line in the loop list. First double-click the Source button, and then double-click the Transformed Source button.
Notice in the Transformed Source window that the following array statement has been transformed into a DO loop:
logical*1 l(12),r,r1 l = .true. |
The Transformed Loops View window (see Figure 3-1) identifies line 40 from the source as a Fortran 90 array statement. It notes that a loop was generated but indicates that the loop array statement was not made parallel because it contains too little work.
Pull down the Show All Loop Types menu and click on Show Fortran 90 Array Stmts. Only the Fortran 90 arrays statements that were transformed into DO loops are displayed.
The following is the array statement in the source:
logical*8 l(3,12) . . . l = .true. |
Because the array has two dimensions, two nested DO loops are generated. Double-click first on loop 22, then on loop 23. They are the two new loops generated from the array statement. The Transformed Loops View window gives information on each loop. (See Figure 3-2 for loop 22 and Figure 3-3 for loop 23.)
Click on loop 26. Notice in the Transformed Source window how the following sliced array statement is transformed into an OMP PARALLEL DO statement, which will itself be converted into a subroutine:
r(:il*2:2) = all(l,id) |
The Transformed Loops View (see Figure 3-4) shows the process of converting first to a parallel loop and then to a subroutine: