subroutine vconvx(n,a,b,c,d) dimension a(n,n),b(n),c(n),d(*) c there are four loops that i use to test some of the more interesting c aspects of a vectorizing compiler c c loop 1 c c setting a matrix to its identity element (from sandia lab benchmark) c do 20, i = 1,n do 10, j = 1,n a(i,j) = 0 10 continue a(i,i) = 1 20 continue c c the best results are: c 1)loop distribution, vectorizing the inner and outer loops c 2)loop interchange on the innermost loop c c c loop 2 c c scalar expansion (forward assignment substitution) and using the last element c calculated outside the loop (without directives). many dusty decks. c do 30, i = 1,n x = c(i) + b(i) c(i) = c(i) +.5 b(i) = x-.5 30 continue print *, x c the best results vectorize without directives or modifying the code by c replacing x with x(i) for all 3 occurrneces of x c c loop 3 c c this example test partial vectorization c for the creation of vector of indices. c this example came from the VAST manual on constructs that DO NOT vectorize. c j =1 do 40, i= 1,n j = j*2 d(j) = 1 40 continue c c the best results are partial vectorization with the net effect being the c loops being compiled as c c temp(1)=1 c do i= 2,n c temp(i) = temp(i-1)*2 (actually temp(i-1)+temp(i-1)) c enddo c c do i= 1,n c d(temp(i)) =1 c enddo c c loop 4 c c tests scalar expansion. came from a benchmark to test the scalar speed of c the machine. since no vectors were defined c q = 1. do 50, i = 1,n q = .995*q 50 continue c c the best results are fully vectorized. the compiler expands .995 into a c vector of .995 and does a product reduction on the vector of .995 c this one fooled everybody. vectorization without vectors. return end .