qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Shu-Chun Weng <scw@google.com>, rth@twiddle.net
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] configure: avx2 and avx512f detection for clang
Date: Thu, 23 Jul 2020 06:54:51 +0200	[thread overview]
Message-ID: <0152137e-638a-dd06-741a-f03830c92ffd@redhat.com> (raw)
In-Reply-To: <bf706105addcaa3f48391be8f7e5c09c3b1735ae.1595463707.git.scw@google.com>

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>
> ---
>  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  4:55 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 [this message]
2020-07-23  6:04     ` Shu-Chun Weng
2020-07-23  6:24       ` Thomas Huth
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=0152137e-638a-dd06-741a-f03830c92ffd@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).