From: Richard Biener <rguenther@suse.de>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: Andrew Stubbs <ams@codesourcery.com>,
Kwok Cheung Yeung <kcy@codesourcery.com>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] amdgcn: Add support for additional natively supported floating-point operations
Date: Fri, 9 Sep 2022 10:16:27 +0000 (UTC) [thread overview]
Message-ID: <nycvar.YFH.7.77.849.2209091011440.20505@jbgna.fhfr.qr> (raw)
In-Reply-To: <08966068-719a-30d1-5b71-7cf839e507e7@codesourcery.com>
On Fri, 9 Sep 2022, Tobias Burnus wrote:
> On 09.09.22 10:10, Andrew Stubbs wrote:
> On 08.09.22 22:38, Kwok Cheung Yeung wrote:
> The instructions for the transcendental functions are documented to have
> limited numerical precision, so they are only used if
> unsafe_math_optimizations are enabled for now.
>
> -funsafe-math-optimizations implies -fno-signed-zeros, -fno-trapping-math,
> -fassociative-math,
> and -freciprocal-math. All of them reduce precision and my violate IEEE or
> ISO/language standards.
>
> However, I think it is rather surprising to have all of the sudden only a
> precision of the
> order of 100,000,000 ULP instead of ~4 ULP as to be expected. That's a
> precision loss of the
> order of 10^8 or 2^29 which is huge!
>
> For program deliberately using double precision, it can be too much ? even if
> they do not need
> double precision in reality. (Weather forecast system recently moved to single
> precision as the
> quality is similar and benefits of faster results/finer grids or longer
> forecast times prevail.)
>
> As this behavior is highly surprising, I think it should be at least
> documented.
>
> In https://gcc.gnu.org/PR105246 , I suggested a new flag (such as
> -mpermit-reduced-precision) to
> make it possible turn it on/off explicitly (might be still enabled by
> -funsafe-math-optimizations);
> alternatively, it could also be handled as initial guess for the result which
> is then refined
> in some iteration steps. (It could also be combined to give the user the
> choice.)
>
> While still being convinced that a flag makes more sense than just documenting
> it,
> I have nonetheless attached a documentation attempt.
>
> Thoughts?
I agree - for example powerpc has -mrecip= to control which instructions
to use (float/double rsqrt or inverse) and -mrecip-precision to
specify whether further iteration is done or not.
x86 has similar but does always perform newton raphson iteration,
documenting 2 ulp instead of 0.5 ulp precision.
Your suggested huge reduction in precision isn't usually acceptable
and should be always explicitely enabled.
Richard.
next prev parent reply other threads:[~2022-09-09 10:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 20:38 Kwok Cheung Yeung
2022-09-09 8:10 ` Andrew Stubbs
2022-09-09 9:15 ` Tobias Burnus
2022-09-09 10:16 ` Richard Biener [this message]
2022-09-09 12:20 ` GCN: Add -mlow-precision-sqrt for double-precision sqrt [PR105246] (was: Re: [PATCH] amdgcn: Add support for additional natively supported floating-point operations) Tobias Burnus
2022-09-09 12:40 ` Andrew Stubbs
2022-09-09 12:32 ` [PATCH] amdgcn: Add support for additional natively supported floating-point operations Stubbs, Andrew
2022-09-09 17:57 ` Joseph Myers
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=nycvar.YFH.7.77.849.2209091011440.20505@jbgna.fhfr.qr \
--to=rguenther@suse.de \
--cc=ams@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kcy@codesourcery.com \
--cc=tobias@codesourcery.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).