Faster Math Functions, Soundly
Abstract
Standard library implementations of functions like sin and exp optimize for accuracy, not speed, because they are intended for generalpurpose use. But applications tolerate inaccuracy from cancellation, rounding error, and singularitiessometimes even very high errorand many application could tolerate error in function implementations as well. This raises an intriguing possibility: speeding up numerical code by tuning standard function implementations. This paper thus introduces OpTuner, an automatic method for selecting the best implementation of mathematical functions at each use site. OpTuner assembles dozens of implementations for the standard mathematical functions from across the speedaccuracy spectrum. OpTuner then uses error Taylor series and integer linear programming to compute optimal assignments of function implementation to use site and presents the user with a speedaccuracy Pareto curve they can use to speed up their code. In a case study on the POVRay ray tracer, OpTuner speeds up a critical computation, leading to a whole program speedup of 9% with no change in the program output (whereas human efforts result in slower code and lowerquality output). On a broader study of 37 standard benchmarks, OpTuner matches 216 implementations to 89 use sites and demonstrates speedups of 107% for negligible decreases in accuracy and of up to 438% for errortolerant applications.
 Publication:

arXiv eprints
 Pub Date:
 July 2021
 arXiv:
 arXiv:2107.05761
 Bibcode:
 2021arXiv210705761B
 Keywords:

 Computer Science  Mathematical Software;
 Computer Science  Software Engineering