qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use a more portable way to enable target specific functions
@ 2022-11-09 22:03 Tom Stellard
  2022-11-10  3:43 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Stellard @ 2022-11-09 22:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Daniel P . Berrange, Tom Stellard

This adds function attributes for avx2, sse2, etc. specialized
functions.  These attributes are supported by both clang and gcc and
are necessary in order to build the code with clang.  The existing gcc
specific pragmas were left in place due to a comment in
utils/bufferiszero.c which mentions the pragmas are needed before headers
to work around a bug in gcc <= 4.8.

Signed-off-by: Tom Stellard <tstellar@redhat.com>
---
 meson.build         | 2 +-
 util/bufferiszero.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/meson.build b/meson.build
index cf3e517e56..45573c0e44 100644
--- a/meson.build
+++ b/meson.build
@@ -2323,7 +2323,7 @@ config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \
     #pragma GCC target("avx2")
     #include <cpuid.h>
     #include <immintrin.h>
-    static int bar(void *a) {
+    __attribute__((target("avx2"))) static int bar(void *a) {
       __m256i x = *(__m256i *)a;
       return _mm256_testz_si256(x, x);
     }
diff --git a/util/bufferiszero.c b/util/bufferiszero.c
index ec3cd4ca15..e4f5628643 100644
--- a/util/bufferiszero.c
+++ b/util/bufferiszero.c
@@ -75,7 +75,7 @@ buffer_zero_int(const void *buf, size_t len)
 
 /* Note that each of these vectorized functions require len >= 64.  */
 
-static bool
+__attribute__((target("sse2"))) static bool
 buffer_zero_sse2(const void *buf, size_t len)
 {
     __m128i t = _mm_loadu_si128(buf);
@@ -117,7 +117,7 @@ buffer_zero_sse2(const void *buf, size_t len)
 #pragma GCC target("sse4")
 #include <smmintrin.h>
 
-static bool
+__attribute__((target("sse4"))) static bool
 buffer_zero_sse4(const void *buf, size_t len)
 {
     __m128i t = _mm_loadu_si128(buf);
@@ -150,7 +150,7 @@ buffer_zero_sse4(const void *buf, size_t len)
 #pragma GCC target("avx2")
 #include <immintrin.h>
 
-static bool
+__attribute__((target("avx2"))) static bool
 buffer_zero_avx2(const void *buf, size_t len)
 {
     /* Begin with an unaligned head of 32 bytes.  */
@@ -184,7 +184,7 @@ buffer_zero_avx2(const void *buf, size_t len)
 #pragma GCC target("avx512f")
 #include <immintrin.h>
 
-static bool
+__attribute__((target("avx512f"))) static bool
 buffer_zero_avx512(const void *buf, size_t len)
 {
     /* Begin with an unaligned head of 64 bytes.  */
-- 
2.35.3



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

* Re: [PATCH] Use a more portable way to enable target specific functions
  2022-11-09 22:03 [PATCH] Use a more portable way to enable target specific functions Tom Stellard
@ 2022-11-10  3:43 ` Richard Henderson
  2022-11-10  9:00   ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2022-11-10  3:43 UTC (permalink / raw)
  To: Tom Stellard, qemu-devel; +Cc: Paolo Bonzini, Daniel P . Berrange

On 11/10/22 09:03, Tom Stellard wrote:
> This adds function attributes for avx2, sse2, etc. specialized
> functions.  These attributes are supported by both clang and gcc and
> are necessary in order to build the code with clang.  The existing gcc
> specific pragmas were left in place due to a comment in
> utils/bufferiszero.c which mentions the pragmas are needed before headers
> to work around a bug in gcc <= 4.8.

GCC 4.8 is now below our minimum, surely.
We should be able to simply replace the pragma with the attribute.


r~


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

* Re: [PATCH] Use a more portable way to enable target specific functions
  2022-11-10  3:43 ` Richard Henderson
@ 2022-11-10  9:00   ` Daniel P. Berrangé
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2022-11-10  9:00 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Tom Stellard, qemu-devel, Paolo Bonzini

On Thu, Nov 10, 2022 at 02:43:28PM +1100, Richard Henderson wrote:
> On 11/10/22 09:03, Tom Stellard wrote:
> > This adds function attributes for avx2, sse2, etc. specialized
> > functions.  These attributes are supported by both clang and gcc and
> > are necessary in order to build the code with clang.  The existing gcc
> > specific pragmas were left in place due to a comment in
> > utils/bufferiszero.c which mentions the pragmas are needed before headers
> > to work around a bug in gcc <= 4.8.
> 
> GCC 4.8 is now below our minimum, surely.
> We should be able to simply replace the pragma with the attribute.

We mandate at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)

> 
> 
> r~
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

end of thread, other threads:[~2022-11-10  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-09 22:03 [PATCH] Use a more portable way to enable target specific functions Tom Stellard
2022-11-10  3:43 ` Richard Henderson
2022-11-10  9:00   ` Daniel P. Berrangé

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).