John Hauser

Berkeley TestFloat

Berkeley TestFloat is a small collection of programs for testing whether an implementation of binary floating-point conforms to the IEEE Standard for Floating-Point Arithmetic. All operations required by the original 1985 version of the IEEE Standard can be tested, except for conversions to and from decimal. With the current release, the following binary formats can be tested: 16-bit half-precision, 32-bit single-precision, 64-bit double-precision, 80-bit double-extended-precision, and/or 128-bit quadruple-precision. TestFloat cannot test decimal floating-point.

TestFloat performs relatively simple tests designed to check the fundamental soundness of a floating-point implementation. All of the modes and special cases of the IEEE Standard are tested. However, TestFloat is not especially good at testing difficult rounding cases for divisions and square roots. It also makes no attempt to find bugs specific to SRT division and the like (such as the infamous Pentium division bug). Pointers to software that tests for such failures are provided later on this page.

TestFloat works by comparing the behavior of the floating-point under test with that of the Berkeley SoftFloat software implementation of floating-point. Any differences found are reported as probable errors in the floating-point being tested. It is the responsibility of the user to verify that the discrepencies TestFloat finds actually represent faults in the floating-point being tested. Unfortunately, TestFloat’s output is not easily interpreted. Detailed knowledge of the IEEE Standard is required to use TestFloat responsibly.

TestFloat is distributed in the form of ISO/ANSI C source code and should be compilable with almost any ISO-compliant C compiler. Using the GNU C Compiler (gcc), the TestFloat programs have been compiled and run on several platforms. To test a new floating-point implementation, some additional code will likely be needed for invoking the new floating-point.

Since Release 3, TestFloat has depended on the existence of a 64-bit integer type in C. If the C compiler used to compile TestFloat does not support 64-bit integers, it is still possible to use the older Release 2c to test the two most common formats, 32-bit single-precision and 64-bit double-precision, but not the other formats.

Release 3e

Release 3 was a complete rewrite of TestFloat, funded by the University of California, Berkeley. Paralleling the upgrades in Release 3 of SoftFloat, the matching release of TestFloat added the abilities to test conversions between floating-point and unsigned integers (both 32-bit and 64-bit) and fused multiply-add operations. Unlike earlier versions, Release 3 and later have a U.C. Berkeley open-source license (specified in the documentation).

The current version of TestFloat is Release 3e (2018 January). This version differs from earlier releases 3b through 3d in only minor ways. Compared to the original Release 3:

This release adds a few more small improvements, including modifying the expected behavior of rounding mode odd and fixing a minor bug in the all-in-one testfloat program.

If you have been successfully using an earlier release of TestFloat, you may not need to upgrade to this release. However, you may still want to upgrade your version of Berkeley SoftFloat, because versions prior to Release 3d were found to have bugs in several of the square root functions.

More information about Berkeley TestFloat Release 3e is in the following files from the TestFloat package:
-- TestFloat-general.html - Berkeley TestFloat Release 3e: General Documentation.
-- TestFloat-source.html - Berkeley TestFloat Release 3e: Source Documentation.
-- TestFloat-history.html - History of Berkeley TestFloat, to Release 3e.

The following archive contains all source code and documentation for Release 3e:
-> zip archive, TestFloat-3e.zip [430 kB].

The older Releases 3a through 3d are still available here:
-> zip archive, TestFloat-3d.zip [426 kB].
-> zip archive, TestFloat-3c.zip [425 kB].
-> zip archive, TestFloat-3b.zip [424 kB].
-> zip archive, TestFloat-3a.zip [358 kB].

Release 2c

For those who may need it, TestFloat versions preceding Release 3 have been updated to Release 2c (2015 January). The only changes in this release compared to the earlier Release 2a are these:

If you have been successfully using TestFloat Release 2a on a 32-bit processor (or compiled as though for a 32-bit processor), you probably do not need to download this release.
-> zip archive, TestFloat-2c.zip [101 kB].

Dependence on Berkeley SoftFloat

TestFloat requires Berkeley SoftFloat, which is not included in the TestFloat archive.
[] Berkeley SoftFloat is a free, high-quality software implementation of binary floating-point that conforms to the IEEE Standard for Floating-Point Arithmetic.

Testing SoftFloat

The TestFloat package includes a testsoftfloat program solely for testing SoftFloat. SoftFloat is tested by comparing it against yet another, different software floating-point that is simpler and also slower than SoftFloat. Although one can’t be completely certain that the other floating-point is correct either, it’s unlikely that it would make exactly the same mistakes as SoftFloat. Any unexpected discrepancies between the two floating-points are flagged as probable errors in one or the other.

Other software for testing floating-point

[] The UCBTEST suite includes programs for testing the rounding of multiplication, division, and square roots, and also for testing the accuracy of elementary transcendental functions. UCBTEST can be found in the NetLib Repository, under the fp (floating-point) directory.
[] W. Kahan at U.C. Berkeley has made a few test programs available on the Web, notably the SRTEST program for testing SRT division.
[] Fred Tydeman (Tydeman Consulting) provides the C11/C99 FPCE Test Suite and several other programs for testing the floating-point compliance of C and C++ compilers and libraries.

Credit and contacts

Berkeley TestFloat was written by me, John R. Hauser. Funding for the development of TestFloat Release 3 and later was provided indirectly by portions of grants to U.C. Berkeley from Microsoft, Intel, DARPA, Nokia, NVIDIA, Oracle, Samsung, and Google, and by a portion of a U.C. Discovery Grant. The TestFloat documentation has more details.

Bugs in TestFloat and other comments can be reported to me at jh@jhauser.us.



John Hauser, 2018 January 23