qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Shu-Chun Weng <scw@google.com>
Cc: qemu-devel@nongnu.org, rth@twiddle.net
Subject: Re: [PATCH 1/2] configure: avx2 and avx512f detection for clang
Date: Thu, 23 Jul 2020 08:24:14 +0200	[thread overview]
Message-ID: <14058222-4024-7e14-c2e1-467bcde0fc7f@redhat.com> (raw)
In-Reply-To: <CAF3nBxjpcPW182wJajOkd+kdTcGQOefptDg=R01C7G9DTrQpZA@mail.gmail.com>

On 23/07/2020 08.04, Shu-Chun Weng wrote:
> Do we have the flexibility to do that for util/bufferiszero.c as well?
> Otherwise, we are using different mechanisms to detect (compile test.c
> with -mavx2) and actually use (GCC pragma & __attribute__((target(*)))))
> the feature in production.

That's true ... so it's likely better to keep the pragmas in the
configure script, indeed!

 Thanks,
  Thomas


> Shu-Chun
> 
> On Wed, Jul 22, 2020 at 9:55 PM Thomas Huth <thuth@redhat.com
> <mailto:thuth@redhat.com>> wrote:
> 
>     On 23/07/2020 02.27, Shu-Chun Weng wrote:
>     > Since clang does not support "#pragma GCC", the instruction sets are
>     > always disabled. In this change, we
>     >
>     >  1. wrap "#pragma GCC" inside "#ifndef __clang__",
>     >  2. only retain them around "#include <{e,i,s}mmintrin.h>" to work
>     >     around gcc bug,
>     >  3. and annotate each function with `__attribute__((target(*)))` which
>     >     is recognized by both gcc and clang.
>     >
>     > Signed-off-by: Shu-Chun Weng <scw@google.com <mailto:scw@google.com>>
>     > ---
>     >  configure           | 16 ++++++++++++++--
>     >  util/bufferiszero.c | 33 +++++++++++++++++++++++----------
>     >  2 files changed, 37 insertions(+), 12 deletions(-)
>     >
>     > diff --git a/configure b/configure
>     > index 4bd80ed507..d9ce3aa5db 100755
>     > --- a/configure
>     > +++ b/configure
>     > @@ -5808,10 +5808,16 @@ fi
>     > 
>     >  if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
>     >    cat > $TMPC << EOF
>     > +#include <cpuid.h>
>     > +#ifndef __clang__
>     >  #pragma GCC push_options
>     >  #pragma GCC target("avx2")
>     > -#include <cpuid.h>
>     > +#endif
>     >  #include <immintrin.h>
>     > +#ifndef __clang__
>     > +#pragma GCC pop_options
>     > +#endif
>     > +__attribute__((target("avx2")))
>     >  static int bar(void *a) {
>     >      __m256i x = *(__m256i *)a;
>     >      return _mm256_testz_si256(x, x);
> 
>     I wonder whether it would make more sense to pass "-mavx2" to the
>     compile_object call afterwards and simply remove the #pragmas here?
>     Did you try that already?
> 
>      Thomas
> 



  reply	other threads:[~2020-07-23  6:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23  0:27 [PATCH 0/2] Instruction set detection for clang Shu-Chun Weng
2020-07-23  0:27 ` [PATCH 1/2] configure: avx2 and avx512f " Shu-Chun Weng
2020-07-23  4:54   ` Thomas Huth
2020-07-23  6:04     ` Shu-Chun Weng
2020-07-23  6:24       ` Thomas Huth [this message]
2020-07-23  0:27 ` [PATCH 2/2] configure: atomic64/128 " Shu-Chun Weng
2020-08-05 23:23 ` [PATCH 0/2] Instruction set " Shu-Chun Weng
2020-09-17  7:25   ` Shu-Chun Weng

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=14058222-4024-7e14-c2e1-467bcde0fc7f@redhat.com \
    --to=thuth@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=scw@google.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 NNTP newsgroup(s).