public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [RFC PATCH] libstdc++, v2: Partial library support for std::float{16,32,64,128}_t
Date: Mon, 17 Oct 2022 14:07:00 +0100	[thread overview]
Message-ID: <CACb0b4=JQOSQ48kw9+xdRhEROVsqScAPwbG4xzhsZBiB=CSNRA@mail.gmail.com> (raw)
In-Reply-To: <Y0vayeXfX4DsqW6g@tucnak>

On Sun, 16 Oct 2022 at 11:23, Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> As the __bf16 support is now in at least on x86_64/i686, I've
> updated my patch to cover bfloat16_t as well and implemented almost
> everything for <cmath> - the only thing missing I'm aware of is
> std::nextafter std::float16_t and std::bfloat16_t overloads (I think
> we probably need to implement that out of line somewhere, or inline? - might
> need inline asm barriers) and std::nexttoward overloads (those are
> intentional, you said there is a LWG issue about that).

Yes, that's now https://cplusplus.github.io/LWG/issue3790
The current proposed resolution is to just restore the C++20 functions
and not provide anything for the new types.

> If you want to have <cmath> done in a different way, e.g. the patch
> groups a lot of different function overloads by the floating point type,
> is that ok or do you want to have them one function at a time for all types,
> then next?

No, I think this way makes more sense. Otherwise the line count in the
file will baloon with all the repeated #if #endif directives.

The only comment I have about the <cmath> changes is that I think all
the new functions should be just 'constexpr' not 'inline
_GLIBCXX_CONSTEXPR'. The __STDCPP_FLOATN__ macros are only defined for
C++23, right? So _GLIBCXX_CONSTEXPR is always just 'constexpr' (it's
only something different for C++98), and that already implies 'inline'
too. So just:

constexpr _Float16
log10(_Float16 __x)
{ return _Float16(__builtin_log10f(__x)); }


> I could try to handle <complex> too, but am kind of lost there.
> The paper dropped the explicit std::complex specializations, can they stay
> around as is and should new overloads be added for the
> _Float*/__gnu_cxx::__bfloat16_t types?

The explicit specializations can stay, they do no harm.

I think to handle the new FP types we can modify the primary template
as shown in P1467. I don't think we'll need to add any new function
overloads for the new types.

I can take care of the <complex> changes.

> And I/O etc. support is missing, not sure I'm able to handle that and if it
> is e.g. possible to keep that support out of libstdc++.so.6, because what
> extended floating point types one has on a particular arch could change over
> time (I mean e.g. bfloat16_t support or float16_t support can be added
> etc.).

Yes, I think we can add the I/O functions as always_inline because all
they're going to do is convert the argument to float, double, or long
double and then call the existing overloads. There will be no new
virtual functions.

I can take care of that too.



> --- libstdc++-v3/include/bits/c++config.jj      2022-05-23 21:44:49.082847038 +0200
> +++ libstdc++-v3/include/bits/c++config 2022-10-14 22:32:55.411346463 +0200
> @@ -1,4 +1,4 @@
> -// Predefined symbols and macros -*- C++ -*-
> +       // Predefined symbols and macros -*- C++ -*-

This whitespace change looks accidental.

Apart from that and simplifying 'inline _GLIBCXX_CONSTEXPR' to just
'constexpr' this looks good for trunk.


  reply	other threads:[~2022-10-17 13:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27  8:45 [RFC PATCH] libstdc++: " Jakub Jelinek
2022-10-16 10:20 ` [RFC PATCH] libstdc++, v2: " Jakub Jelinek
2022-10-17 13:07   ` Jonathan Wakely [this message]
2022-10-17 16:25     ` [PATCH] libstdc++, v3: Partial library support for std::float{16,32,64,128}_t and std::bfloat16_t Jakub Jelinek
2022-10-18  9:18       ` Jonathan Wakely
2022-10-17 21:33     ` [RFC PATCH] libstdc++, v2: Partial library support for std::float{16, 32, 64, 128}_t Joseph Myers
2022-10-17 21:45       ` Jonathan Wakely
2022-10-17 21:50       ` Jakub Jelinek

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='CACb0b4=JQOSQ48kw9+xdRhEROVsqScAPwbG4xzhsZBiB=CSNRA@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=libstdc++@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).