
The ECN No Name Newsletter is no longer being published. This is an archived issue.
[previous article] [next article]A vector processor is a piece of hardware that does operations on arrays much faster than a normal CPU can. The new Gould NP-1 machines that will be replacing the three Gould 9080s (GA, CA, MG) have vector processor hardware for the FORTRAN compiler. To make use of the vector processor, you use what is called a vector preprocessor.
A vector preprocessor takes DO loops and IF statements and puts them in a special form that allows them to make use of the vector hardware. However not all DO loops and IF statements can be translated. They are required to have a fixed number of iterations and only the following statements are allowed:
REMEMBER not all loops can be vectorized.
On the NP-1, any FORTRAN-77 program source can be run through the vector preprocessor with the command: "fort -VLo file.f" (You must run the csh command unlimit to remove your resource limits first.) It is best to compile without the vector preprocessor to first make sure your code has no errors. If the code compiles without errors, four files are created. The a.out file and the file.o object file and two other special files, file.lv and file.fv. The file file.lv contains diagnostic output from the vector preprocessor. It lists all the loops that were vectorized and information on why some loops could not be vectorized. This information can be helpful in figuring out how your code can be changed to make it vectorizable. The file file.fv is the vectorized FORTRAN code.
Obviously, it is important to vectorize the loops that are executed the most frequently. To help identify these subroutines, the user should use the UNIX profil utility (similar to SHADOW on the CYBER 205) to determine where the program spends most of its time.
Here is an example of a piece of code that vectorizes well:
integer i
real x(10000,632), y(10000,632)
c compute data
do 25 j=1,10000
do 10 i=1,630
x(j,i)=(cos(3.0*i/100.)+1.0) +j
y(j,i)=sin(4.0*i/100.)
10 continue
25 continue
stop
end
Run the code through the vector preprocessor with the command "fort -VLo file.f" The file file.lv contains:
GOULD, C.S.D. VPP V1.01.01 11:22:2 3/26/88
FORTRAN 8X GOULD=,OPTON=,OPTOFF=,LSTO
1. integer i
2. real x(10000,632), y(10000,632)
3. c compute data
4. do 25 j=1,10000
5. do 10 i=1,630
6. x(j,i)=(cos(3.0*i/100.)+1.0)+j
7. y(j,i)=sin(4.0*i/100.)
8. 10 continue
9. 25 continue
10. stop
11. end
----------------- MAIN ------------------
LINE TYP MSG (T=TRANSLATION, D=DEPENDENCY,
W=WARNING, S=SYNTAX)
7 T NON-UNIT STRIDE PREVENTS TRANSLATION(Y)
-----------------------------------------
c compute data
do 25 I=1, 630
x(:,i)=(cos((3.0*i)/100.)+1.0)+seq(1,10000)
y(:,i)=sin((4.0*i)/100.)
25 continue
stop
end
------- LOOP SUMMARY FOR ROUTINE MAIN -------
%CD %DP
LABEL INDEX START END NEST COMMENT ITERATIONS
25 J 6 11 1 VECTORIZED 10000
10 I 7 10 2 NON-UNIT STRIDE 630
------ EVENT SUMMARY FOR ROUTINE MAIN ------
WARNING MESSAGES 0
SYNTAX ERRORS 0
TRANSLATION DIAGNOSTICS 1
DATA DEPENDENCY CONFLICTS 0
LOOPS EXAMINED 2
LOOPS TRANSLATED 1
The file file.fv contains the vectorized FORTRAN code. The FORTRAN code in file.fv has FORTRAN-8X compatible array syntax.
c translated by vpp 1.01.01 11:22: 2 3/26/88
c switches: GOULD=,OPTON=,OPTOFF=,
c LSTON=AO,LSTOFF=,TDYON=,TDYOFF=
integer i
real x(10000,632), y(10000,632)
c Compute data
do 25 i=1, 630
x(:,i)=(cos((3.0*i)/100.)+1.0)+seq(1,10000)
y(:,i)=sin((4.0*i)/100.)
25 continue
stop
end
This program runs on the NP-1 that is presently being tested in EE with the following results:
_________________________________________________________________ Output from the time command: nonvectorized 120.8u 14.9s 4:06 55% 0+2081k 4+0io 6163pf+0w vectorized 3.4u 6.0s 0:16 56% 0+1494k 5+0io 6163pf+0w _________________________________________________________________
If you add up the system and user time, it took 135.7 CPU seconds to run the unvectorized code and 9.4 CPU seconds to run the vectorized code. For more information on the Gould NP-1 vector processor you can look at ECN manual #742 Gould Advanced Vector Preprocessor User's Guide in the Potter Library or you can ask to see your site specialist's copy.