From: Matthias Kretz <m.kretz@gsi.de>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: Thomas Rodgers <trodgers@redhat.com>,
libstdc++ <libstdc++@gcc.gnu.org>,
Gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] std::experimental::simd
Date: Sat, 14 Nov 2020 02:11:04 +0100 [thread overview]
Message-ID: <7016866.CdeeP7ohKn@excalibur> (raw)
In-Reply-To: <20201111234331.GA503596@redhat.com>
On Donnerstag, 12. November 2020 00:43:31 CET Jonathan Wakely wrote:
> On 08/05/20 21:03 +0200, Matthias Kretz wrote:
> >Here's my last update to the std::experimental::simd patch. It's currently
> >based on the gcc-10 branch.
> >
> >
> >+
> >+// __next_power_of_2{{{
> >+/**
> >+ * \internal
>
> We use @foo for Doxygen commens rather than \foo
Done.
> >+ * Returns the next power of 2 larger than or equal to \p __x.
> >+ */
> >+constexpr std::size_t
> >+__next_power_of_2(std::size_t __x)
> >+{
> >+ return (__x & (__x - 1)) == 0 ? __x
> >+ : __next_power_of_2((__x | (__x >> 1)) + 1);
> >+}
>
> Can this be replaced with std::__bit_ceil ?
>
> std::bit_ceil is C++20, but we provide __private versions of
> everything in <bit> for C++14 and up.
Ah good. I'll delete some code.
> >+// vvv ---- type traits ---- vvv
> >+// integer type aliases{{{
> >+using _UChar = unsigned char;
> >+using _SChar = signed char;
> >+using _UShort = unsigned short;
> >+using _UInt = unsigned int;
> >+using _ULong = unsigned long;
> >+using _ULLong = unsigned long long;
> >+using _LLong = long long;
>
> I have a suspicion some of these might clash with libc macros on some
> OS somewhere, but we can cross that bridge when we come to it.
I need those to help cutting down the code for 80 cols. ;-)
> >+// __make_dependent_t {{{
> >+template <typename, typename _Up> struct __make_dependent
> >+{
> >+ using type = _Up;
> >+};
> >+template <typename _Tp, typename _Up>
> >+using __make_dependent_t = typename __make_dependent<_Tp, _Up>::type;
>
> Do you need a distinct class template for this, or can
> __make_dependent_t be an alias to __type_identity<T>::type or
> something else that already exists?
With GCC it would suffice to use __type_identity<T>::type here. But Clang
rejects it. Clang sees that the first template argument is not used in the
definition of the alias and thus doesn't make _Up a dependent type.
> >+// __call_with_n_evaluations{{{
> >+template <size_t... _I, typename _F0, typename _FArgs>
> >+_GLIBCXX_SIMD_INTRINSIC constexpr auto
> >+__call_with_n_evaluations(std::index_sequence<_I...>, _F0&& __f0,
> >+ _FArgs&& __fargs)
>
> I'm not sure if it matters here, but old versions of G++ passed empty
> types (like index_sequence) using the wrong ABI. Passing them as the
> last argument makes it a non-issue. If they're not the last argument,
> you get incompatible code when compiling with -fabi-version=7 or
> lower.
These are all [[gnu::always_inline]]. So it shouldn't matter.
> >+// __is_narrowing_conversion<_From, _To>{{{
> >+template <typename _From, typename _To, bool =
> >std::is_arithmetic<_From>::value, + bool =
> >std::is_arithmetic<_To>::value>
>
> These could use is_arithmetic_v.
Right. That was me trying to work around a clang-format bug. Will fix. I'm in
the process of ditching clang-format anyway.
> >+{
> >+};
> >+
> >+template <typename _Tp>
> >+struct __is_narrowing_conversion<bool, _Tp, true, true> : public true_type
>
> This looks odd, bool to arithmetic type T is narrowing?
> I assume there's a reason for it, so maybe a comment explaining it
> would help.
Odd indeed. Either I wanted to take a shortcut to implement: "From is a
vectorizable type and every possibly value of From can be represented with
type value_type, or [...]". Or I wanted to swap bool and _Tp here and say that
anything other than bool converting to bool is narrowing.
I should clean this up.
>
> >+// _BitOps {{{
> >+struct _BitOps
> > [...]
> std::__popcount in <bit>
> > [...]
> std::__countl_zero in <bit>
Yes. I'll clean up all of _BitOps.
> >+template <typename _V>
>
> We generally avoid single letter names, although _V isn't in the list
> of BADNAMES in the manual, so maybe this one's OK.
>
> >+template <typename _Tp, typename _TVT = _VectorTraits<_Tp>,
> >+ typename _R
>
> Same for _R, it's not listed as a BADNAME.
I believe I checked the list. ;-)
> >+
> >+template <typename _Tp, typename = decltype(_Tp() & _Tp())>
> >+_GLIBCXX_SIMD_INTRINSIC constexpr _Tp
> >+__and(_Tp __a, _Tp __b) noexcept
>
> Calls to __and are done unqualified. Are they only with types that
> won't cause ADL to look outside namespace std?
>
> Even though __and is a reserved name, avoidign ADL has other benefits.
Called either with integers, [[gnu::vector_size(N)]] types, or
std::experimental::parallelism_v2::_SimdWrapper. I request a column limit
relaxation to at least 100 cols if I should qualify all of them with
std::experimental:: ;-)
> That's all for now ... not very far through the huge patch though.
> Generally this looks very good. The things mentioned above are
> stylistic or just remove some redundancy, they're not critical.
Thanks. I'll post a new patch ASAP. My tests are running.
-Matthias
--
──────────────────────────────────────────────────────────────────────────
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:[~2020-11-14 1:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 12:12 Matthias Kretz
2019-10-15 3:52 ` Thomas Rodgers
2019-10-24 8:26 ` Dr. Matthias Kretz
2020-02-10 16:49 ` Thomas Rodgers
2020-02-10 20:14 ` Thomas Rodgers
2020-01-07 11:01 ` Matthias Kretz
2020-01-07 11:17 ` Andrew Pinski
2020-01-07 13:19 ` Dr. Matthias Kretz
[not found] ` <3486545.znU0eCzeS4@excalibur>
[not found] ` <xkqeo8qyl8y8.fsf@trodgers.remote>
2020-05-08 19:03 ` Matthias Kretz
2020-11-11 23:43 ` Jonathan Wakely
2020-11-14 1:11 ` Matthias Kretz [this message]
2020-11-15 19:11 ` Matthias Kretz
2020-12-10 21:13 ` Matthias Kretz
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=7016866.CdeeP7ohKn@excalibur \
--to=m.kretz@gsi.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
--cc=trodgers@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).