From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Emilio G. Cota" <cota@braap.org>
Cc: qemu-devel@nongnu.org, laurent.desnogues@gmail.com,
Aurelien Jarno <aurelien@aurel32.net>,
Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [RFC PATCH] fpu: add compile time check for old glibc/libm and fma
Date: Mon, 07 Jan 2019 12:42:55 +0000 [thread overview]
Message-ID: <87k1jgvdtc.fsf@linaro.org> (raw)
In-Reply-To: <20181221193037.GB11197@flamenco>
Emilio G. Cota <cota@braap.org> writes:
> On Thu, Dec 20, 2018 at 11:10:08 +0000, Alex Bennée wrote:
> (snip)
>> +#if defined(__GLIBC__) && (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 12)
>> +#define QEMU_HARDFLOAT_USE_FMA 0
>> +#else
>> +#define QEMU_HARDFLOAT_USE_FMA 1
>> +#endif
>> +#else
>> +#define QEMU_HARDFLOAT_USE_FMA 1
>> +#endif
>> +
>> /*
>> * QEMU_HARDFLOAT_USE_ISINF chooses whether to use isinf() over
>> * float{32,64}_is_infinity when !USE_FP.
>> @@ -1551,6 +1570,9 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s)
>> ub.s = xb;
>> uc.s = xc;
>>
>> + if (!QEMU_HARDFLOAT_USE_FMA) {
>> + goto soft;
>> + }
>
> I don't think this should be a compile-time check; if the QEMU binary
> is run on a system with a newer, fixed glibc (or any other libc), then
> we'll have disabled fma hardfloat unnecessarily.
>
> What do you think about the following?
>
> Laurent: if you want to test the below, you can pull it from
> https://github.com/cota/qemu/tree/fma-fix
>
> Thanks,
>
> Emilio
> ---
> commit ddeec29a2c33550c5d018aeea05d45a23579ae1b
> Author: Emilio G. Cota <cota@braap.org>
> Date: Fri Dec 21 14:08:57 2018 -0500
>
> softfloat: enforce softfloat if the host's FMA is broken
>
> The added branch is marked as unlikely and therefore its impact
> on performance (measured with fp-bench) is within the noise range
> when measured on an Intel(R) Xeon(R) Gold 6142 CPU @ 2.60GHz.
>
> Laurent Desnogues <laurent.desnogues@gmail.com>
> Signed-off-by: Emilio G. Cota <cota@braap.org>
I've applied b8cc3928cee7b1d91bf39c86bec4801b9dc612e1 from your tree to
fpu/next although the numbers look a bit odd. I see:
Before:
143.83 MFlops
89.34 MFlops
After:
150.20 MFlops
85.73 MFlops
On my i7-4770 where as your commit seems to show a big jump in
performance which is odd as this is preventing a bug not enabling FMA.
> +
> +static void __attribute__((constructor)) softfloat_init(void)
> +{
> + union_float64 ua, ub, uc, ur;
> +
> + if (QEMU_NO_HARDFLOAT) {
> + return;
> + }
> +
> + /*
> + * Test that the host's FMA is not obviously broken. For example,
> + * glibc < 2.23 can perform an incorrect FMA on certain hosts; see
> + * https://sourceware.org/bugzilla/show_bug.cgi?id=13304
> + */
> + ua.s = 0x0020000000000001;
> + ub.s = 0x3ca0000000000000;
> + uc.s = 0x0020000000000000;
> + ur.h = fma(ua.h, ub.h, uc.h);
> + if (ur.s != 0x0020000000000001) {
> + host_fma_is_broken = true;
> + }
> +}
I'm fine with the cpuid stuff at the bottom of softfloat for now. We can
move it later if the other micro-architectures want to get in on the
detecting features game.
--
Alex Bennée
next prev parent reply other threads:[~2019-01-07 12:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-20 11:10 [Qemu-devel] [RFC PATCH] fpu: add compile time check for old glibc/libm and fma Alex Bennée
2018-12-20 13:10 ` Aleksandar Markovic
2018-12-21 14:14 ` Laurent Desnogues
2018-12-21 19:30 ` Emilio G. Cota
2018-12-21 22:01 ` Richard Henderson
2019-01-07 11:50 ` Alex Bennée
2019-01-07 12:42 ` Alex Bennée [this message]
2018-12-22 6:40 ` Aleksandar Markovic
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=87k1jgvdtc.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=aurelien@aurel32.net \
--cc=cota@braap.org \
--cc=laurent.desnogues@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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).