Using the SIMD libraries

The MASS SIMD library libmass_simdp7.a or libmass_simdp8.a contains a set of frequently used math intrinsic functions that provide improved performance over the corresponding standard system library functions. If you want to use the MASS SIMD functions, you can do so as follows:
  1. Provide the interfaces for the functions by including mass_simd.include in your source files.
  2. Link the MASS SIMD library libmass_simdp7.a or libmass_simdp8.a with your application. For instructions, see Compiling and linking a program with MASS.

The single-precision MASS SIMD functions accept single-precision arguments and return single-precision results. Likewise, the double-precision MASS SIMD functions accept double-precision arguments and return double-precision results. They are summarized in Table 1.

Table 1. MASS SIMD functions
Double-precision function Single-precision function Description Double-precision function interface Single-precision function interface
acosd2 acosf4 Computes the arc cosine of each element of vx.

vector(real(8)) function acosd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function acosf4(vx)
vector(real(4)), value :: vx

acoshd2 acoshf4 Computes the arc hyperbolic cosine of each element of vx.

vector(real(8)) function acoshd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function acoshf4(vx)
vector(real(4)), value :: vx

asind2 asinf4 Computes the arc sine of each element of vx.

vector(real(8)) function asind2(vx)
vector(real(8)), value :: vx

vector(real(4)) function asinf4(vx)
vector(real(4)), value :: vx

asinhd2 asinhf4 Computes the arc hyperbolic sine of each element of vx.

vector(real(8)) function asinhd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function asinhf4(vx)
vector(real(4)), value :: vx

atand2 atanf4 Computes the arc tangent of each element of vx.

vector(real(8)) function atand2(vx)
vector(real(8)), value :: vx

vector(real(4)) function atanf4(vx)
vector(real(4)), value :: vx

atan2d2 atan2f4 Computes the arc tangent of each element of vx/vy.

vector(real(8)) function atan2d2(vx,vy)
vector(real(8)), value :: vx, vy

vector(real(4)) function atan2f4(vx,vy)
vector(real(4)), value :: vx, vy

atanhd2 atanhf4 Computes the arc hyperbolic tangent of each element of vx.

vector(real(8)) function atanhd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function atanhf4(vx)
vector(real(4)), value :: vx

cbrtd2 cbrtf4 Computes the cube root of each element of vx

vector(real(8)) function cbrtd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function cbrtf4(vx)
vector(real(4)), value :: vx

cosd2 cosf4 Computes the cosine of each element of vx.

vector(real(8)) function cosd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function cosf4(vx)
vector(real(4)), value :: vx

coshd2 coshf4 Computes the hyperbolic cosine of each element of vx.

vector(real(8)) function coshd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function coshf4(vx)
vector(real(4)), value :: vx

cosisind2 cosisinf4

Computes the cosine and sine of each element of x, and stores the results in y and z as follows:

cosisind2 (x, y, z) sets the elements of y to cos(x1), sin(x1), and the elements of z to cos(x2), sin(x2), where x1, x2 are the elements of x.

cosisinf4 (x,y,z) sets the elements of y to cos(x1), sin(x1), cos(x2), sin(x2), and the elements of z to cos(x3), sin(x3), cos(x4), sin(x4), where x1, x2, x3, x4 are the elements of x.

subroutine cosisind2 (x, y, z)
vector(real(8)), value :: x
vector(real(8)) y, z

subroutine cosisinf4 (x, y, z)
vector(real(4)), value :: x
vector(real(4)) y, z

divd2 divf4 Computes the quotient vx/vy.

vector(real(8)) function divd2(vx, vy)
vector(real(8)), value :: vx, vy

vector(real(4)) function divf4(vx, vy)
vector(real(4)), value :: vx, vy

erfcd2 erfcf4 Computes the complementary error function of each element of vx.

vector(real(8)) function erfcd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function erfcf4(vx)
vector(real(4)), value :: vx

erfd2 erff4 Computes the error function of each element of vx.

vector(real(8)) function erfd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function erff4(vx)
vector(real(4)), value :: vx

expd2 expf4 Computes the exponential function of each element of vx.

vector(real(8)) function expd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function expf4(vx)
vector(real(4)), value :: vx

exp2d2 exp2f4 Computes 2 raised to the power of each element of vx.

vector(real(8)) function exp2d2(vx)
vector(real(8)), value :: vx

vector(real(4)) function exp2f4(vx)
vector(real(4)), value :: vx

expm1d2 expm1f4 Computes (the exponential function of each element of vx) - 1.

vector(real(8)) function expm1d2(vx)
vector(real(8)), value :: vx

vector(real(4)) function exp2m1f4(vx)
vector(real(4)), value :: vx

exp2m1d2 exp2m1f4 Computes (2 raised to the power of each element of vx) - 1.

vector(real(8)) function exp2m1d2(vx)
vector(real(8)), value :: vx

vector(real(4)) function exp2m1f4(vx)
vector(real(4)), value :: vx

hypotd2 hypotf4 For each element of vx and the corresponding element of vy, computes sqrt(vx*vx+vy*vy).

vector(real(8)) function hypotd2(vx,vy)
vector(real(8)), value :: vx, vy

vector(real(4)) function hypotf4(vx,vy)
vector(real(4)), value :: vx, vy

lgammad2 lgammaf4 Computes the natural logarithm of the absolute value of the Gamma function of each element of vx .

vector(real(8)) function lgammad2(vx)
vector(real(8)), value :: vx

vector(real(4)) function lgammaf4(vx)
vector(real(4)), value :: vx

logd2 logf4 Computes the natural logarithm of each element of vx.

vector(real(8)) function logd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function logf4(vx)
vector(real(4)), value :: vx

log2d2 log2f4 Computes the base-2 logarithm of each element of vx.

vector(real(8)) function log2d2(vx)
vector(real(8)), value :: vx

vector(real(4)) function log2f4(vx)
vector(real(4)), value :: vx

log10d2 log10f4 Computes the base-10 logarithm of each element of vx.

vector(real(8)) function log10d2(vx)
vector(real(8)), value :: vx

vector(real(4)) function log10f4(vx)
vector(real(4)), value :: vx

log1pd2 log1pf4 Computes the natural logarithm of each element of (vx +1).

vector(real(8)) function log1pd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function log1pf4(vx)
vector(real(4)), value :: vx

log21pd2 log21pf4 Computes the base-2 logarithm of each element of (vx +1).

vector(real(8)) function log21pd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function log21pf4(vx)
vector(real(4)), value :: vx

powd2 powf4 Computes each element of vx raised to the power of the corresponding element of vy.

vector(real(8)) function powd2(vx, vy)
vector(real(8)), value :: vx, vy

vector(real(4)) function powf4(vx, vy)
vector(real(4)), value :: vx, vy

qdrtd2 qdrtf4 Computes the quad root of each element of vx.

vector(real(8)) function qdrtd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function qdrtf4(vx)
vector(real(4)), value :: vx

rcbrtd2 rcbrtf4 Computes the reciprocal of the cube root of each element of vx.

vector(real(8)) function rcbrtd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function rcbrtf4(vx)
vector(real(4)), value :: vx

recipd2 recipf4 Computes the reciprocal of each element of vx.

vector(real(8)) function recipd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function recipf4(vx)
vector(real(4)), value :: vx

rqdrtd2 rqdrtf4 Computes the reciprocal of the quad root of each element of vx.

vector(real(8)) function rqdrtd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function rqdrtf4(vx)
vector(real(4)), value :: vx

rsqrtd2 rsqrtf4 Computes the reciprocal of the square root of each element of vx.

vector(real(8)) function rsqrtd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function rsqrtf4(vx)
vector(real(4)), value :: vx

sincosd2 sincosf4 Computes the sine and cosine of each element of vx.

subroutine sincosd2(vx, vs, vc)
vector(real(8)), value :: vx
vector(real(8)) vs, vc

subroutine sincosf4(vx, vs, vc)
vector(real(4)), value :: vx
vector(real(4)) vs, vc

sind2 sinf4 Computes the sine of each element of vx.

vector(real(8)) function sind2(vx)
vector(real(8)), value :: vx

vector(real(4)) function sinf4(vx)
vector(real(4)), value :: vx

sinhd2 sinhf4 Computes the hyperbolic sine of each element of vx.i

vector(real(8)) function sinhd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function sinhf4(vx)
vector(real(4)), value :: vx

sqrtd2 sqrtf4 Computes the square root of each element of vx.

vector(real(8)) function sqrtd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function sqrtf4(vx)
vector(real(4)), value :: vx

tand2 tanf4 Computes the tangent of each element of vx.

vector(real(8)) function tand2(vx)
vector(real(8)), value :: vx

vector(real(4)) function tanf4(vx)
vector(real(4)), value :: vx

tanhd2 tanhf4 Computes the hyperbolic tangent of each element of vx.

vector(real(8)) function tanhd2(vx)
vector(real(8)), value :: vx

vector(real(4)) function tanhf4(vx)
vector(real(4)), value :: vx

The MASS SIMD library interfaces include the following features:
  • The SIMD functions are marked pure. You can call them from pure procedures.
  • The intent of the argument is specified to assist in compiler error checking.
The following example shows the XL Fortran interface declarations of some of MASS SIMD library functions:
INTERFACE
  PURE VECTOR(REAL*4) FUNCTION acosf4 (x)
    VECTOR(REAL*4), value :: x 
  END FUNCTION

  PURE VECTOR(REAL*4) FUNCTION atan2f4 (x,y) 
    VECTOR(REAL*4), value :: x,y 
  END FUNCTION 

  PURE SUBROUTINE sincosf4 (x,s,c) 
   VECTOR(REAL*4), value :: x
   VECTOR(REAL*4), INTENT(OUT) :: s,c 
  END SUBROUTINE
END INTERFACE


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us