All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes
@ 2016-06-01 14:54 Dr. David Alan Gilbert (git)
  2016-06-01 14:54 ` [Qemu-devel] [PATCH v2 1/2] Make avx2 configure test work with -O2 Dr. David Alan Gilbert (git)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-01 14:54 UTC (permalink / raw)
  To: qemu-devel, liang.z.li, pbonzini, peter.maydell; +Cc: amit.shah

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Hi,
  This pair of patches fixes a couple of issues that we found during test.
The first is that the configure test is pessimistic when compiled with -O2,
the second is that the explicit 4.9 gcc test is a bit coarse; I've removed
that test but beefed up the ./configure test to actually use the avx2
intrinsics and that fails in the same way as the main code, so it works
in the same way as the explicit check but allows older gcc's to work
when -save-temps isn't used.

Dave

v2
  Remove the explicit version check
  Split the patches

Dr. David Alan Gilbert (2):
  Make avx2 configure test work with -O2
  avx2 configure: Use primitives in test

 configure     | 15 +++++++++++----
 util/cutils.c |  8 +-------
 2 files changed, 12 insertions(+), 11 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] Make avx2 configure test work with -O2
  2016-06-01 14:54 [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
@ 2016-06-01 14:54 ` Dr. David Alan Gilbert (git)
  2016-06-01 14:54 ` [Qemu-devel] [PATCH v2 2/2] avx2 configure: Use primitives in test Dr. David Alan Gilbert (git)
  2016-06-03  3:02 ` [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes Li, Liang Z
  2 siblings, 0 replies; 4+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-01 14:54 UTC (permalink / raw)
  To: qemu-devel, liang.z.li, pbonzini, peter.maydell; +Cc: amit.shah

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

When configured with --extra-cflags=-O2 gcc optimised out the test
and the readelf failed the check leaving avx2 disabled.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index b5aab72..5693c60 100755
--- a/configure
+++ b/configure
@@ -1783,7 +1783,7 @@ fi
 cat > $TMPC << EOF
 static void bar(void) {}
 static void *bar_ifunc(void) {return (void*) bar;}
-static void foo(void) __attribute__((ifunc("bar_ifunc")));
+void foo(void) __attribute__((ifunc("bar_ifunc")));
 int main(void) { foo(); return 0; }
 EOF
 if compile_prog "-mavx2" "" ; then
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] avx2 configure: Use primitives in test
  2016-06-01 14:54 [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
  2016-06-01 14:54 ` [Qemu-devel] [PATCH v2 1/2] Make avx2 configure test work with -O2 Dr. David Alan Gilbert (git)
@ 2016-06-01 14:54 ` Dr. David Alan Gilbert (git)
  2016-06-03  3:02 ` [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes Li, Liang Z
  2 siblings, 0 replies; 4+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-01 14:54 UTC (permalink / raw)
  To: qemu-devel, liang.z.li, pbonzini, peter.maydell; +Cc: amit.shah

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Use the avx2 primitives during the test, thus making sure that the
compiler and assembler could actually use avx2.

This also detects the failure case on gcc 4.8.x with -save-temps
and avoids the need for the gcc version check in cutils.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 configure     | 15 +++++++++++----
 util/cutils.c |  8 +-------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 5693c60..6449e65 100755
--- a/configure
+++ b/configure
@@ -1781,12 +1781,19 @@ fi
 # avx2 optimization requirement check
 
 cat > $TMPC << EOF
-static void bar(void) {}
+#pragma GCC push_options
+#pragma GCC target("avx2")
+#include <cpuid.h>
+#include <immintrin.h>
+
+static int bar(void *a) {
+    return _mm256_movemask_epi8(_mm256_cmpeq_epi8(*(__m256i *)a, (__m256i){0}));
+}
 static void *bar_ifunc(void) {return (void*) bar;}
-void foo(void) __attribute__((ifunc("bar_ifunc")));
-int main(void) { foo(); return 0; }
+int foo(void *a) __attribute__((ifunc("bar_ifunc")));
+int main(int argc, char *argv[]) { return foo(argv[0]);}
 EOF
-if compile_prog "-mavx2" "" ; then
+if compile_prog "" ; then
     if readelf --syms $TMPE |grep "IFUNC.*foo" >/dev/null 2>&1; then
         avx2_opt="yes"
     fi
diff --git a/util/cutils.c b/util/cutils.c
index 43d1afb..5830a68 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -256,13 +256,7 @@ static size_t buffer_find_nonzero_offset_inner(const void *buf, size_t len)
     return i * sizeof(VECTYPE);
 }
 
-/*
- * GCC before version 4.9 has a bug which will cause the target
- * attribute work incorrectly and failed to compile in some case,
- * restrict the gcc version to 4.9+ to prevent the failure.
- */
-
-#if defined CONFIG_AVX2_OPT && QEMU_GNUC_PREREQ(4, 9)
+#if defined CONFIG_AVX2_OPT
 #pragma GCC push_options
 #pragma GCC target("avx2")
 #include <cpuid.h>
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes
  2016-06-01 14:54 [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
  2016-06-01 14:54 ` [Qemu-devel] [PATCH v2 1/2] Make avx2 configure test work with -O2 Dr. David Alan Gilbert (git)
  2016-06-01 14:54 ` [Qemu-devel] [PATCH v2 2/2] avx2 configure: Use primitives in test Dr. David Alan Gilbert (git)
@ 2016-06-03  3:02 ` Li, Liang Z
  2 siblings, 0 replies; 4+ messages in thread
From: Li, Liang Z @ 2016-06-03  3:02 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git), qemu-devel, pbonzini, peter.maydell
  Cc: amit.shah

> Cc: amit.shah@redhat.com
> Subject: [PATCH v2 0/2] AVX2 configure fixes
> 
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Hi,
>   This pair of patches fixes a couple of issues that we found during test.
> The first is that the configure test is pessimistic when compiled with -O2, the
> second is that the explicit 4.9 gcc test is a bit coarse; I've removed that test
> but beefed up the ./configure test to actually use the avx2 intrinsics and that
> fails in the same way as the main code, so it works in the same way as the
> explicit check but allows older gcc's to work when -save-temps isn't used.
> 
> Dave
> 
> v2
>   Remove the explicit version check
>   Split the patches
> 
> Dr. David Alan Gilbert (2):
>   Make avx2 configure test work with -O2
>   avx2 configure: Use primitives in test
> 
>  configure     | 15 +++++++++++----
>  util/cutils.c |  8 +-------
>  2 files changed, 12 insertions(+), 11 deletions(-)
> 
> --
> 2.7.4

Looks good. Thank!

Reviewed-by: Liang Li <liang.z.li@intel.com>

Liang

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-03  3:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01 14:54 [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes Dr. David Alan Gilbert (git)
2016-06-01 14:54 ` [Qemu-devel] [PATCH v2 1/2] Make avx2 configure test work with -O2 Dr. David Alan Gilbert (git)
2016-06-01 14:54 ` [Qemu-devel] [PATCH v2 2/2] avx2 configure: Use primitives in test Dr. David Alan Gilbert (git)
2016-06-03  3:02 ` [Qemu-devel] [PATCH v2 0/2] AVX2 configure fixes Li, Liang Z

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.