Skip to main content
eScholarship
Open Access Publications from the University of California

UC Davis

UC Davis Electronic Theses and Dissertations bannerUC Davis

Engineering Floating-Point Correctness: Practical Testing and Tuning Techniques

Abstract

This dissertation explores testing techniques that follow from just a few of the many challenges that arise from the multifaceted nature of correctness in floating-point code.First, the floating-point oracle problem stems from both the difficulty of deriving a reliable ground truth -- due to the intrinsic approximation of the real-valued model of arithmetic by the floating-point model -- as well as a lack of formal specifications for correct behavior in floating-point implementations of non-elementary mathematical functions. This dissertation advances the field of oracle-free testing of floating-point code by introducing an automated approach to differential testing of numerical libraries. This approach is implemented in the prototype tool FPDiff, an evaluation of which finds 655 unique discrepancies between four numerical libraries: The GNU Scientific Library GSL written in C, the JavaScript library jmat, and the Python libraries mpmath and SciPy; after an automated reduction to 327 discrepancies, we find 150 that represent 125 unique bugs.Second is a facet of floating-point correctness testing for which there is a concrete specification: From the combination of domain errors inherent to the real-valued model and range-errors introduced by the floating-point model, the notion of a floating-point exception arises -- consequently, a program's correctness is also reliant on the compliance of its floating-point exception handling to a given specification. This dissertation advances the field of correctness testing of floating-point code by introducing a novel approach to testing this compliance. The approach is based on exception spoofing via binary rewriting and constraint solving and is implemented in the prototype tool EXCVATE. Our evaluation of EXCVATE finds exception-handling bugs in 5/26 level 1 and 2 BLAS functions across multiple implementations.Third is the challenge of maintaining correctness while exploiting the intrinsic approximation of the real-valued model of arithmetic by the floating-point model via automated and performance-guided floating-point precision tuning. This dissertation advances the field of floating-point precision tuning with a first-of-its-kind case study exploring the challenges that arise from extending established techniques typically evaluated on small benchmarks in the existing research to an important new domain: weather and climate models. Our case study demonstrates both the promise and the shortcomings of these techniques in such a setting. For instance, while our experiments automatically discover a variant of an MPAS-A hotspot with 1.95x speedup that incurs less error than the uniform 32-bit model, the performance gain is ultimately masked by the casting overhead incurred by passing data into and out of the hotspot. We also include a discussion of lessons learned and recommendations for future research directions.