From: Matthias Kretz <m.kretz@gsi.de>
To: Martin Reinecke <martin@mpa-garching.mpg.de>,
GCC Development <gcc@gcc.gnu.org>
Subject: Re: Determining maximum vector length supported by the CPU?
Date: Wed, 22 May 2019 09:37:00 -0000 [thread overview]
Message-ID: <8204676.kP6zuPok09@minbar> (raw)
In-Reply-To: <719f4268-b2a8-e950-8005-7af26e8a1ef3@mpa-garching.mpg.de>
On Mittwoch, 22. Mai 2019 11:27:25 CEST Martin Reinecke wrote:
> Still, I would need a way to determine how long the vectors actually
> are. But it would probably be enough to measure this at runtime then.
FWIW, something that took me way too long to figure out: You can use vector
builtins very conveniently in C++ with the traits I define at https://
github.com/VcDevel/std-simd/blob/59e6348a9d34b4ef4f5ef1fc4f423dd75e1987f3/
experimental/bits/simd.h#L925 (ignore _SimdWrapper: I'm working on phasing it
out after I discovered the _VectorTraits solution). You'll need __vector_type,
__is_vector_type and _VectorTraits and then you can write:
template <typename T, typename VT = VectorTraits<T>>
void f(T x) {
using element_type = typename VT::value_type;
constexpr auto N = VT::_S_width;
...
}
f(x) only participates in overload resolution if x is a vector builtin type
because otherwise VectorTraits<T> leads to a substitution failure (SFINAE).
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://kretzfamily.de
GSI Helmholtzzentrum für Schwerionenforschung https://gsi.de
SIMD easy and portable https://github.com/VcDevel/Vc
──────────────────────────────────────────────────────────────────────────
next prev parent reply other threads:[~2019-05-22 9:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 8:36 Martin Reinecke
2019-05-22 9:18 ` Richard Biener
2019-05-22 9:27 ` Martin Reinecke
2019-05-22 9:37 ` Matthias Kretz [this message]
2019-05-22 9:27 ` Matthias Kretz
-- strict thread matches above, loose matches on Subject: below --
2019-05-22 6:39 Martin Reinecke
2019-05-22 8:09 ` 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=8204676.kP6zuPok09@minbar \
--to=m.kretz@gsi.de \
--cc=gcc@gcc.gnu.org \
--cc=martin@mpa-garching.mpg.de \
/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).