From: "Alex Bennée" <alex.bennee@linaro.org>
To: Matt <mborgerson@gmail.com>
Cc: peter.maydell@linaro.org,
Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, aurelien@aurel32.net
Subject: Re: TCG Floating Point Support (Work in Progress)
Date: Thu, 30 Sep 2021 10:13:52 +0100 [thread overview]
Message-ID: <87bl4a768t.fsf@linaro.org> (raw)
In-Reply-To: <CADc=-s7RifpTSQ_6tYY4B4pze-wy6KprPo=J6Jvv0VVV3PU8DA@mail.gmail.com>
Matt <mborgerson@gmail.com> writes:
> Hello--
>
> I'm excited to share that I have been developing support for TCG
> floating point operations; specifically, to accelerate emulation of
> x86 guest code which heavily exercises the x87 FPU for a game console
> emulator project based on QEMU. So far, this work has shown great
> promise, demonstrating some dramatic performance improvements in
> emulation of x87 heavy code.
I've not reviewed the code as it is a rather large diff. For your proper
submission could you please ensure that your patch series is broken up
into discreet commits to aid review. It also aids bisection if
regressions are identified.
> The feature works in concert with unaccelerated x87 FPU helpers, and
> also allows total soft float helper fallback if the user discovers
> some issue with the hard float implementation.
The phrase "if the user discovers some issues" is a bit of a red flag.
We should always be striving for correct emulation of floating point.
Indeed we have recently got the code base to the point we pass all of
the Berkey softfloat test suite. This can be checked by running:
make check-softfloat
However the test code links directly to the softfloat code so won't work
with direct code execution. The existing 32/64 bit hardfloat
optimisations work within the helpers. While generating direct code is
appealing to avoid the cost of helper calls it's fairly well cached and
predicted code. Experience with the initial hardfloat code showed the
was still a performance win even with the cost of the helper call.
> For the TCG target,
> I've opted to implement it for x86-64 hosts using SSE2, although this
> could be extended to support full 80b double extended precision with
> host x87 support. I'm also in early development of an implementation
> for AArch64 hosts.
I don't think you'll see the same behaviour emulating an x87 on anything
that isn't an x87 because the boundaries for things like inexact
calculation will be different. Indeed if you look at the existing
hardfloat code function can_use_fpu() you will see we only call the host
processor function if the inexact bit is already set. Other wrappers
have even more checks for normal numbers. Anything that needs NaN
handling will fallback to the correct softfloat code.
I think there will be a wariness to merge anything that only works for a
single frontend/backend combination. Running translated x86 on x86 is
not the common case for TCG ;-)
> There are still some significant tasks to be done, like proper
> handling of exception flags, edge cases, and testing, to name a few.
These are the things that make correct handling of floating point hard.
> Once in a slightly more mature state, I do think this feature would
> make a natural addition to upstream QEMU and plan to submit it for
> consideration.
>
> I'm writing to the mailing list now to inform FPU maintainers and any
> other interested parties that this work is happening, to solicit any
> early feedback, and to extend an invitation to anyone interested in
> collaborating to expedite its upstreaming.
I'll happily review patches on the list that provide for an accelerated
FPU experience as long as the correctness is maintained.
> My initial TCG FP work can be found here:
> https://github.com/mborgerson/xemu/pull/464/commits
>
> Thanks,
> Matt
--
Alex Bennée
next prev parent reply other threads:[~2021-09-30 9:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-30 5:39 TCG Floating Point Support (Work in Progress) Matt
2021-09-30 7:30 ` Matt
2021-09-30 9:13 ` Alex Bennée [this message]
2021-10-01 2:47 ` Matt
2021-10-01 8:03 ` Alex Bennée
2021-10-02 2:07 ` Matt
2022-03-09 3:48 ` gaosong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bl4a768t.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=aurelien@aurel32.net \
--cc=mborgerson@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).