CPFloat: A C Library for Simulating Low-precision Arithmetic
Open Access
- 17 June 2023
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Mathematical Software
- Vol. 49 (2) , 1-32
Abstract
One can simulate low-precision floating-point arithmetic via software by executing each arithmetic operation in hardware and then rounding the result to the desired number of significant bits. For IEEE-compliant formats, rounding requires only standard mathematical library functions, but handling subnormals, underflow, and overflow demands special attention, and numerical errors can cause mathematically correct formulae to behave incorrectly in finite arithmetic. Moreover, the ensuing implementations are not necessarily efficient, as the library functions these techniques build upon are typically designed to handle a broad range of cases and may not be optimized for the specific needs of rounding algorithms. CPFloat is a C library for simulating low-precision arithmetics. It offers efficient routines for rounding, performing mathematical computations, and querying properties of the simulated low-precision format. The software exploits the bit-level floating-point representation of the format in which the numbers are stored and replaces costly library calls with low-level bit manipulations and integer arithmetic. In numerical experiments, the new techniques bring a considerable speedup (typically one order of magnitude or more) over existing alternatives in C, C++, and MATLAB. To our knowledge, CPFloat is currently the most efficient and complete library for experimenting with custom low-precision floating-point arithmetic.Keywords
Funding Information
- Royal Society, by Istituto Nazionale di Alta Matematica INdAM-GNCS Project 2020, and by Wenner-Gren Foundations (UPD2019-0067)
- EPSRC Doctoral Prize Fellowship and by EPSRC (EP/P020720/1)
- Department of Mathematics, the University of Manchester
- School of Science and Technology, Örebro University, Örebro (SE-701 82)
This publication has 38 references indexed in Scilit:
- IEEE754 Precision- k base-β Arithmetic Inherited by Precision- m Base-β Arithmetic for k < mACM Transactions on Mathematical Software, 2016
- Coping with Silent Errors in HPC Applications2016
- Quad Precision Floating Point on the IBM z132016
- SIPE: Small Integer Plus Exponent2013
- A Microbenchmark Suite for OpenMP Tasks2012
- MPFRACM Transactions on Mathematical Software, 2007
- INTLAB — INTerval LABoratory1999
- What every computer scientist should know about floating-point arithmeticACM Computing Surveys, 1991
- Reprint of a Note on Rounding-Off ErrorsSIAM Review, 1959
- The November meeting in PasadenaBulletin of the American Mathematical Society, 1950