public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Hongtao Liu <crazylht@gmail.com>
Cc: Jason Merrill <jason@redhat.com>,
	Jonathan Wakely <jwakely@redhat.com>,
	"Joseph S. Myers" <joseph@codesourcery.com>,
	Bruce Korb <bkorb@gnu.org>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: Implement P1467R9 - Extended floating-point types and standard names compiler part except for bfloat16 [PR106652]
Date: Tue, 20 Sep 2022 10:51:18 +0200	[thread overview]
Message-ID: <Yyl/BkcvjpWW3Jyz@tucnak> (raw)
In-Reply-To: <CAMZc-bxB2fVAxVbBmqOj-ixTJybuX-V9dT2FvjrQR-wWRR7HkQ@mail.gmail.com>

On Tue, Sep 20, 2022 at 11:35:07AM +0800, Hongtao Liu wrote:
> > The question is (mainly for aarch64, arm and x86 backend maintainers) if we
> > shouldn't support it, in the PR there is a partial patch to do so, but
> > the big question is if it should be supported as the __bf16 type those
> > 3 targets use with u6__bf16 mangling and remove those *_invalid_* cases
> > and add conversions to/from at least SFmode but probably also DFmode, TFmode
> > and XFmode on x86 and implement arithmetics on those through conversion to
> > SFmode, performing arithmetics there and conversion back.
> > Conversion from BFmode to SFmode is easy, left shift by 16 and ought to be
> > implemented inline, SFmode -> BFmode conversion is harder,
> > I think it is roughly:
> I'm not sure if there should be any floating point exceptions for
> BFmode operation.
> For x86, there's no floating point exceptions for AVX512_BF16 related
> instructions

As long as __bf16 is just an extension, supporting or not supporting
exceptions on sNaNs is just fine I think, but I'm afraid it is different
for std::bfloat16_t.  If we claim we support it (define that type
in <stdfloat>, predefine __STD_BFLOAT16_TYPE__), then it needs to follow
ISO/IEC/IEEE 60559, and I'm afraid that means also exceptions and the like.
While the IEEE spec doesn't cover the exact bfloat16 format, C++ talks about
a format with these and these number of bits here and there that behaves
like in IEEE otherwise.
Whether we support std::bfloat16_t at all is our choice, if we do support
it, whether we support it with __bf16 underlying type or come up with
something different, it is up to us, and with -ffast-math/-Ofast etc.
we can certainly use hw instructions for it which don't raise exceptions.

At least that is my limited understanding of it...

	Jakub


  parent reply	other threads:[~2022-09-20  8:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  8:05 Jakub Jelinek
2022-09-12 19:36 ` Joseph Myers
2022-09-12 20:52   ` Jakub Jelinek
2022-09-12 21:00     ` Jakub Jelinek
2022-09-13 17:50     ` Joseph Myers
2022-09-16 11:48 ` Jason Merrill
2022-09-16 17:34   ` Jakub Jelinek
2022-09-17  8:58     ` Jason Merrill
2022-09-19 16:39       ` Jakub Jelinek
2022-09-26 21:15         ` Jason Merrill
2022-09-26 22:11           ` Jakub Jelinek
2022-09-20  3:35 ` Hongtao Liu
2022-09-20  7:14   ` Hongtao Liu
2022-09-20  8:51   ` Jakub Jelinek [this message]
2022-09-22 15:56     ` [RFC PATCH] __trunc{tf,xf,df,sf,hf}bf2, __truncbfhf2 and __extendbfsf2 Jakub Jelinek
2022-09-23  0:44       ` Hongtao Liu

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=Yyl/BkcvjpWW3Jyz@tucnak \
    --to=jakub@redhat.com \
    --cc=bkorb@gnu.org \
    --cc=crazylht@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=jwakely@redhat.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).