mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
Update bench-code for addressing CI problem
Unit test code is in test-xbzrle.c, and benchmark code is in xbzrle-bench.c for performance benchmarking. we have modified xbzrle-bench.c to address CI problem. Signed-off-by: ling xu <ling1.xu@intel.com> Co-authored-by: Zhou Zhao <zhou.zhao@intel.com> Co-authored-by: Jun Jin <jun.i.jin@intel.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
04ffce137b
commit
cc98c9fd5c
3 changed files with 509 additions and 5 deletions
|
@ -16,6 +16,35 @@
|
|||
|
||||
#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;
|
||||
|
@ -54,7 +83,7 @@ static void test_encode_decode_zero(void)
|
|||
buffer[1000 + diff_len + 5] = 105;
|
||||
|
||||
/* encode zero page */
|
||||
dlen = xbzrle_encode_buffer(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
|
||||
dlen = xbzrle_encode_buffer_func(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
|
||||
XBZRLE_PAGE_SIZE);
|
||||
g_assert(dlen == 0);
|
||||
|
||||
|
@ -78,7 +107,7 @@ static void test_encode_decode_unchanged(void)
|
|||
test[1000 + diff_len + 5] = 109;
|
||||
|
||||
/* test unchanged buffer */
|
||||
dlen = xbzrle_encode_buffer(test, test, XBZRLE_PAGE_SIZE, compressed,
|
||||
dlen = xbzrle_encode_buffer_func(test, test, XBZRLE_PAGE_SIZE, compressed,
|
||||
XBZRLE_PAGE_SIZE);
|
||||
g_assert(dlen == 0);
|
||||
|
||||
|
@ -96,7 +125,7 @@ static void test_encode_decode_1_byte(void)
|
|||
|
||||
test[XBZRLE_PAGE_SIZE - 1] = 1;
|
||||
|
||||
dlen = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
||||
dlen = xbzrle_encode_buffer_func(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
||||
XBZRLE_PAGE_SIZE);
|
||||
g_assert(dlen == (uleb128_encode_small(&buf[0], 4095) + 2));
|
||||
|
||||
|
@ -121,7 +150,7 @@ static void test_encode_decode_overflow(void)
|
|||
}
|
||||
|
||||
/* encode overflow */
|
||||
rc = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
||||
rc = xbzrle_encode_buffer_func(buffer, test, XBZRLE_PAGE_SIZE, compressed,
|
||||
XBZRLE_PAGE_SIZE);
|
||||
g_assert(rc == -1);
|
||||
|
||||
|
@ -152,7 +181,7 @@ static void encode_decode_range(void)
|
|||
test[1000 + diff_len + 5] = 109;
|
||||
|
||||
/* test encode/decode */
|
||||
dlen = xbzrle_encode_buffer(test, buffer, XBZRLE_PAGE_SIZE, compressed,
|
||||
dlen = xbzrle_encode_buffer_func(test, buffer, XBZRLE_PAGE_SIZE, compressed,
|
||||
XBZRLE_PAGE_SIZE);
|
||||
|
||||
rc = xbzrle_decode_buffer(compressed, dlen, test, XBZRLE_PAGE_SIZE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue