From: Matthias Kretz <m.kretz@gsi.de>
To: <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>
Cc: <libstdc++@gcc.gnu.org>, David Malcolm <dmalcolm@redhat.com>,
Jonathan Wakely <jwakely@redhat.com>
Subject: Re: [PATCH] Add gnu::diagnose_as attribute
Date: Tue, 1 Jun 2021 23:01:44 +0200 [thread overview]
Message-ID: <3673050.7O1Wp1SQZX@excalibur> (raw)
In-Reply-To: <cdfc040a-4195-d453-b01e-c1eb7ed33e3a@redhat.com>
On Tuesday, 1 June 2021 21:12:18 CEST Jason Merrill wrote:
> On 5/28/21 3:42 AM, Matthias Kretz wrote:
> > On Friday, 28 May 2021 05:05:52 CEST Jason Merrill wrote:
> >> I'd think you could get the same effect from a hypothetical
> >>
> >> namespace [[gnu::diagnose_as]] stdx = std::experimental;
> >>
> >> though we'll need to add support for attributes on namespace aliases to
> >> the grammar.
> >
> > Right, but then two of my design goals can't be met:
> >
> > 1. Diagnostics have an improved signal-to-noise ratio out of the box.
> >
> > 2. We can use replacement names that are not valid identifiers.
>
> This is the basic disconnect: I think that these goals are
> contradictory, and that replacement names that are not valid identifiers
> will just confuse users that don't know about them.
With signal-to-noise ratio I meant the ratio (averaged over all GCC users - so
yes, we can't give actual numbers for these):
#characters one needs to read to understand / #total diagnostic characters.
Or more specifically
1 - #characters that are distracting from understanding the issue / #total
diagnostic characters.
Consider that for the stdx::simd case I regularly hit the problem that vim's
QuickFix truncates at 4095 characters and the message basically just got
started (i.e. it's sometimes impossible to use vim's QuickFix to understand
errors involving stdx::simd). There's *a lot* of noise that must be removed
*per default*.
WRT "invalid identifiers", there are two types:
(1) string of characters that is not a valid C++ identifier
(2) valid C++ identifier, but not defined for the given TU
(2) can be confusing, I agree, but doesn't have to be. (1) provides a stronger
hint that something is either abbreviated or intentionally hidden from the
user.
If I write `std::experimental::simd<float>` in my code and get a diagnostic
that says 'stdₓ::simd<float, simd_abi::[SSE]>' then it's relatively easy to
make the connection what happened here: 'stdₓ' clearly must mean something
else than a literal 'stdₓ' in my code. The user knows there's no `std::simd'
so it must be `std::experimental::simd`. (Note that once
std::experimental::simd goes into the IS, I would be the first to propose a
change for 'stdₓ::simd' back to 'std::experimental::simd'.)
> If a user sees stdx::foo in a diagnostic and then tries to refer to
> stdx::foo and gets an error, the diagnostic is not more helpful than one
> that uses the fully qualified name.
Hmm, if GCC prints an actual suggestion like "write 'stdₓ::foo' here" then
yes, I agree. That should not make use of diagnose_as.
> Jonathan, David, any thoughts on this issue?
>
> > I can imagine using it to make _Internal __names more readable while at
> > the
> > same time discouraging users to utter them in their own code. Sorry for
> > the
> > bad code obfuscation example above.
> >
> > An example for consideration from stdx::simd:
> > namespace std {
> > namespace experimental {
> > namespace parallelism_v2 [[gnu::diagnose_as("stdx")]] {
> > namespace simd_abi [[gnu::diagnose_as("simd_abi")]] {
> >
> > template <int _Bytes>
> >
> > struct _VecBuiltin;
> >
> > template <int _Bytes>
> >
> > struct _VecBltnBtmsk;
> >
> > #if x86
> >
> > using __ignore_me_0 [[gnu::diagnose_as("[SSE]")]] = _VecBuiltin<16>;
> > using __ignore_me_1 [[gnu::diagnose_as("[AVX]")]] = _VecBuiltin<32>;
> > using __ignore_me_2 [[gnu::diagnose_as("[AVX512]")]] =
> > _VecBltnBtmsk<64>;
> >
> > #endif
> > }}}}
> >
> > Then diagnostics would print 'stdx::simd<float, simd_abi::[AVX512]>'
> > instead of 'stdx::simd<float, simd_abi::_VecBltnBtmsk<64>>'. (Users utter
> > the type by saying e.g. 'stdx::native_simd<float>', while compiling with
> > AVX512 flags.)
>
> Wouldn't it be better to print stdx::native_simd<float> if that's how
> the users write the type?
No. For example, I might expect that native_simd maps to AVX-512 vectors but
forgot the relevant -m flag(s). If the diagnostics show 'simd<float,
simd_abi::[SSE]>' I have a good chance of catching that issue.
And the other way around: If I wrote `stdx::simd<float>` and it happens to be
the same type as the native_simd typedef, it would show the latter in
diagnostics. Similar issue with asking for a simd ABI with
`simd_abi::deduce_t<float, 16>`: I typically don't want to know whether that's
also native_simd<float> but rather what exact simd_abi I got. And no, as a
user I don't typically care about the libstdc++ implementation details but
what those details mean.
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
std::experimental::simd https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────
next prev parent reply other threads:[~2021-06-01 21:01 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-23 15:16 [RFC] " Matthias Kretz
2021-04-27 9:46 ` Jonathan Wakely
2021-05-04 11:13 ` [PATCH] " Matthias Kretz
2021-05-04 13:34 ` David Malcolm
2021-05-04 14:23 ` Matthias Kretz
2021-05-04 14:32 ` Matthias Kretz
2021-05-04 19:00 ` David Malcolm
2021-05-04 19:22 ` Matthias Kretz
2021-05-14 16:05 ` Martin Sebor
2021-05-26 21:33 ` Matthias Kretz
2021-05-27 17:39 ` Jason Merrill
2021-05-27 18:54 ` Matthias Kretz
2021-05-27 21:15 ` Jason Merrill
2021-05-27 22:07 ` Matthias Kretz
2021-05-28 3:05 ` Jason Merrill
2021-05-28 7:42 ` Matthias Kretz
2021-06-01 19:12 ` Jason Merrill
2021-06-01 21:01 ` Matthias Kretz [this message]
2021-06-11 10:01 ` Matthias Kretz
2021-06-15 15:51 ` Jason Merrill
2021-06-15 20:56 ` Matthias Kretz
2021-06-16 0:48 ` Jason Merrill
2021-06-22 7:30 ` Matthias Kretz
2021-06-22 19:52 ` Jason Merrill
2021-06-22 20:01 ` Matthias Kretz
2021-06-22 20:12 ` Jason Merrill
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=3673050.7O1Wp1SQZX@excalibur \
--to=m.kretz@gsi.de \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=jwakely@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).