aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-05-17 20:00:30 -0700
committerRichard Henderson <richard.henderson@linaro.org>2023-05-23 16:51:18 -0700
commit7ba7db9fa101f59cd42cc8ead8a83b121a852943 (patch)
tree6ca3b59ea82b7d2629346e1fb88823c38bbccb30 /tests/unit
parent1b48d0abdf3b723f2d0f91172dcc9f89d50a92ce (diff)
downloadqemu-7ba7db9fa101f59cd42cc8ead8a83b121a852943.zip
qemu-7ba7db9fa101f59cd42cc8ead8a83b121a852943.tar.gz
qemu-7ba7db9fa101f59cd42cc8ead8a83b121a852943.tar.bz2
migration/xbzrle: Use i386 host/cpuinfo.h
Perform the function selection once, and only if CONFIG_AVX512_OPT is enabled. Centralize the selection to xbzrle.c, instead of spreading the init across 3 files. Remove xbzrle-bench.c. The benefit of being able to benchmark the different implementations is less important than not peeking into the internals of the implementation. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test-xbzrle.c49
1 files changed, 10 insertions, 39 deletions
diff --git a/tests/unit/test-xbzrle.c b/tests/unit/test-xbzrle.c
index 547046d..b6996de 100644
--- a/tests/unit/test-xbzrle.c
+++ b/tests/unit/test-xbzrle.c
@@ -16,35 +16,6 @@
#define XBZRLE_PAGE_SIZE 4096
-int (*xbzrle_encode_buffer_func)(uint8_t *, uint8_t *, int,
- uint8_t *, int) = xbzrle_encode_buffer;
-#if defined(CONFIG_AVX512BW_OPT)
-#include "qemu/cpuid.h"
-static void __attribute__((constructor)) init_cpu_flag(void)
-{
- unsigned max = __get_cpuid_max(0, NULL);
- int a, b, c, d;
- if (max >= 1) {
- __cpuid(1, a, b, c, d);
- /* We must check that AVX is not just available, but usable. */
- if ((c & bit_OSXSAVE) && (c & bit_AVX) && max >= 7) {
- int bv;
- __asm("xgetbv" : "=a"(bv), "=d"(d) : "c"(0));
- __cpuid_count(7, 0, a, b, c, d);
- /* 0xe6:
- * XCR0[7:5] = 111b (OPMASK state, upper 256-bit of ZMM0-ZMM15
- * and ZMM16-ZMM31 state are enabled by OS)
- * XCR0[2:1] = 11b (XMM state and YMM state are enabled by OS)
- */
- if ((bv & 0xe6) == 0xe6 && (b & bit_AVX512BW)) {
- xbzrle_encode_buffer_func = xbzrle_encode_buffer_avx512;
- }
- }
- }
- return ;
-}
-#endif
-
static void test_uleb(void)
{
uint32_t i, val;
@@ -83,8 +54,8 @@ static void test_encode_decode_zero(void)
buffer[1000 + diff_len + 5] = 105;
/* encode zero page */
- dlen = xbzrle_encode_buffer_func(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
- XBZRLE_PAGE_SIZE);
+ dlen = xbzrle_encode_buffer(buffer, buffer, XBZRLE_PAGE_SIZE,
+ compressed, XBZRLE_PAGE_SIZE);
g_assert(dlen == 0);
g_free(buffer);
@@ -107,8 +78,8 @@ static void test_encode_decode_unchanged(void)
test[1000 + diff_len + 5] = 109;
/* test unchanged buffer */
- dlen = xbzrle_encode_buffer_func(test, test, XBZRLE_PAGE_SIZE, compressed,
- XBZRLE_PAGE_SIZE);
+ dlen = xbzrle_encode_buffer(test, test, XBZRLE_PAGE_SIZE,
+ compressed, XBZRLE_PAGE_SIZE);
g_assert(dlen == 0);
g_free(test);
@@ -125,8 +96,8 @@ static void test_encode_decode_1_byte(void)
test[XBZRLE_PAGE_SIZE - 1] = 1;
- dlen = xbzrle_encode_buffer_func(buffer, test, XBZRLE_PAGE_SIZE, compressed,
- XBZRLE_PAGE_SIZE);
+ dlen = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE,
+ compressed, XBZRLE_PAGE_SIZE);
g_assert(dlen == (uleb128_encode_small(&buf[0], 4095) + 2));
rc = xbzrle_decode_buffer(compressed, dlen, buffer, XBZRLE_PAGE_SIZE);
@@ -150,8 +121,8 @@ static void test_encode_decode_overflow(void)
}
/* encode overflow */
- rc = xbzrle_encode_buffer_func(buffer, test, XBZRLE_PAGE_SIZE, compressed,
- XBZRLE_PAGE_SIZE);
+ rc = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE,
+ compressed, XBZRLE_PAGE_SIZE);
g_assert(rc == -1);
g_free(buffer);
@@ -181,8 +152,8 @@ static void encode_decode_range(void)
test[1000 + diff_len + 5] = 109;
/* test encode/decode */
- dlen = xbzrle_encode_buffer_func(test, buffer, XBZRLE_PAGE_SIZE, compressed,
- XBZRLE_PAGE_SIZE);
+ dlen = xbzrle_encode_buffer(test, buffer, XBZRLE_PAGE_SIZE,
+ compressed, XBZRLE_PAGE_SIZE);
rc = xbzrle_decode_buffer(compressed, dlen, test, XBZRLE_PAGE_SIZE);
g_assert(rc < XBZRLE_PAGE_SIZE);