Metalibm: A Mathematical Functions Code Generator
There are several different libraries with code for mathematical functions such as exp, log, sin, cos, etc. They provide only one implementation for each function. As there is a link between accuracy and performance, that approach is not optimal. Sometimes there is a need to rewrite a function’s implementation with the respect to a particular specification.
In this paper we present a code generator for parametrized implementations of mathematical functions. We discuss the benefits of code generation for mathematical libraries and present how to implement mathematical functions. We also explain how the mathematical functions are usually implemented and generalize this idea for the case of arbitrary function with implementation parameters.
Our code generator produces C code for parametrized functions within a known scheme: range reduction (domain splitting), polynomial approximation and reconstruction. This approach can be expanded to generate code for black-box functions, e.g. defined only by differential equations.
Keywordscode generation elementary functions mathematical libraries
Unable to display preview. Download preview PDF.
- 1.Loosemore, S., Stallman, R.M., et al.: The GNU C Library Reference Manual for version 2.19, Free Software Foundation, Inc.Google Scholar
- 2.Daramy-Loirat, C., Defour, D., de Dinechin, F., et al.: CR-LIBM. A library of correctly rounded elementary functions in double-precision, user’s manual (2013)Google Scholar
- 3.IEEE Computer Society, IEEE Standard for Floating-Point Arithmetic, IEEE Standard 754-2008 (August 2008)Google Scholar
- 6.Chevillard, S., Lauter, C., Joldeş, M.: Users manual for the Sollya tool, Release 4.0 (May 2013)Google Scholar
- 8.Muller, J.-M., Brisebarre, N., de Dinechin, F., et al.: Handbook of Floating-Point Arithmetic. Birkhäuser (2010)Google Scholar
- 9.Chevillard, S.: Évaluation efficace de fonctions numériques. Outils et exemples, PhD Thesis, ENS de Lyon (2009)Google Scholar
- 11.Lauter, C.: Arrondi correct de fonctions mathématiques, PhD Thesis, ENS de Lyon (2008)Google Scholar
- 12.Schewchuk, J.R.: Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates. Discrete & Computational Geometry (1997)Google Scholar
- 13.de Dinechin, F., Defour, D., Lauter, C.: Fast correct rounding of elementary functions in double precision using double-extended arithmetic, Research report, ENS de Lyon (2004)Google Scholar