From: Matthias Kretz <m.kretz@gsi.de>
To: <gcc@gcc.gnu.org>
Subject: Re: Determining maximum vector length supported by the CPU?
Date: Wed, 22 May 2019 08:09:00 -0000 [thread overview]
Message-ID: <53743762.tOYSgijEGa@minbar> (raw)
In-Reply-To: <1ceb35b6-4a28-8739-90d4-c300fd81b044@mpa-garching.mpg.de>
Hi Martin,
I agree, we need more information from the compiler. Esp. whether the user
specified `-mprefer-avx128` or `-mprefer-vector-width=none/128/256/512`.
OTOH `-msve-vector-bits=N` is reported as __ARM_FEATURE_SVE_BITS. So that's
covered.
Related: PR83875 - because while we're adding things in that area, it'd be
nice if they worked with target clones as well.
Are you aware of std::experimental::simd? It didn't make GCC 9.1, but you
can easily patch your (installed) libstdc++ using https://github.com/VcDevel/
std-simd.
Cheers,
Matthias
On Mittwoch, 22. Mai 2019 08:39:25 CEST Martin Reinecke wrote:
> [Disclaimer: I sent this to gcc-help two weeks ago, but didn't get an
> answer. Maybe the topic is more suited for the main gcc list ... I
> really think the feature in question would be extremely useful to have,
> and easy to add!]
>
> Hi,
>
> I'm currently writing an FFT library which tries to make use of SIMD
> instructions and uses a lot of variables with
> __attribute__ ((vector_size (xyz))
>
> The resulting source is nicely portable and architecture-independent -
> except for the one place where I need to determine the maximum
> hardware-supported vector length on the target CPU.
>
> This currently looks like
>
> #if defined(__AVX__)
> constexpr int veclen=32;
> #elif defined(__SSE2__)
> constexpr int veclen=16;
> [...]
>
> This approach requires me to add an #ifdef for many architectures, most
> of which I cannot really test on ... and new architectures will be
> unsupported by default.
>
> Hence my question: is there a way in gcc to determine the hardware
> vector length for the architecture the compiler is currently targeting?
> Some predefined macro like
>
> HARDWARE_VECTOR_LENGTH_IN_BYTES
>
> which is 32 for AVX, 16 for SSE2, and has proper values for Neon, VPX
> etc. etc.
>
> If this is not provided at the moment, would it bo possible to add this
> in the future? This could massively simplify writing and maintaining
> multi-platform SIMD code.
>
> Thanks,
> Martin
//
--
──────────────────────────────────────────────────────────────────────────
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 8:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 6:39 Martin Reinecke
2019-05-22 8:09 ` Matthias Kretz [this message]
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
2019-05-22 9:27 ` 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=53743762.tOYSgijEGa@minbar \
--to=m.kretz@gsi.de \
--cc=gcc@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).