Oracle® Solaris Studio 12.4: Numerical Computation Guide

Exit Print View

Updated: January 2015
 
 

5.5.1 Transcendental Functions

Most of the common math library functions standardized by programming languages, such ass exponential, logarithmic, and trigonometric functions, are expensive to round correctly, compared to rational arithmetic or algebraic functions like square root (sqrt()). Nearly correctly rounded functions are suitable for most purposes, and much faster. But the fastest nearly-correctly-rounded functions differ on different platforms.

  • Use portable code for the functions used by the application. One source of such code is the Freely-Distributable Math Library, fdlibm. It can be obtained from the Netlib software repository.

  • Avoid the –xvector option. The vectorized versions of transcendental functions are optimized for a particular platform and produce slightly different results on different platforms.

  • Avoid the x86 hardware transcendental instructions. Even though these instructions have error bounds almost as small as possible, they are not quite correctly rounded. Also, the Intel and AMD versions differ occasionally, even though both are quite good. With Oracle Solaris Studio C/C++ compilers, –xbuiltin=%default can be used, especially after –fast, to make sure that none of the transcendental instructions are substituted inline by the compiler for built-in transcendental functions. Likewise the –xnolibmil option after –fast disables inline templates; libm.il from Oracle Solaris Studio might have some templates that invoke the transcendental instructions.