HP OpenVMS Systems Documentation
OpenVMS VAX RTL Mathematics (MTH$) Manual
2.3 Vector Versions of Existing Scalar Routines
Vector forms of many MTH$ routines are provided to support vectorized compiled applications. Vector versions of key F-floating, D-floating, and G-floating scalar routines employ vector hardware, while maintaining identical results with their scalar counterparts. Many of the scalar algorithms have been redesigned to ensure identical results and good performance for both the vector and scalar versions of each routine. All vectorized routines return bit-for-bit identical results as the scalar versions.
You can call the vector MTH$ routines directly if your program is
written in VAX MACRO. If you are a Fortran programmer, specify the
Fortran intrinsic function name only. The Fortran compiler will then
determine whether the vector or scalar version of a routine should be
You should not attempt to recover from an MTH$ vector exception. After
an MTH$ vector exception, the vector routines cannot continue
execution, and nonexceptional values might not have been computed.
Some scalar routines check to see if a user has enabled underflow
detection. For each of those scalar routines, there are two
corresponding vector routines: one that always enables underflow
checking and one that never enables underflow checking. (In the latter
case, underflows produce a result of zero.) The Fortran compiler always
chooses the vector version that does not signal underflows, unless the
user specifies the /CHECK=UNDERFLOW qualifier. This ensures that the
check is performed but does not impair vector performance for those not
interested in underflow detection.
Use one of the formats in Table 2-3 to call (from VAX MACRO) a vector math routine that enables underflow signaling. (The E in the routine name means enabled underflow signaling.)
Use one of the formats in Table 2-4 to call (from VAX MACRO) a vector math routine that does not enable underflow signaling.
In the preceding formats, the following conventions are used:
2.3.4 Calling a Vector Math Routine
In the following examples, keep in mind that vector real arguments are passed in V0, V1, and so on, and vector real results are returned in V0. On the other hand, vector complex arguments are passed in V0 and V1, V2, and V3, and so on. Vector complex results are returned in V0 and V1.
The following example shows how to call the vector version of MTH$EXP. Assume that you do not want underflows to be signaled, and you need to use the current contents of all vector and scalar registers after the invocation. Before you can call the vector routine from VAX MACRO, perform the following steps.
The following MACRO program fragment shows this example. Assume that:
Note that MTH$VEXP_R3_V6 denotes an F-floating data type because there is no letter between V and E in the routine name. (For further explanation, refer to Section 2.3.3.) The stride (the number of array elements that are skipped) must be a multiple of 4 because each F-floating value requires 4 bytes.
The following example demonstrates how to call the vector version of OTS$POWDD with a vector base raised to a scalar power. Before you can call the vector routine from VAX MACRO, perform the following steps.
The following MACRO program fragment shows how to call OTS$VPOWDD_R1_V8 to compute the result of raising 60 values to the power P. Assume that:
Note that OTS$VPOWDD_R1_V8 raises a D-floating base to a D-floating power, which you determine from the DD in the routine name. (For further explanation, refer to Section 2.3.3.) The stride (the number of array elements that are skipped) must be a multiple of 8 because each D-floating value requires 8 bytes.
2.4 Fast-Vector Math Routines
This section describes the fast-vector math routines that offer significantly higher performance at the cost of slightly reduced accuracy when compared with corresponding standard vector math routines. Also note that some fast-vector math routines have restricted argument domains.
When you specify the compile command qualifiers /VECTOR and /MATH_LIBRARY=FAST, the Compaq Fortran compiler selects the appropriate fast-vector math routine, if one exists. The default is /MATH_LIBRARY=ACCURATE. You must specify the /G_FLOATING compile qualifier in conjunction with the /MATH_LIBRARY=FAST and /VECTOR qualifiers to access the G_floating routines.
You can call these routines from VAX MACRO using the standard calling method. The math function names, together with corresponding entry points of the fast-vector math routines, are listed in Table 2-5.
%SYSTEM-F-VARITH, vector arithmetic fault
The special restrictions listed in Table 2-6 apply only to fast-vector routines SIN, COS, and TAN. The standard vector routines handle the full range of VAX floating-point numbers.
If the application program uses arguments outside of the listed domain, the routine returns the following error message:
%SYSTEM-F-VARITH, vector arithmetic fault
If the application requires argument values beyond the listed limits,
use the corresponding standard vector math routine.
The fast-vector math routines do not guarantee the
same results as those obtained with the corresponding standard vector
math routines. Calls to the fast-vector routines generally
yield results that are different from the scalar and original vector
MTH$ library routines. The typical maximum error is a 2-LSB (Least
Significant Bit) error for the F_floating routines and a 4-LSB error
for the D_floating and G_floating routines. This generally corresponds
to a difference in the 6th significant decimal digit for the F_floating
routines, the 15th digit for D_floating, and the 14th digit for
The fast-vector math routines generally provide performance improvements over the standard vector routines ranging from 15 to 300 percent, depending on the routines called and input arguments to the routines. The overall performance improvement using fast-vector math routines in a typical user application will increase, but not at the same level as the routines themselves. You should do performance and correctness testing of your application using both the fast-vector and the standard vector math routines before deciding which to use for your application.