qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 2/2] Test code for AVX512 support for xbzrle_encode_buffer


From: Richard Henderson
Subject: Re: [PATCH v3 2/2] Test code for AVX512 support for xbzrle_encode_buffer
Date: Tue, 9 Aug 2022 11:30:53 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 8/8/22 00:48, ling xu wrote:
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>
---
  tests/unit/test-xbzrle.c | 307 ++++++++++++++++++++++++++++++++++++---
  1 file changed, 290 insertions(+), 17 deletions(-)

diff --git a/tests/unit/test-xbzrle.c b/tests/unit/test-xbzrle.c
index ef951b6e54..653016826f 100644
--- a/tests/unit/test-xbzrle.c
+++ b/tests/unit/test-xbzrle.c
@@ -38,111 +38,280 @@ static void test_uleb(void)
      g_assert(val == 0);
  }
-static void test_encode_decode_zero(void)
+static float *test_encode_decode_zero(void)
  {
      uint8_t *buffer = g_malloc0(XBZRLE_PAGE_SIZE);
      uint8_t *compressed = g_malloc0(XBZRLE_PAGE_SIZE);
+    uint8_t *buffer512 = g_malloc0(XBZRLE_PAGE_SIZE);
+    uint8_t *compressed512 = g_malloc0(XBZRLE_PAGE_SIZE);
      int i = 0;
-    int dlen = 0;
+    int dlen = 0, dlen512 = 0;
      int diff_len = g_test_rand_int_range(0, XBZRLE_PAGE_SIZE - 1006);
for (i = diff_len; i > 0; i--) {
          buffer[1000 + i] = i;
+        buffer512[1000 + i] = i;
      }
buffer[1000 + diff_len + 3] = 103;
      buffer[1000 + diff_len + 5] = 105;
+ buffer512[1000 + diff_len + 3] = 103;
+    buffer512[1000 + diff_len + 5] = 105;
+
      /* encode zero page */
+    time_t t_start, t_end, t_start512, t_end512;
+    t_start = clock();
      dlen = xbzrle_encode_buffer(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
                         XBZRLE_PAGE_SIZE);
+    t_end = clock();
+    float time_val = difftime(t_end, t_start);
      g_assert(dlen == 0);
+ t_start512 = clock();
+    dlen512 = xbzrle_encode_buffer_512(buffer512, buffer512, XBZRLE_PAGE_SIZE,
+                                       compressed512, XBZRLE_PAGE_SIZE);
+    t_end512 = clock();
+    float time_val512 = difftime(t_end512, t_start512);
+    g_assert(dlen512 == 0);
+
+    static float result_zero[2];
+    result_zero[0] = time_val;
+    result_zero[1] = time_val512;
+
      g_free(buffer);
      g_free(compressed);
+    g_free(buffer512);
+    g_free(compressed512);
+
+    return result_zero;
+}

Why are you returning a pointer to static storage?
I'll note that this isn't so much "testing" as "benchmarking".

Does the speedup from using 512-bit vectors make up for the clock slowdown that is enforced on the cpu cluster? As far as I know, it is still quite rare for avx512 to actually pay off.

I suggest you model testing on test_buffer_is_zero_next_accel().



r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]