mbox series

[0/4] target/arm: Fix int64_to_float16 double-rounding

Message ID 20180814002653.12828-1-richard.henderson@linaro.org
Headers show
Series target/arm: Fix int64_to_float16 double-rounding | expand

Message

Richard Henderson Aug. 14, 2018, 12:26 a.m. UTC
In 88808a022c0, I tried to fix an overflow problem that affected float16
scaling by coverting first to float64 and then rounding after that.  

However, Laurent reported that -0x3ff40000000001 converted to float16
resulted in 0xfbfe instead of the expected 0xfbff.  This is caused by
the inexact conversion to float64.

Rather than build more logic into target/arm to compensate, just add
a function that takes a scaling parameter so that the whole thing is
done all at once with only one rounding.

I don't have a failing test case for the float-to-int paths, but it
seemed best to apply the same solution.


r~


Richard Henderson (4):
  softfloat: Add scaling int-to-float routines
  softfloat: Add scaling float-to-int routines
  target/arm: Use the int-to-float-scale softfloat routines
  target/arm: Use the float-to-int-scale softfloat routines

 include/fpu/softfloat.h | 169 ++++++++----
 fpu/softfloat.c         | 579 +++++++++++++++++++++++++++++++---------
 target/arm/helper.c     | 130 ++++-----
 3 files changed, 628 insertions(+), 250 deletions(-)

-- 
2.17.1

Comments

Alex Bennée Aug. 14, 2018, 8:32 a.m. UTC | #1
Richard Henderson <richard.henderson@linaro.org> writes:

> In 88808a022c0, I tried to fix an overflow problem that affected float16

> scaling by coverting first to float64 and then rounding after that.

>

> However, Laurent reported that -0x3ff40000000001 converted to float16

> resulted in 0xfbfe instead of the expected 0xfbff.  This is caused by

> the inexact conversion to float64.

>

> Rather than build more logic into target/arm to compensate, just add

> a function that takes a scaling parameter so that the whole thing is

> done all at once with only one rounding.

>

> I don't have a failing test case for the float-to-int paths, but it

> seemed best to apply the same solution.


Can't we add the constants to the fcvt test case?

>

>

> r~

>

>

> Richard Henderson (4):

>   softfloat: Add scaling int-to-float routines

>   softfloat: Add scaling float-to-int routines

>   target/arm: Use the int-to-float-scale softfloat routines

>   target/arm: Use the float-to-int-scale softfloat routines

>

>  include/fpu/softfloat.h | 169 ++++++++----

>  fpu/softfloat.c         | 579 +++++++++++++++++++++++++++++++---------

>  target/arm/helper.c     | 130 ++++-----

>  3 files changed, 628 insertions(+), 250 deletions(-)



--
Alex Bennée
Richard Henderson Aug. 14, 2018, 2:47 p.m. UTC | #2
On 08/14/2018 01:32 AM, Alex Bennée wrote:
> Can't we add the constants to the fcvt test case?


No, they're all half-to-integer.  This is integer-to-half.

We could write another one, I suppose, but it's not just
an add-one-line kind of thing.


r~
Alex Bennée Aug. 14, 2018, 3:38 p.m. UTC | #3
Richard Henderson <richard.henderson@linaro.org> writes:

> On 08/14/2018 01:32 AM, Alex Bennée wrote:

>> Can't we add the constants to the fcvt test case?

>

> No, they're all half-to-integer.  This is integer-to-half.


I'll add the int-to-float conversions, the whole thing could do with a
bit of a re-factor anyway.

>

> We could write another one, I suppose, but it's not just

> an add-one-line kind of thing.

>

>

> r~



--
Alex Bennée
no-reply@patchew.org Aug. 16, 2018, 1 a.m. UTC | #4
Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180814002653.12828-1-richard.henderson@linaro.org
Subject: [Qemu-devel] [PATCH 0/4] target/arm: Fix int64_to_float16 double-rounding

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
709fbe603d target/arm: Use the float-to-int-scale softfloat routines
b158c8d737 target/arm: Use the int-to-float-scale softfloat routines
5f86798067 softfloat: Add scaling float-to-int routines
8ec3fc49ea softfloat: Add scaling int-to-float routines

=== OUTPUT BEGIN ===
Checking PATCH 1/4: softfloat: Add scaling int-to-float routines...
Checking PATCH 2/4: softfloat: Add scaling float-to-int routines...
Checking PATCH 3/4: target/arm: Use the int-to-float-scale softfloat routines...
Checking PATCH 4/4: target/arm: Use the float-to-int-scale softfloat routines...
ERROR: space prohibited before that close parenthesis ')'
#57: FILE: target/arm/helper.c:11531:
+                         get_float_rounding_mode(fpst), )

ERROR: space prohibited before that close parenthesis ')'
#63: FILE: target/arm/helper.c:11536:
+                         get_float_rounding_mode(fpst), )

total: 2 errors, 0 warnings, 142 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Peter Maydell Aug. 20, 2018, 5:15 p.m. UTC | #5
On 14 August 2018 at 01:26, Richard Henderson
<richard.henderson@linaro.org> wrote:
> In 88808a022c0, I tried to fix an overflow problem that affected float16

> scaling by coverting first to float64 and then rounding after that.

>

> However, Laurent reported that -0x3ff40000000001 converted to float16

> resulted in 0xfbfe instead of the expected 0xfbff.  This is caused by

> the inexact conversion to float64.

>

> Rather than build more logic into target/arm to compensate, just add

> a function that takes a scaling parameter so that the whole thing is

> done all at once with only one rounding.

>

> I don't have a failing test case for the float-to-int paths, but it

> seemed best to apply the same solution.

>

>

> r~

>

>

> Richard Henderson (4):

>   softfloat: Add scaling int-to-float routines

>   softfloat: Add scaling float-to-int routines

>   target/arm: Use the int-to-float-scale softfloat routines

>   target/arm: Use the float-to-int-scale softfloat routines


series
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>


and applied to target-arm.next.

thanks
-- PMM
no-reply@patchew.org Aug. 20, 2018, 7:35 p.m. UTC | #6
Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180814002653.12828-1-richard.henderson@linaro.org
Subject: [Qemu-devel] [PATCH 0/4] target/arm: Fix int64_to_float16 double-rounding

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
776a29ed02 target/arm: Use the float-to-int-scale softfloat routines
c08c4abc59 target/arm: Use the int-to-float-scale softfloat routines
71c42653c5 softfloat: Add scaling float-to-int routines
040490a28a softfloat: Add scaling int-to-float routines

=== OUTPUT BEGIN ===
Checking PATCH 1/4: softfloat: Add scaling int-to-float routines...
Checking PATCH 2/4: softfloat: Add scaling float-to-int routines...
Checking PATCH 3/4: target/arm: Use the int-to-float-scale softfloat routines...
Checking PATCH 4/4: target/arm: Use the float-to-int-scale softfloat routines...
ERROR: space prohibited before that close parenthesis ')'
#58: FILE: target/arm/helper.c:11585:
+                         get_float_rounding_mode(fpst), )

ERROR: space prohibited before that close parenthesis ')'
#64: FILE: target/arm/helper.c:11590:
+                         get_float_rounding_mode(fpst), )

total: 2 errors, 0 warnings, 142 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com