Skip to contentSkip to conversation

softfloat tests based on berkeley's testfloat

PATCH New Emilio G. Cota 1 participant 4 messages Sep 13, 2018

lore
Share & tools
lore
#0 lore raw

v3 cover softfloat tests based on berkeley's testfloat

v2: https://lists.gnu.org/archive/html/qemu-devel/2018-09/msg00927.html

Changes:

- Add a patch to remove an unused FP primitive (patch 1). This patch can be applied before patches 2 and 3. The gcov numbers quoted in patch 3 assume that patch 1 has been applied.

- Rewrite fp-test.c from scratch, instead of trying to preserve most of the original testsoftfloat.c.

- Test all operations by default. A subset of ops can be chosen as well.

- Test rounding=even (-r even) by default. All rounding modes can be tested with `-r all'.

- Fix endianess issues. Turns out I was not including config-host.h when compiling softfloat/testfloat. The tests now give the same results on both little and big-endian hosts.

- Update git submodules to point to my github tree. This is a temporary fix; we're working on having the trees hosted on qemu.org.

- Support setting the initial FP flags for each test. This will allow us to test hardfloat, since it only kicks in when "inexact" is set.

Checkpatch reports some errors, but they're false positives.

You can fetch this series from:
https://github.com/cota/qemu/tree/fp-test-v3

The tests show that we probably have bugs in at least:

- f16_mulAdd, f32_mulAdd, f64_mulAdd

- extF80_lt_quiet, extF80_rem, extF80_roundToInt, extF80_to_f128, extF80_to_f32, extF80_to_f64

- f128_to_extF80, f128_to_f32, f128_to_f64, f32_to_extF80, f32_to_f128, f64_to_extF80, f64_to_f128, i32_to_extF80, i64_to_extF80

- f64_div

A sample of these errors are appended.
I do not have time to look into these, but I hope someone else does.

Once the muladd and div bugs are fixed, I'll resubmit the hardfloat patches (they do not affect conversions).

Thanks,

Emilio
---

$ ./fp-test -e 1 2>&1 | grep -A2 'Errors found'
Errors found in i32_to_extF80:
E801FFFF
        => -401B.BFF0000800000000 .....  expected -401B.BFF0000000000000 ....x
--
Errors found in i64_to_extF80:
03FFFFFFFC001000
        => +4038.FFFFFFFF00040000 .....  expected +4039.8000000000000000 ....x
--
Errors found in f16_mulAdd, rounding near_even, tininess before rounding:
+00.000  +1F.000  +1F.203  => +1F.203 .....  expected -1F.3FF v....
31754 tests performed; 1 error found.
--
Errors found in f16_mulAdd, rounding near_even, tininess after rounding:
+00.000  +1F.000  +1F.3FF  => +1F.3FF .....  expected -1F.3FF v....
32067 tests performed; 1 error found.
--
Errors found in f32_to_extF80:
+FF.000001
        => +7FFF.8000010000000000 v....  expected -7FFF.FFFFFFFFFFFFFFFF v....
--
Errors found in f32_to_f128:
+FF.000001  => +7FFF.0000020000000000000000000000 v....
        expected -7FFF.FFFFFFFFFFFFFFFFFFFFFFFFFFFF v....
--
Errors found in f32_mulAdd, rounding near_even, tininess before rounding:
+00.000000  +FF.000000  +FF.5F7FFF
        => +FF.5F7FFF .....  expected -FF.7FFFFF v....
--
Errors found in f32_mulAdd, rounding near_even, tininess after rounding:
+00.000000  +FF.000000  -FF.6C4D58
        => -FF.6C4D58 .....  expected -FF.7FFFFF v....
--
Errors found in f64_to_extF80:
-3FE.00FF7FFFFFFFF
        => -3FFE.807FBFFFFFFFF800 .....  expected -3FFE.807FC00000000000 ....x
--
Errors found in f64_to_f128:
-7FF.0100000000000  => -7FFF.0100000000000000000000000000 v....
        expected -7FFF.FFFFFFFFFFFFFFFFFFFFFFFFFFFF v....
--
Errors found in f64_mulAdd, rounding near_even, tininess before rounding:
+000.0000000000000  +7FF.0000000000000  +7FF.BF24ED0677699
        => +7FF.BF24ED0677699 .....  expected -7FF.FFFFFFFFFFFFF v....
--
Errors found in f64_mulAdd, rounding near_even, tininess after rounding:
+000.0000000000000  +7FF.0000000000000  +7FF.FFC0007FFFFFF
        => +7FF.FFC0007FFFFFF .....  expected -7FF.FFFFFFFFFFFFF v....
--
Errors found in f64_div, rounding near_even:
-001.FFFFFFEFF7FFF  -3FD.0000007FFDFFF
        => +003.FFFFFEEFFC00A ....x  expected +003.FFFFFEEFFC009 ....x
--
Errors found in extF80_to_f32, rounding near_even, tininess before rounding:
-7FFF.80401FFFFFFFFFFF  => -FF.00401F v....  expected -FF.7FFFFF v....
139 tests performed; 1 error found.
--
Errors found in extF80_to_f32, rounding near_even, tininess after rounding:
+7FFF.8000800000FFFFFF  => +FF.000080 v....  expected -FF.7FFFFF v....
71 tests performed; 1 error found.
--
Errors found in extF80_to_f64, rounding near_even, tininess before rounding:
+7FFF.930086F7F7267DA4
        => +7FF.26010DEFEE4CF v....  expected -7FF.FFFFFFFFFFFFF v....
--
Errors found in extF80_to_f64, rounding near_even, tininess after rounding:
+7FFF.800000FFFFFFF7FE
        => +7FF.000001FFFFFFE v....  expected -7FF.FFFFFFFFFFFFF v....
--
Errors found in extF80_to_f128:
+7FFF.8000000000000001  => +7FFF.0000000000000002000000000000 v....
        expected -7FFF.FFFFFFFFFFFFFFFFFFFFFFFFFFFF v....
--
Errors found in extF80_roundToInt, rounding near_even, exact:
+41CE.FFFFFFF000080000
        => +41CE.FFFFFFF000080000 .....  expected +41CF.8000000000000000 ....x
--
Errors found in extF80_rem:
+400B.8699A4DE2E7CE377  -403F.80000000001F0000
        => +400B.8699A4DE2E7CE377 .....  expected +400B.8699A50000000000 ....x
--
Errors found in extF80_lt_quiet:
+0000.0000000000000000  +0000.0000000000000000  => 1 .....  expected 0 .....
6 tests performed; 1 error found.
--
Errors found in f128_to_f32, rounding near_even, tininess before rounding:
+7FFF.130D47134E0139488DB1C13ECDAA
        => +FF.0986A3 v....  expected -FF.7FFFFF v....
--
Errors found in f128_to_f32, rounding near_even, tininess after rounding:
-7FFF.03FFFFFFFFFFFFFFFFFFFFFC0000
        => -FF.01FFFF v....  expected -FF.7FFFFF v....
--
Errors found in f128_to_f64, rounding near_even, tininess before rounding:
-7FFF.6312E1534A40638DAB5A8EDC5B64
        => -7FF.6312E1534A406 v....  expected -7FF.FFFFFFFFFFFFF v....
--
Errors found in f128_to_f64, rounding near_even, tininess after rounding:
-7FFF.000000000FFFFFFFFFFF80000000
        => -7FF.000000000FFFF v....  expected -7FF.FFFFFFFFFFFFF v....
--
Errors found in f128_to_extF80, rounding near_even, tininess before rounding:
-4000.00000000000000FFFEFFFFFFFFFF
        => -4000.8000000000000080 ....x  expected -4000.8000000000000000 ....x
--
Errors found in f128_to_extF80, rounding near_even, tininess after rounding:
+4003.38A57DBF7023D11088F01AE93540
        => +4003.9C52BEDFB811E888 ....x  expected +4003.9C52BF0000000000 ....x
#1 lore raw

PATCH v3 1/3 softfloat: remove float64_trunc_to_int

It has not had users since f83311e476 ("target-m68k: use floatx80 internally", 2017-06-21).

Note that no other bit-width has floatX_trunc_to_int.

---
 include/fpu/softfloat.h | 1 -
 fpu/softfloat.c         | 7 -------
 2 files changed, 8 deletions(-)
include/fpu/softfloat.h +0 -1
index cc1b58b029..8fd9f9bbae 100644
@@ -535,7 +535,6 @@ float128 float64_to_float128(float64, float_status *status);
 | Software IEC/IEEE double-precision operations.
 *----------------------------------------------------------------------------*/
 float64 float64_round_to_int(float64, float_status *status);
-float64 float64_trunc_to_int(float64, float_status *status);
 float64 float64_add(float64, float64, float_status *status);
 float64 float64_sub(float64, float64, float_status *status);
 float64 float64_mul(float64, float64, float_status *status);
fpu/softfloat.c +0 -7
index 59ca356d0e..9405f12a03 100644
@@ -1409,13 +1409,6 @@ float64 float64_round_to_int(float64 a, float_status *s)
     return float64_round_pack_canonical(pr, s);
 }
 
-float64 float64_trunc_to_int(float64 a, float_status *s)
-{
-    FloatParts pa = float64_unpack_canonical(a, s);
-    FloatParts pr = round_to_int(pa, float_round_to_zero, 0, s);
-    return float64_round_pack_canonical(pr, s);
-}
-
 /*
  * Returns the result of converting the floating-point value `a' to
  * the two's complement integer format. The conversion is performed
Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 2/3 gitmodules: add berkeley's softfloat + testfloat version 3

In reply to Emilio G. Cota

These are BSD-licensed so we can add them as submodules.

---
 .gitmodules                   | 6 ++++++
 tests/fp/berkeley-softfloat-3 | 1 +
 tests/fp/berkeley-testfloat-3 | 1 +
 3 files changed, 8 insertions(+)
 create mode 160000 tests/fp/berkeley-softfloat-3
 create mode 160000 tests/fp/berkeley-testfloat-3
.gitmodules +6 -0
index d108478e0a..43920b9b90 100644
@@ -43,3 +43,9 @@
 [submodule "roms/u-boot-sam460ex"]
 	path = roms/u-boot-sam460ex
 	url = git://git.qemu.org/u-boot-sam460ex.git
+[submodule "tests/fp/testfloat"]
+	path = tests/fp/berkeley-testfloat-3
+	url = git://github.com/cota/berkeley-testfloat-3
+[submodule "tests/fp/berkeley-softfloat-3"]
+	path = tests/fp/berkeley-softfloat-3
+	url = git://github.com/cota/berkeley-softfloat-3
tests/fp/berkeley-softfloat-3 new file +1 -0
new file mode 160000
index 0000000000..b64af41c32
@@ -0,0 +1 @@
+Subproject commit b64af41c3276f97f0e181920400ee056b9c88037
tests/fp/berkeley-testfloat-3 new file +1 -0
new file mode 160000
index 0000000000..ca9fa2ba05
@@ -0,0 +1 @@
+Subproject commit ca9fa2ba05625ba929958f163b01747e07dd39cc
Signature · 1 line
2.17.1
#3 lore raw

PATCH v3 3/3 tests/fp/fp-test: add floating point tests

In reply to Emilio G. Cota

By leveraging berkeley's softfloat and testfloat.

With this we get decent coverage of softfloat.c:

$ ./fp-test -r even:	67.22% coverage
$ ./fp-test -r all:	73.11% coverage

Note that we do not yet test parts of softfloat.c that aren't in the original softfloat library, namely:

- denormal inputs
- *_to_int16/uint16 conversions
- scalbn for fixed point
- muladd variants
- min/max
- exp2
- log2
- float*_compare (except float16_compare)

---
 configure              |   2 +
 tests/fp/platform.h    |  41 ++
 tests/fp/fp-test.c     | 992 +++++++++++++++++++++++++++++++++++++++++
 tests/fp/wrap.inc.c    | 653 +++++++++++++++++++++++++++
 tests/Makefile.include |   3 +
 tests/fp/.gitignore    |   1 +
 tests/fp/Makefile      | 597 +++++++++++++++++++++++++
 7 files changed, 2289 insertions(+)
 create mode 100644 tests/fp/platform.h
 create mode 100644 tests/fp/fp-test.c
 create mode 100644 tests/fp/wrap.inc.c
 create mode 100644 tests/fp/.gitignore
 create mode 100644 tests/fp/Makefile
configure +2 -0
index 58862d2ae8..b02da8c0b4 100755
@@ -7451,12 +7451,14 @@ fi
 
 # build tree in object directory in case the source is not in the current directory
 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
+DIRS="$DIRS tests/fp"
 DIRS="$DIRS docs docs/interop fsdev scsi"
 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
 DIRS="$DIRS roms/seabios roms/vgabios"
 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
+FILES="$FILES tests/fp/Makefile"
 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
 FILES="$FILES pc-bios/spapr-rtas/Makefile"
 FILES="$FILES pc-bios/s390-ccw/Makefile"
tests/fp/platform.h new file +41 -0

41 lines not on this page · raw message

tests/fp/fp-test.c new file +992 -0

992 lines not on this page · raw message

tests/fp/wrap.inc.c new file +653 -0

653 lines not on this page · raw message

tests/Makefile.include +3 -0
index 87c81d1dcc..363f133101 100644
@@ -657,6 +657,9 @@ tests/qht-bench$(EXESUF): tests/qht-bench.o $(test-util-obj-y)
 tests/test-bufferiszero$(EXESUF): tests/test-bufferiszero.o $(test-util-obj-y)
 tests/atomic_add-bench$(EXESUF): tests/atomic_add-bench.o $(test-util-obj-y)
 
+tests/fp/%:
+	$(MAKE) -C $(dir $@) $(notdir $@)
+
 tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\
 	hw/core/bus.o \
tests/fp/.gitignore new file +1 -0
new file mode 100644
index 0000000000..8d45d18ac4
@@ -0,0 +1 @@
+fp-test
tests/fp/Makefile new file +597 -0

597 lines not on this page · raw message

Signature · 1 line
2.17.1