Use a more portable way to enable target specific functions
PATCH 1/1 Use a more portable way to enable target specific functions
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.
--- meson.build | 2 +- util/bufferiszero.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
meson.build +1 -1
@@ -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); }
util/bufferiszero.c +4 -4
@@ -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. */
Signature · 1 line
2.35.3
Quoted 6 lines · 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.cwhich 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~
Quoted 10 lines · Richard Henderson
Quoted 6 lines · 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.cwhich 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)
Quoted 4 lines
r~
With regards,
Daniel
Signature · 3 lines
|: 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 :|