HP Fortran Programmer's Guide (B3908-90031; September 2011)

Performance and optimization
Vectorization
Chapter 6170
Note that the *$* VECTORIZE directive does not force vectorization. The optimizer vectorizes only if:
The loop performs a vector operation recognized by the optimizer as in its repertoire.
The loop is safe to vectorize. The same conditions that can prevent parallelization—see, for example,
“Data dependences” on page 166—can also prevent vectorization.
The optimizer can discover no other transformations that can result in better performance.
The only way to ensure vectorization is for the programmer to edit the source file and substitute an
appropriate call to the BLAS library for the loop, as described in “Controlling vectorization locally” on
page 169.
For a detailed description of the *$* [NO]VECTORIZE directive, see the HP Fortran Programmer's
Reference.
NOTE The + Ovectorize option is valid only on the PA-RISC systems.
Calling BLAS library routines
The HP Fortran compiler is bundled with the Basic Linear Algebra Subroutine (BLAS) library. This library
consists of specially tuned routines that perform low-level vector and matrix operations that conform to a de
facto, industry-wide standard
1
. The BLAS routines are widely available, making them portable across many
implementations of Fortran.
HP Fortran includes a library of the BLAS routines that have been especially tuned for performance on
PA-RISC machines. You can call any of these routines in an HP Fortran program by compiling it with the
-lblas option.
Consider the following program, which contains a loop that performs an operation on two arrays that is
identical to the saxpy routine in the BLAS library, as noted in the comments:
Example 6-1 saxpy.f90
PROGRAM main
INTEGER :: i, inc_x, inc_y, dim_num
REAL, DIMENSION(5) :: x, y
REAL :: b
b = 3.0
dim_num = 5
1. See the LAPACK Users Guide, ed. J. Dongarra et al (Philadelphia, 1992). Each of the BLAS
routines has its own man page; see blas(3X) for an introduction. Also, see the URL:
http://www.netlib.org.