public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] Bench: Add support for choose direction of memcpy in benchtests
@ 2021-05-24  1:30 Noah Goldstein
  2021-05-24  1:30 ` [PATCH v1 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
  2021-05-24  1:48 ` [PATCH v1 " H.J. Lu
  0 siblings, 2 replies; 10+ messages in thread
From: Noah Goldstein @ 2021-05-24  1:30 UTC (permalink / raw)
  To: libc-alpha

This patch adds support for testing memcpy with both dst > src and dst
< src. Since memcpy is implemented as memmove which has seperate
control flows for certain sizes depending on dst > src it seems like
1) information that should be provided in the benchtest output and a
variable that can be controlled for the benchmarks.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
 benchtests/bench-memcpy-large.c | 50 +++++++++++++---------
 benchtests/bench-memcpy-walk.c  | 33 +++++++++-----
 benchtests/bench-memcpy.c       | 76 ++++++++++++++++++---------------
 3 files changed, 94 insertions(+), 65 deletions(-)

diff --git a/benchtests/bench-memcpy-large.c b/benchtests/bench-memcpy-large.c
index efb9627b1e..0021274e92 100644
--- a/benchtests/bench-memcpy-large.c
+++ b/benchtests/bench-memcpy-large.c
@@ -52,11 +52,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
 }
 
 static void
-do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
+do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
+         int both_ways)
 {
   size_t i, j;
   char *s1, *s2;
-
+  size_t repeats;
   align1 &= 4095;
   if (align1 + len >= page_size)
     return;
@@ -68,20 +69,27 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
   s1 = (char *) (buf1 + align1);
   s2 = (char *) (buf2 + align2);
 
-  for (i = 0, j = 1; i < len; i++, j += 23)
-    s1[i] = j;
+  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
+    {
+      for (i = 0, j = 1; i < len; i++, j += 23)
+        s1[i] = j;
 
-  json_element_object_begin (json_ctx);
-  json_attr_uint (json_ctx, "length", (double) len);
-  json_attr_uint (json_ctx, "align1", (double) align1);
-  json_attr_uint (json_ctx, "align2", (double) align2);
-  json_array_begin (json_ctx, "timings");
+      json_element_object_begin (json_ctx);
+      json_attr_uint (json_ctx, "length", (double) len);
+      json_attr_uint (json_ctx, "align1", (double) align1);
+      json_attr_uint (json_ctx, "align2", (double) align2);
+      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
+      json_array_begin (json_ctx, "timings");
 
-  FOR_EACH_IMPL (impl, 0)
-    do_one_test (json_ctx, impl, s2, s1, len);
+      FOR_EACH_IMPL (impl, 0)
+        do_one_test (json_ctx, impl, s2, s1, len);
 
-  json_array_end (json_ctx);
-  json_element_object_end (json_ctx);
+      json_array_end (json_ctx);
+      json_element_object_end (json_ctx);
+
+      s1 = (char *) (buf2 + align1);
+      s2 = (char *) (buf1 + align2);
+    }
 }
 
 int
@@ -109,14 +117,14 @@ test_main (void)
   json_array_begin (&json_ctx, "results");
   for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
     {
-      do_test (&json_ctx, 0, 0, i + 7);
-      do_test (&json_ctx, 0, 3, i + 15);
-      do_test (&json_ctx, 3, 0, i + 31);
-      do_test (&json_ctx, 3, 5, i + 63);
-      do_test (&json_ctx, 0, 127, i);
-      do_test (&json_ctx, 0, 255, i);
-      do_test (&json_ctx, 0, 256, i);
-      do_test (&json_ctx, 0, 4064, i);
+      do_test (&json_ctx, 0, 0, i + 7, 1);
+      do_test (&json_ctx, 0, 3, i + 15, 1);
+      do_test (&json_ctx, 3, 0, i + 31, 1);
+      do_test (&json_ctx, 3, 5, i + 63, 1);
+      do_test (&json_ctx, 0, 127, i, 1);
+      do_test (&json_ctx, 0, 255, i, 1);
+      do_test (&json_ctx, 0, 256, i, 1);
+      do_test (&json_ctx, 0, 4064, i, 1);
     }
 
   json_array_end (&json_ctx);
diff --git a/benchtests/bench-memcpy-walk.c b/benchtests/bench-memcpy-walk.c
index b04d8ac0ed..610529ef1b 100644
--- a/benchtests/bench-memcpy-walk.c
+++ b/benchtests/bench-memcpy-walk.c
@@ -66,17 +66,30 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src,
 }
 
 static void
-do_test (json_ctx_t *json_ctx, size_t len)
+do_test (json_ctx_t *json_ctx, size_t len, int both_ways)
 {
-  json_element_object_begin (json_ctx);
-  json_attr_uint (json_ctx, "length", (double) len);
-  json_array_begin (json_ctx, "timings");
 
-  FOR_EACH_IMPL (impl, 0)
-    do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len);
+  char *s1, *s2;
+  size_t repeats;
+  s1 = (char *) (buf1);
+  s2 = (char *) (buf2);
+
+  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
+    {
+      json_element_object_begin (json_ctx);
+      json_attr_uint (json_ctx, "length", (double) len);
+      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
+      json_array_begin (json_ctx, "timings");
 
-  json_array_end (json_ctx);
-  json_element_object_end (json_ctx);
+      FOR_EACH_IMPL (impl, 0)
+        do_one_test (json_ctx, impl, s2, s1, len);
+
+      json_array_end (json_ctx);
+      json_element_object_end (json_ctx);
+
+      s1 = (char *) (buf2);
+      s2 = (char *) (buf1);
+    }
 }
 
 int
@@ -103,8 +116,8 @@ test_main (void)
   json_array_begin (&json_ctx, "results");
   for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
     {
-      do_test (&json_ctx, i);
-      do_test (&json_ctx, i + 1);
+      do_test (&json_ctx, i, 1);
+      do_test (&json_ctx, i + 1, 1);
     }
 
   json_array_end (&json_ctx);
diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c
index 184495d539..d9236a2282 100644
--- a/benchtests/bench-memcpy.c
+++ b/benchtests/bench-memcpy.c
@@ -54,11 +54,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
 }
 
 static void
-do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
+do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
+         int both_ways)
 {
   size_t i, j;
   char *s1, *s2;
-
+  size_t repeats;
   align1 &= 63;
   if (align1 + len >= page_size)
     return;
@@ -70,20 +71,27 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
   s1 = (char *) (buf1 + align1);
   s2 = (char *) (buf2 + align2);
 
-  for (i = 0, j = 1; i < len; i++, j += 23)
-    s1[i] = j;
+  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
+    {
+      for (i = 0, j = 1; i < len; i++, j += 23)
+        s1[i] = j;
 
-  json_element_object_begin (json_ctx);
-  json_attr_uint (json_ctx, "length", (double) len);
-  json_attr_uint (json_ctx, "align1", (double) align1);
-  json_attr_uint (json_ctx, "align2", (double) align2);
-  json_array_begin (json_ctx, "timings");
+      json_element_object_begin (json_ctx);
+      json_attr_uint (json_ctx, "length", (double) len);
+      json_attr_uint (json_ctx, "align1", (double) align1);
+      json_attr_uint (json_ctx, "align2", (double) align2);
+      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
+      json_array_begin (json_ctx, "timings");
 
-  FOR_EACH_IMPL (impl, 0)
-    do_one_test (json_ctx, impl, s2, s1, len);
+      FOR_EACH_IMPL (impl, 0)
+        do_one_test (json_ctx, impl, s2, s1, len);
 
-  json_array_end (json_ctx);
-  json_element_object_end (json_ctx);
+      json_array_end (json_ctx);
+      json_element_object_end (json_ctx);
+
+      s1 = (char *) (buf2 + align1);
+      s2 = (char *) (buf1 + align2);
+    }
 }
 
 int
@@ -111,46 +119,46 @@ test_main (void)
   json_array_begin (&json_ctx, "results");
   for (i = 0; i < 18; ++i)
     {
-      do_test (&json_ctx, 0, 0, 1 << i);
-      do_test (&json_ctx, i, 0, 1 << i);
-      do_test (&json_ctx, 0, i, 1 << i);
-      do_test (&json_ctx, i, i, 1 << i);
+      do_test (&json_ctx, 0, 0, 1 << i, 1);
+      do_test (&json_ctx, i, 0, 1 << i, 1);
+      do_test (&json_ctx, 0, i, 1 << i, 1);
+      do_test (&json_ctx, i, i, 1 << i, 1);
     }
 
   for (i = 0; i < 32; ++i)
     {
-      do_test (&json_ctx, 0, 0, i);
-      do_test (&json_ctx, i, 0, i);
-      do_test (&json_ctx, 0, i, i);
-      do_test (&json_ctx, i, i, i);
+      do_test (&json_ctx, 0, 0, i, 0);
+      do_test (&json_ctx, i, 0, i, 0);
+      do_test (&json_ctx, 0, i, i, 0);
+      do_test (&json_ctx, i, i, i, 0);
     }
 
   for (i = 3; i < 32; ++i)
     {
       if ((i & (i - 1)) == 0)
 	continue;
-      do_test (&json_ctx, 0, 0, 16 * i);
-      do_test (&json_ctx, i, 0, 16 * i);
-      do_test (&json_ctx, 0, i, 16 * i);
-      do_test (&json_ctx, i, i, 16 * i);
+      do_test (&json_ctx, 0, 0, 16 * i, 1);
+      do_test (&json_ctx, i, 0, 16 * i, 1);
+      do_test (&json_ctx, 0, i, 16 * i, 1);
+      do_test (&json_ctx, i, i, 16 * i, 1);
     }
 
   for (i = 32; i < 64; ++i)
     {
-      do_test (&json_ctx, 0, 0, 32 * i);
-      do_test (&json_ctx, i, 0, 32 * i);
-      do_test (&json_ctx, 0, i, 32 * i);
-      do_test (&json_ctx, i, i, 32 * i);
+      do_test (&json_ctx, 0, 0, 32 * i, 1);
+      do_test (&json_ctx, i, 0, 32 * i, 1);
+      do_test (&json_ctx, 0, i, 32 * i, 1);
+      do_test (&json_ctx, i, i, 32 * i, 1);
     }
 
-  do_test (&json_ctx, 0, 0, getpagesize ());
+  do_test (&json_ctx, 0, 0, getpagesize (), 1);
 
   for (i = 0; i <= 32; ++i)
     {
-      do_test (&json_ctx, 0, 0, 2048 + 64 * i);
-      do_test (&json_ctx, i, 0, 2048 + 64 * i);
-      do_test (&json_ctx, 0, i, 2048 + 64 * i);
-      do_test (&json_ctx, i, i, 2048 + 64 * i);
+      do_test (&json_ctx, 0, 0, 2048 + 64 * i, 1);
+      do_test (&json_ctx, i, 0, 2048 + 64 * i, 1);
+      do_test (&json_ctx, 0, i, 2048 + 64 * i, 1);
+      do_test (&json_ctx, i, i, 2048 + 64 * i, 1);
     }
 
   json_array_end (&json_ctx);
-- 
2.25.1


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

* [PATCH v1 2/2] x86: Improve memmove-vec-unaligned-erms.S
  2021-05-24  1:30 [PATCH v1 1/2] Bench: Add support for choose direction of memcpy in benchtests Noah Goldstein
@ 2021-05-24  1:30 ` Noah Goldstein
  2021-05-24  1:45   ` H.J. Lu
  2021-05-24  3:15   ` [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests Noah Goldstein
  2021-05-24  1:48 ` [PATCH v1 " H.J. Lu
  1 sibling, 2 replies; 10+ messages in thread
From: Noah Goldstein @ 2021-05-24  1:30 UTC (permalink / raw)
  To: libc-alpha

This patch changes the condition for copy 4x VEC so that if length is
exactly equal to 4 * VEC_SIZE it will use the 4x VEC case instead of
8x VEC case.

Results For Skylake memcpy-avx2-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 9.137   , 6.873   , New , 75.22
128 , 7   , 0   , 12.933  , 7.732   , New , 59.79
128 , 0   , 7   , 11.852  , 6.76    , New , 57.04
128 , 7   , 7   , 12.587  , 6.808   , New , 54.09

Results For Icelake memcpy-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 9.963   , 5.416   , New , 54.36
128 , 7   , 0   , 16.467  , 8.061   , New , 48.95
128 , 0   , 7   , 14.388  , 7.644   , New , 53.13
128 , 7   , 7   , 14.546  , 7.642   , New , 52.54

Results For Tigerlake memcpy-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 8.979   , 4.95    , New , 55.13
128 , 7   , 0   , 14.245  , 7.122   , New , 50.0
128 , 0   , 7   , 12.668  , 6.675   , New , 52.69
128 , 7   , 7   , 13.042  , 6.802   , New , 52.15

Results For Skylake memmove-avx2-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 6.181   , 5.691   , New , 92.07
128 , 32  , 0   , 6.165   , 5.752   , New , 93.3
128 , 0   , 7   , 13.923  , 9.37    , New , 67.3
128 , 7   , 0   , 12.049  , 10.182  , New , 84.5

Results For Icelake memmove-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 5.479   , 4.889   , New , 89.23
128 , 32  , 0   , 5.127   , 4.911   , New , 95.79
128 , 0   , 7   , 18.885  , 13.547  , New , 71.73
128 , 7   , 0   , 15.565  , 14.436  , New , 92.75

Results For Tigerlake memmove-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 5.275   , 4.815   , New , 91.28
128 , 32  , 0   , 5.376   , 4.565   , New , 84.91
128 , 0   , 7   , 19.426  , 14.273  , New , 73.47
128 , 7   , 0   , 15.924  , 14.951  , New , 93.89

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
 sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
index 5e4a071f16..d36cd288c7 100644
--- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
@@ -420,7 +420,7 @@ L(more_2x_vec):
 	cmpq	$(VEC_SIZE * 8), %rdx
 	ja	L(more_8x_vec)
 	cmpq	$(VEC_SIZE * 4), %rdx
-	jb	L(last_4x_vec)
+	jbe	L(last_4x_vec)
 	/* Copy from 4 * VEC to 8 * VEC, inclusively. */
 	VMOVU	(%rsi), %VEC(0)
 	VMOVU	VEC_SIZE(%rsi), %VEC(1)
-- 
2.25.1


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

* Re: [PATCH v1 2/2] x86: Improve memmove-vec-unaligned-erms.S
  2021-05-24  1:30 ` [PATCH v1 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
@ 2021-05-24  1:45   ` H.J. Lu
  2021-05-24  3:15     ` Noah Goldstein
  2021-05-24  3:15   ` [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests Noah Goldstein
  1 sibling, 1 reply; 10+ messages in thread
From: H.J. Lu @ 2021-05-24  1:45 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell

On Sun, May 23, 2021 at 6:30 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> This patch changes the condition for copy 4x VEC so that if length is
> exactly equal to 4 * VEC_SIZE it will use the 4x VEC case instead of
> 8x VEC case.
>
> Results For Skylake memcpy-avx2-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 0   , 9.137   , 6.873   , New , 75.22
> 128 , 7   , 0   , 12.933  , 7.732   , New , 59.79
> 128 , 0   , 7   , 11.852  , 6.76    , New , 57.04
> 128 , 7   , 7   , 12.587  , 6.808   , New , 54.09
>
> Results For Icelake memcpy-evex-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 0   , 9.963   , 5.416   , New , 54.36
> 128 , 7   , 0   , 16.467  , 8.061   , New , 48.95
> 128 , 0   , 7   , 14.388  , 7.644   , New , 53.13
> 128 , 7   , 7   , 14.546  , 7.642   , New , 52.54
>
> Results For Tigerlake memcpy-evex-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 0   , 8.979   , 4.95    , New , 55.13
> 128 , 7   , 0   , 14.245  , 7.122   , New , 50.0
> 128 , 0   , 7   , 12.668  , 6.675   , New , 52.69
> 128 , 7   , 7   , 13.042  , 6.802   , New , 52.15
>
> Results For Skylake memmove-avx2-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 32  , 6.181   , 5.691   , New , 92.07
> 128 , 32  , 0   , 6.165   , 5.752   , New , 93.3
> 128 , 0   , 7   , 13.923  , 9.37    , New , 67.3
> 128 , 7   , 0   , 12.049  , 10.182  , New , 84.5
>
> Results For Icelake memmove-evex-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 32  , 5.479   , 4.889   , New , 89.23
> 128 , 32  , 0   , 5.127   , 4.911   , New , 95.79
> 128 , 0   , 7   , 18.885  , 13.547  , New , 71.73
> 128 , 7   , 0   , 15.565  , 14.436  , New , 92.75
>
> Results For Tigerlake memmove-evex-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 32  , 5.275   , 4.815   , New , 91.28
> 128 , 32  , 0   , 5.376   , 4.565   , New , 84.91
> 128 , 0   , 7   , 19.426  , 14.273  , New , 73.47
> 128 , 7   , 0   , 15.924  , 14.951  , New , 93.89
>
> Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> ---
>  sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> index 5e4a071f16..d36cd288c7 100644
> --- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> +++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> @@ -420,7 +420,7 @@ L(more_2x_vec):
>         cmpq    $(VEC_SIZE * 8), %rdx
>         ja      L(more_8x_vec)
>         cmpq    $(VEC_SIZE * 4), %rdx
> -       jb      L(last_4x_vec)
> +       jbe     L(last_4x_vec)
>         /* Copy from 4 * VEC to 8 * VEC, inclusively. */
              ^^^^^^^^^^^^^^^^^^^^ Please also update the comment to
"4 * VEC + 1"

>         VMOVU   (%rsi), %VEC(0)
>         VMOVU   VEC_SIZE(%rsi), %VEC(1)
> --
> 2.25.1
>

Thanks.

-- 
H.J.

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

* Re: [PATCH v1 1/2] Bench: Add support for choose direction of memcpy in benchtests
  2021-05-24  1:30 [PATCH v1 1/2] Bench: Add support for choose direction of memcpy in benchtests Noah Goldstein
  2021-05-24  1:30 ` [PATCH v1 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
@ 2021-05-24  1:48 ` H.J. Lu
  1 sibling, 0 replies; 10+ messages in thread
From: H.J. Lu @ 2021-05-24  1:48 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell

On Sun, May 23, 2021 at 6:30 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> This patch adds support for testing memcpy with both dst > src and dst
> < src. Since memcpy is implemented as memmove which has seperate
> control flows for certain sizes depending on dst > src it seems like
> 1) information that should be provided in the benchtest output and a
> variable that can be controlled for the benchmarks.
>
> Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> ---
>  benchtests/bench-memcpy-large.c | 50 +++++++++++++---------
>  benchtests/bench-memcpy-walk.c  | 33 +++++++++-----
>  benchtests/bench-memcpy.c       | 76 ++++++++++++++++++---------------
>  3 files changed, 94 insertions(+), 65 deletions(-)
>
> diff --git a/benchtests/bench-memcpy-large.c b/benchtests/bench-memcpy-large.c
> index efb9627b1e..0021274e92 100644
> --- a/benchtests/bench-memcpy-large.c
> +++ b/benchtests/bench-memcpy-large.c
> @@ -52,11 +52,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
>  }
>
>  static void
> -do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
> +do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
> +         int both_ways)
>  {
>    size_t i, j;
>    char *s1, *s2;
> -
> +  size_t repeats;
>    align1 &= 4095;
>    if (align1 + len >= page_size)
>      return;
> @@ -68,20 +69,27 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
>    s1 = (char *) (buf1 + align1);
>    s2 = (char *) (buf2 + align2);
>
> -  for (i = 0, j = 1; i < len; i++, j += 23)
> -    s1[i] = j;
> +  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
> +    {
> +      for (i = 0, j = 1; i < len; i++, j += 23)
> +        s1[i] = j;
>
> -  json_element_object_begin (json_ctx);
> -  json_attr_uint (json_ctx, "length", (double) len);
> -  json_attr_uint (json_ctx, "align1", (double) align1);
> -  json_attr_uint (json_ctx, "align2", (double) align2);
> -  json_array_begin (json_ctx, "timings");
> +      json_element_object_begin (json_ctx);
> +      json_attr_uint (json_ctx, "length", (double) len);
> +      json_attr_uint (json_ctx, "align1", (double) align1);
> +      json_attr_uint (json_ctx, "align2", (double) align2);
> +      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
> +      json_array_begin (json_ctx, "timings");
>
> -  FOR_EACH_IMPL (impl, 0)
> -    do_one_test (json_ctx, impl, s2, s1, len);
> +      FOR_EACH_IMPL (impl, 0)
> +        do_one_test (json_ctx, impl, s2, s1, len);
>
> -  json_array_end (json_ctx);
> -  json_element_object_end (json_ctx);
> +      json_array_end (json_ctx);
> +      json_element_object_end (json_ctx);
> +
> +      s1 = (char *) (buf2 + align1);
> +      s2 = (char *) (buf1 + align2);
> +    }
>  }
>
>  int
> @@ -109,14 +117,14 @@ test_main (void)
>    json_array_begin (&json_ctx, "results");
>    for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
>      {
> -      do_test (&json_ctx, 0, 0, i + 7);
> -      do_test (&json_ctx, 0, 3, i + 15);
> -      do_test (&json_ctx, 3, 0, i + 31);
> -      do_test (&json_ctx, 3, 5, i + 63);
> -      do_test (&json_ctx, 0, 127, i);
> -      do_test (&json_ctx, 0, 255, i);
> -      do_test (&json_ctx, 0, 256, i);
> -      do_test (&json_ctx, 0, 4064, i);
> +      do_test (&json_ctx, 0, 0, i + 7, 1);
> +      do_test (&json_ctx, 0, 3, i + 15, 1);
> +      do_test (&json_ctx, 3, 0, i + 31, 1);
> +      do_test (&json_ctx, 3, 5, i + 63, 1);
> +      do_test (&json_ctx, 0, 127, i, 1);
> +      do_test (&json_ctx, 0, 255, i, 1);
> +      do_test (&json_ctx, 0, 256, i, 1);
> +      do_test (&json_ctx, 0, 4064, i, 1);
>      }
>
>    json_array_end (&json_ctx);
> diff --git a/benchtests/bench-memcpy-walk.c b/benchtests/bench-memcpy-walk.c
> index b04d8ac0ed..610529ef1b 100644
> --- a/benchtests/bench-memcpy-walk.c
> +++ b/benchtests/bench-memcpy-walk.c
> @@ -66,17 +66,30 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src,
>  }
>
>  static void
> -do_test (json_ctx_t *json_ctx, size_t len)
> +do_test (json_ctx_t *json_ctx, size_t len, int both_ways)
>  {
> -  json_element_object_begin (json_ctx);
> -  json_attr_uint (json_ctx, "length", (double) len);
> -  json_array_begin (json_ctx, "timings");
>
> -  FOR_EACH_IMPL (impl, 0)
> -    do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len);
> +  char *s1, *s2;
> +  size_t repeats;
> +  s1 = (char *) (buf1);
> +  s2 = (char *) (buf2);
> +
> +  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
> +    {
> +      json_element_object_begin (json_ctx);
> +      json_attr_uint (json_ctx, "length", (double) len);
> +      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
> +      json_array_begin (json_ctx, "timings");
>
> -  json_array_end (json_ctx);
> -  json_element_object_end (json_ctx);
> +      FOR_EACH_IMPL (impl, 0)
> +        do_one_test (json_ctx, impl, s2, s1, len);
> +
> +      json_array_end (json_ctx);
> +      json_element_object_end (json_ctx);
> +
> +      s1 = (char *) (buf2);
> +      s2 = (char *) (buf1);
> +    }
>  }
>
>  int
> @@ -103,8 +116,8 @@ test_main (void)
>    json_array_begin (&json_ctx, "results");
>    for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
>      {
> -      do_test (&json_ctx, i);
> -      do_test (&json_ctx, i + 1);
> +      do_test (&json_ctx, i, 1);
> +      do_test (&json_ctx, i + 1, 1);
>      }
>
>    json_array_end (&json_ctx);
> diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c
> index 184495d539..d9236a2282 100644
> --- a/benchtests/bench-memcpy.c
> +++ b/benchtests/bench-memcpy.c
> @@ -54,11 +54,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
>  }
>
>  static void
> -do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
> +do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
> +         int both_ways)
>  {
>    size_t i, j;
>    char *s1, *s2;
> -
> +  size_t repeats;
>    align1 &= 63;
>    if (align1 + len >= page_size)
>      return;
> @@ -70,20 +71,27 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
>    s1 = (char *) (buf1 + align1);
>    s2 = (char *) (buf2 + align2);
>
> -  for (i = 0, j = 1; i < len; i++, j += 23)
> -    s1[i] = j;
> +  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
> +    {
> +      for (i = 0, j = 1; i < len; i++, j += 23)
> +        s1[i] = j;
>
> -  json_element_object_begin (json_ctx);
> -  json_attr_uint (json_ctx, "length", (double) len);
> -  json_attr_uint (json_ctx, "align1", (double) align1);
> -  json_attr_uint (json_ctx, "align2", (double) align2);
> -  json_array_begin (json_ctx, "timings");
> +      json_element_object_begin (json_ctx);
> +      json_attr_uint (json_ctx, "length", (double) len);
> +      json_attr_uint (json_ctx, "align1", (double) align1);
> +      json_attr_uint (json_ctx, "align2", (double) align2);
> +      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
> +      json_array_begin (json_ctx, "timings");
>
> -  FOR_EACH_IMPL (impl, 0)
> -    do_one_test (json_ctx, impl, s2, s1, len);
> +      FOR_EACH_IMPL (impl, 0)
> +        do_one_test (json_ctx, impl, s2, s1, len);
>
> -  json_array_end (json_ctx);
> -  json_element_object_end (json_ctx);
> +      json_array_end (json_ctx);
> +      json_element_object_end (json_ctx);
> +
> +      s1 = (char *) (buf2 + align1);
> +      s2 = (char *) (buf1 + align2);
> +    }
>  }
>
>  int
> @@ -111,46 +119,46 @@ test_main (void)
>    json_array_begin (&json_ctx, "results");
>    for (i = 0; i < 18; ++i)
>      {
> -      do_test (&json_ctx, 0, 0, 1 << i);
> -      do_test (&json_ctx, i, 0, 1 << i);
> -      do_test (&json_ctx, 0, i, 1 << i);
> -      do_test (&json_ctx, i, i, 1 << i);
> +      do_test (&json_ctx, 0, 0, 1 << i, 1);
> +      do_test (&json_ctx, i, 0, 1 << i, 1);
> +      do_test (&json_ctx, 0, i, 1 << i, 1);
> +      do_test (&json_ctx, i, i, 1 << i, 1);
>      }
>
>    for (i = 0; i < 32; ++i)
>      {
> -      do_test (&json_ctx, 0, 0, i);
> -      do_test (&json_ctx, i, 0, i);
> -      do_test (&json_ctx, 0, i, i);
> -      do_test (&json_ctx, i, i, i);
> +      do_test (&json_ctx, 0, 0, i, 0);
> +      do_test (&json_ctx, i, 0, i, 0);
> +      do_test (&json_ctx, 0, i, i, 0);
> +      do_test (&json_ctx, i, i, i, 0);
>      }
>
>    for (i = 3; i < 32; ++i)
>      {
>        if ((i & (i - 1)) == 0)
>         continue;
> -      do_test (&json_ctx, 0, 0, 16 * i);
> -      do_test (&json_ctx, i, 0, 16 * i);
> -      do_test (&json_ctx, 0, i, 16 * i);
> -      do_test (&json_ctx, i, i, 16 * i);
> +      do_test (&json_ctx, 0, 0, 16 * i, 1);
> +      do_test (&json_ctx, i, 0, 16 * i, 1);
> +      do_test (&json_ctx, 0, i, 16 * i, 1);
> +      do_test (&json_ctx, i, i, 16 * i, 1);
>      }
>
>    for (i = 32; i < 64; ++i)
>      {
> -      do_test (&json_ctx, 0, 0, 32 * i);
> -      do_test (&json_ctx, i, 0, 32 * i);
> -      do_test (&json_ctx, 0, i, 32 * i);
> -      do_test (&json_ctx, i, i, 32 * i);
> +      do_test (&json_ctx, 0, 0, 32 * i, 1);
> +      do_test (&json_ctx, i, 0, 32 * i, 1);
> +      do_test (&json_ctx, 0, i, 32 * i, 1);
> +      do_test (&json_ctx, i, i, 32 * i, 1);
>      }
>
> -  do_test (&json_ctx, 0, 0, getpagesize ());
> +  do_test (&json_ctx, 0, 0, getpagesize (), 1);
>
>    for (i = 0; i <= 32; ++i)
>      {
> -      do_test (&json_ctx, 0, 0, 2048 + 64 * i);
> -      do_test (&json_ctx, i, 0, 2048 + 64 * i);
> -      do_test (&json_ctx, 0, i, 2048 + 64 * i);
> -      do_test (&json_ctx, i, i, 2048 + 64 * i);
> +      do_test (&json_ctx, 0, 0, 2048 + 64 * i, 1);
> +      do_test (&json_ctx, i, 0, 2048 + 64 * i, 1);
> +      do_test (&json_ctx, 0, i, 2048 + 64 * i, 1);
> +      do_test (&json_ctx, i, i, 2048 + 64 * i, 1);
>      }
>
>    json_array_end (&json_ctx);
> --
> 2.25.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.

-- 
H.J.

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

* [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests
  2021-05-24  1:30 ` [PATCH v1 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
  2021-05-24  1:45   ` H.J. Lu
@ 2021-05-24  3:15   ` Noah Goldstein
  2021-05-24  3:15     ` [PATCH v2 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
  2021-05-24  3:22     ` [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests H.J. Lu
  1 sibling, 2 replies; 10+ messages in thread
From: Noah Goldstein @ 2021-05-24  3:15 UTC (permalink / raw)
  To: libc-alpha

This patch adds support for testing memcpy with both dst > src and dst
< src. Since memcpy is implemented as memmove which has seperate
control flows for certain sizes depending on dst > src it seems like
1) information that should be provided in the benchtest output and a
variable that can be controlled for the benchmarks.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
 benchtests/bench-memcpy-large.c | 50 +++++++++++++---------
 benchtests/bench-memcpy-walk.c  | 33 +++++++++-----
 benchtests/bench-memcpy.c       | 76 ++++++++++++++++++---------------
 3 files changed, 94 insertions(+), 65 deletions(-)

diff --git a/benchtests/bench-memcpy-large.c b/benchtests/bench-memcpy-large.c
index efb9627b1e..0021274e92 100644
--- a/benchtests/bench-memcpy-large.c
+++ b/benchtests/bench-memcpy-large.c
@@ -52,11 +52,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
 }
 
 static void
-do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
+do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
+         int both_ways)
 {
   size_t i, j;
   char *s1, *s2;
-
+  size_t repeats;
   align1 &= 4095;
   if (align1 + len >= page_size)
     return;
@@ -68,20 +69,27 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
   s1 = (char *) (buf1 + align1);
   s2 = (char *) (buf2 + align2);
 
-  for (i = 0, j = 1; i < len; i++, j += 23)
-    s1[i] = j;
+  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
+    {
+      for (i = 0, j = 1; i < len; i++, j += 23)
+        s1[i] = j;
 
-  json_element_object_begin (json_ctx);
-  json_attr_uint (json_ctx, "length", (double) len);
-  json_attr_uint (json_ctx, "align1", (double) align1);
-  json_attr_uint (json_ctx, "align2", (double) align2);
-  json_array_begin (json_ctx, "timings");
+      json_element_object_begin (json_ctx);
+      json_attr_uint (json_ctx, "length", (double) len);
+      json_attr_uint (json_ctx, "align1", (double) align1);
+      json_attr_uint (json_ctx, "align2", (double) align2);
+      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
+      json_array_begin (json_ctx, "timings");
 
-  FOR_EACH_IMPL (impl, 0)
-    do_one_test (json_ctx, impl, s2, s1, len);
+      FOR_EACH_IMPL (impl, 0)
+        do_one_test (json_ctx, impl, s2, s1, len);
 
-  json_array_end (json_ctx);
-  json_element_object_end (json_ctx);
+      json_array_end (json_ctx);
+      json_element_object_end (json_ctx);
+
+      s1 = (char *) (buf2 + align1);
+      s2 = (char *) (buf1 + align2);
+    }
 }
 
 int
@@ -109,14 +117,14 @@ test_main (void)
   json_array_begin (&json_ctx, "results");
   for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
     {
-      do_test (&json_ctx, 0, 0, i + 7);
-      do_test (&json_ctx, 0, 3, i + 15);
-      do_test (&json_ctx, 3, 0, i + 31);
-      do_test (&json_ctx, 3, 5, i + 63);
-      do_test (&json_ctx, 0, 127, i);
-      do_test (&json_ctx, 0, 255, i);
-      do_test (&json_ctx, 0, 256, i);
-      do_test (&json_ctx, 0, 4064, i);
+      do_test (&json_ctx, 0, 0, i + 7, 1);
+      do_test (&json_ctx, 0, 3, i + 15, 1);
+      do_test (&json_ctx, 3, 0, i + 31, 1);
+      do_test (&json_ctx, 3, 5, i + 63, 1);
+      do_test (&json_ctx, 0, 127, i, 1);
+      do_test (&json_ctx, 0, 255, i, 1);
+      do_test (&json_ctx, 0, 256, i, 1);
+      do_test (&json_ctx, 0, 4064, i, 1);
     }
 
   json_array_end (&json_ctx);
diff --git a/benchtests/bench-memcpy-walk.c b/benchtests/bench-memcpy-walk.c
index b04d8ac0ed..610529ef1b 100644
--- a/benchtests/bench-memcpy-walk.c
+++ b/benchtests/bench-memcpy-walk.c
@@ -66,17 +66,30 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src,
 }
 
 static void
-do_test (json_ctx_t *json_ctx, size_t len)
+do_test (json_ctx_t *json_ctx, size_t len, int both_ways)
 {
-  json_element_object_begin (json_ctx);
-  json_attr_uint (json_ctx, "length", (double) len);
-  json_array_begin (json_ctx, "timings");
 
-  FOR_EACH_IMPL (impl, 0)
-    do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len);
+  char *s1, *s2;
+  size_t repeats;
+  s1 = (char *) (buf1);
+  s2 = (char *) (buf2);
+
+  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
+    {
+      json_element_object_begin (json_ctx);
+      json_attr_uint (json_ctx, "length", (double) len);
+      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
+      json_array_begin (json_ctx, "timings");
 
-  json_array_end (json_ctx);
-  json_element_object_end (json_ctx);
+      FOR_EACH_IMPL (impl, 0)
+        do_one_test (json_ctx, impl, s2, s1, len);
+
+      json_array_end (json_ctx);
+      json_element_object_end (json_ctx);
+
+      s1 = (char *) (buf2);
+      s2 = (char *) (buf1);
+    }
 }
 
 int
@@ -103,8 +116,8 @@ test_main (void)
   json_array_begin (&json_ctx, "results");
   for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
     {
-      do_test (&json_ctx, i);
-      do_test (&json_ctx, i + 1);
+      do_test (&json_ctx, i, 1);
+      do_test (&json_ctx, i + 1, 1);
     }
 
   json_array_end (&json_ctx);
diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c
index 184495d539..d9236a2282 100644
--- a/benchtests/bench-memcpy.c
+++ b/benchtests/bench-memcpy.c
@@ -54,11 +54,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
 }
 
 static void
-do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
+do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
+         int both_ways)
 {
   size_t i, j;
   char *s1, *s2;
-
+  size_t repeats;
   align1 &= 63;
   if (align1 + len >= page_size)
     return;
@@ -70,20 +71,27 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
   s1 = (char *) (buf1 + align1);
   s2 = (char *) (buf2 + align2);
 
-  for (i = 0, j = 1; i < len; i++, j += 23)
-    s1[i] = j;
+  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
+    {
+      for (i = 0, j = 1; i < len; i++, j += 23)
+        s1[i] = j;
 
-  json_element_object_begin (json_ctx);
-  json_attr_uint (json_ctx, "length", (double) len);
-  json_attr_uint (json_ctx, "align1", (double) align1);
-  json_attr_uint (json_ctx, "align2", (double) align2);
-  json_array_begin (json_ctx, "timings");
+      json_element_object_begin (json_ctx);
+      json_attr_uint (json_ctx, "length", (double) len);
+      json_attr_uint (json_ctx, "align1", (double) align1);
+      json_attr_uint (json_ctx, "align2", (double) align2);
+      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
+      json_array_begin (json_ctx, "timings");
 
-  FOR_EACH_IMPL (impl, 0)
-    do_one_test (json_ctx, impl, s2, s1, len);
+      FOR_EACH_IMPL (impl, 0)
+        do_one_test (json_ctx, impl, s2, s1, len);
 
-  json_array_end (json_ctx);
-  json_element_object_end (json_ctx);
+      json_array_end (json_ctx);
+      json_element_object_end (json_ctx);
+
+      s1 = (char *) (buf2 + align1);
+      s2 = (char *) (buf1 + align2);
+    }
 }
 
 int
@@ -111,46 +119,46 @@ test_main (void)
   json_array_begin (&json_ctx, "results");
   for (i = 0; i < 18; ++i)
     {
-      do_test (&json_ctx, 0, 0, 1 << i);
-      do_test (&json_ctx, i, 0, 1 << i);
-      do_test (&json_ctx, 0, i, 1 << i);
-      do_test (&json_ctx, i, i, 1 << i);
+      do_test (&json_ctx, 0, 0, 1 << i, 1);
+      do_test (&json_ctx, i, 0, 1 << i, 1);
+      do_test (&json_ctx, 0, i, 1 << i, 1);
+      do_test (&json_ctx, i, i, 1 << i, 1);
     }
 
   for (i = 0; i < 32; ++i)
     {
-      do_test (&json_ctx, 0, 0, i);
-      do_test (&json_ctx, i, 0, i);
-      do_test (&json_ctx, 0, i, i);
-      do_test (&json_ctx, i, i, i);
+      do_test (&json_ctx, 0, 0, i, 0);
+      do_test (&json_ctx, i, 0, i, 0);
+      do_test (&json_ctx, 0, i, i, 0);
+      do_test (&json_ctx, i, i, i, 0);
     }
 
   for (i = 3; i < 32; ++i)
     {
       if ((i & (i - 1)) == 0)
 	continue;
-      do_test (&json_ctx, 0, 0, 16 * i);
-      do_test (&json_ctx, i, 0, 16 * i);
-      do_test (&json_ctx, 0, i, 16 * i);
-      do_test (&json_ctx, i, i, 16 * i);
+      do_test (&json_ctx, 0, 0, 16 * i, 1);
+      do_test (&json_ctx, i, 0, 16 * i, 1);
+      do_test (&json_ctx, 0, i, 16 * i, 1);
+      do_test (&json_ctx, i, i, 16 * i, 1);
     }
 
   for (i = 32; i < 64; ++i)
     {
-      do_test (&json_ctx, 0, 0, 32 * i);
-      do_test (&json_ctx, i, 0, 32 * i);
-      do_test (&json_ctx, 0, i, 32 * i);
-      do_test (&json_ctx, i, i, 32 * i);
+      do_test (&json_ctx, 0, 0, 32 * i, 1);
+      do_test (&json_ctx, i, 0, 32 * i, 1);
+      do_test (&json_ctx, 0, i, 32 * i, 1);
+      do_test (&json_ctx, i, i, 32 * i, 1);
     }
 
-  do_test (&json_ctx, 0, 0, getpagesize ());
+  do_test (&json_ctx, 0, 0, getpagesize (), 1);
 
   for (i = 0; i <= 32; ++i)
     {
-      do_test (&json_ctx, 0, 0, 2048 + 64 * i);
-      do_test (&json_ctx, i, 0, 2048 + 64 * i);
-      do_test (&json_ctx, 0, i, 2048 + 64 * i);
-      do_test (&json_ctx, i, i, 2048 + 64 * i);
+      do_test (&json_ctx, 0, 0, 2048 + 64 * i, 1);
+      do_test (&json_ctx, i, 0, 2048 + 64 * i, 1);
+      do_test (&json_ctx, 0, i, 2048 + 64 * i, 1);
+      do_test (&json_ctx, i, i, 2048 + 64 * i, 1);
     }
 
   json_array_end (&json_ctx);
-- 
2.25.1


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

* [PATCH v2 2/2] x86: Improve memmove-vec-unaligned-erms.S
  2021-05-24  3:15   ` [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests Noah Goldstein
@ 2021-05-24  3:15     ` Noah Goldstein
  2021-05-24  3:21       ` H.J. Lu
  2021-05-24  3:22     ` [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests H.J. Lu
  1 sibling, 1 reply; 10+ messages in thread
From: Noah Goldstein @ 2021-05-24  3:15 UTC (permalink / raw)
  To: libc-alpha

This patch changes the condition for copy 4x VEC so that if length is
exactly equal to 4 * VEC_SIZE it will use the 4x VEC case instead of
8x VEC case.

Results For Skylake memcpy-avx2-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 9.137   , 6.873   , New , 75.22
128 , 7   , 0   , 12.933  , 7.732   , New , 59.79
128 , 0   , 7   , 11.852  , 6.76    , New , 57.04
128 , 7   , 7   , 12.587  , 6.808   , New , 54.09

Results For Icelake memcpy-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 9.963   , 5.416   , New , 54.36
128 , 7   , 0   , 16.467  , 8.061   , New , 48.95
128 , 0   , 7   , 14.388  , 7.644   , New , 53.13
128 , 7   , 7   , 14.546  , 7.642   , New , 52.54

Results For Tigerlake memcpy-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 8.979   , 4.95    , New , 55.13
128 , 7   , 0   , 14.245  , 7.122   , New , 50.0
128 , 0   , 7   , 12.668  , 6.675   , New , 52.69
128 , 7   , 7   , 13.042  , 6.802   , New , 52.15

Results For Skylake memmove-avx2-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 6.181   , 5.691   , New , 92.07
128 , 32  , 0   , 6.165   , 5.752   , New , 93.3
128 , 0   , 7   , 13.923  , 9.37    , New , 67.3
128 , 7   , 0   , 12.049  , 10.182  , New , 84.5

Results For Icelake memmove-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 5.479   , 4.889   , New , 89.23
128 , 32  , 0   , 5.127   , 4.911   , New , 95.79
128 , 0   , 7   , 18.885  , 13.547  , New , 71.73
128 , 7   , 0   , 15.565  , 14.436  , New , 92.75

Results For Tigerlake memmove-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 5.275   , 4.815   , New , 91.28
128 , 32  , 0   , 5.376   , 4.565   , New , 84.91
128 , 0   , 7   , 19.426  , 14.273  , New , 73.47
128 , 7   , 0   , 15.924  , 14.951  , New , 93.89

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
 sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
index 5e4a071f16..a783da5de2 100644
--- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
+++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
@@ -420,8 +420,8 @@ L(more_2x_vec):
 	cmpq	$(VEC_SIZE * 8), %rdx
 	ja	L(more_8x_vec)
 	cmpq	$(VEC_SIZE * 4), %rdx
-	jb	L(last_4x_vec)
-	/* Copy from 4 * VEC to 8 * VEC, inclusively. */
+	jbe	L(last_4x_vec)
+	/* Copy from 4 * VEC + 1 to 8 * VEC, inclusively. */
 	VMOVU	(%rsi), %VEC(0)
 	VMOVU	VEC_SIZE(%rsi), %VEC(1)
 	VMOVU	(VEC_SIZE * 2)(%rsi), %VEC(2)
@@ -440,7 +440,7 @@ L(more_2x_vec):
 	VMOVU	%VEC(7), -(VEC_SIZE * 4)(%rdi,%rdx)
 	VZEROUPPER_RETURN
 L(last_4x_vec):
-	/* Copy from 2 * VEC to 4 * VEC. */
+	/* Copy from 2 * VEC + 1 to 4 * VEC, inclusively. */
 	VMOVU	(%rsi), %VEC(0)
 	VMOVU	VEC_SIZE(%rsi), %VEC(1)
 	VMOVU	-VEC_SIZE(%rsi,%rdx), %VEC(2)
-- 
2.25.1


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

* Re: [PATCH v1 2/2] x86: Improve memmove-vec-unaligned-erms.S
  2021-05-24  1:45   ` H.J. Lu
@ 2021-05-24  3:15     ` Noah Goldstein
  0 siblings, 0 replies; 10+ messages in thread
From: Noah Goldstein @ 2021-05-24  3:15 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Carlos O'Donell

On Sun, May 23, 2021 at 9:45 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, May 23, 2021 at 6:30 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > This patch changes the condition for copy 4x VEC so that if length is
> > exactly equal to 4 * VEC_SIZE it will use the 4x VEC case instead of
> > 8x VEC case.
> >
> > Results For Skylake memcpy-avx2-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 0   , 9.137   , 6.873   , New , 75.22
> > 128 , 7   , 0   , 12.933  , 7.732   , New , 59.79
> > 128 , 0   , 7   , 11.852  , 6.76    , New , 57.04
> > 128 , 7   , 7   , 12.587  , 6.808   , New , 54.09
> >
> > Results For Icelake memcpy-evex-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 0   , 9.963   , 5.416   , New , 54.36
> > 128 , 7   , 0   , 16.467  , 8.061   , New , 48.95
> > 128 , 0   , 7   , 14.388  , 7.644   , New , 53.13
> > 128 , 7   , 7   , 14.546  , 7.642   , New , 52.54
> >
> > Results For Tigerlake memcpy-evex-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 0   , 8.979   , 4.95    , New , 55.13
> > 128 , 7   , 0   , 14.245  , 7.122   , New , 50.0
> > 128 , 0   , 7   , 12.668  , 6.675   , New , 52.69
> > 128 , 7   , 7   , 13.042  , 6.802   , New , 52.15
> >
> > Results For Skylake memmove-avx2-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 32  , 6.181   , 5.691   , New , 92.07
> > 128 , 32  , 0   , 6.165   , 5.752   , New , 93.3
> > 128 , 0   , 7   , 13.923  , 9.37    , New , 67.3
> > 128 , 7   , 0   , 12.049  , 10.182  , New , 84.5
> >
> > Results For Icelake memmove-evex-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 32  , 5.479   , 4.889   , New , 89.23
> > 128 , 32  , 0   , 5.127   , 4.911   , New , 95.79
> > 128 , 0   , 7   , 18.885  , 13.547  , New , 71.73
> > 128 , 7   , 0   , 15.565  , 14.436  , New , 92.75
> >
> > Results For Tigerlake memmove-evex-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 32  , 5.275   , 4.815   , New , 91.28
> > 128 , 32  , 0   , 5.376   , 4.565   , New , 84.91
> > 128 , 0   , 7   , 19.426  , 14.273  , New , 73.47
> > 128 , 7   , 0   , 15.924  , 14.951  , New , 93.89
> >
> > Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> > ---
> >  sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> > index 5e4a071f16..d36cd288c7 100644
> > --- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> > +++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> > @@ -420,7 +420,7 @@ L(more_2x_vec):
> >         cmpq    $(VEC_SIZE * 8), %rdx
> >         ja      L(more_8x_vec)
> >         cmpq    $(VEC_SIZE * 4), %rdx
> > -       jb      L(last_4x_vec)
> > +       jbe     L(last_4x_vec)
> >         /* Copy from 4 * VEC to 8 * VEC, inclusively. */
>               ^^^^^^^^^^^^^^^^^^^^ Please also update the comment to
> "4 * VEC + 1"

Fixed.

>
> >         VMOVU   (%rsi), %VEC(0)
> >         VMOVU   VEC_SIZE(%rsi), %VEC(1)
> > --
> > 2.25.1
> >
>
> Thanks.
>
> --
> H.J.

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

* Re: [PATCH v2 2/2] x86: Improve memmove-vec-unaligned-erms.S
  2021-05-24  3:15     ` [PATCH v2 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
@ 2021-05-24  3:21       ` H.J. Lu
  2022-04-28  0:07         ` Sunil Pandey
  0 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu @ 2021-05-24  3:21 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell

On Sun, May 23, 2021 at 8:15 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> This patch changes the condition for copy 4x VEC so that if length is
> exactly equal to 4 * VEC_SIZE it will use the 4x VEC case instead of
> 8x VEC case.
>
> Results For Skylake memcpy-avx2-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 0   , 9.137   , 6.873   , New , 75.22
> 128 , 7   , 0   , 12.933  , 7.732   , New , 59.79
> 128 , 0   , 7   , 11.852  , 6.76    , New , 57.04
> 128 , 7   , 7   , 12.587  , 6.808   , New , 54.09
>
> Results For Icelake memcpy-evex-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 0   , 9.963   , 5.416   , New , 54.36
> 128 , 7   , 0   , 16.467  , 8.061   , New , 48.95
> 128 , 0   , 7   , 14.388  , 7.644   , New , 53.13
> 128 , 7   , 7   , 14.546  , 7.642   , New , 52.54
>
> Results For Tigerlake memcpy-evex-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 0   , 8.979   , 4.95    , New , 55.13
> 128 , 7   , 0   , 14.245  , 7.122   , New , 50.0
> 128 , 0   , 7   , 12.668  , 6.675   , New , 52.69
> 128 , 7   , 7   , 13.042  , 6.802   , New , 52.15
>
> Results For Skylake memmove-avx2-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 32  , 6.181   , 5.691   , New , 92.07
> 128 , 32  , 0   , 6.165   , 5.752   , New , 93.3
> 128 , 0   , 7   , 13.923  , 9.37    , New , 67.3
> 128 , 7   , 0   , 12.049  , 10.182  , New , 84.5
>
> Results For Icelake memmove-evex-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 32  , 5.479   , 4.889   , New , 89.23
> 128 , 32  , 0   , 5.127   , 4.911   , New , 95.79
> 128 , 0   , 7   , 18.885  , 13.547  , New , 71.73
> 128 , 7   , 0   , 15.565  , 14.436  , New , 92.75
>
> Results For Tigerlake memmove-evex-erms
> size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> 128 , 0   , 32  , 5.275   , 4.815   , New , 91.28
> 128 , 32  , 0   , 5.376   , 4.565   , New , 84.91
> 128 , 0   , 7   , 19.426  , 14.273  , New , 73.47
> 128 , 7   , 0   , 15.924  , 14.951  , New , 93.89
>
> Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> ---
>  sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> index 5e4a071f16..a783da5de2 100644
> --- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> +++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> @@ -420,8 +420,8 @@ L(more_2x_vec):
>         cmpq    $(VEC_SIZE * 8), %rdx
>         ja      L(more_8x_vec)
>         cmpq    $(VEC_SIZE * 4), %rdx
> -       jb      L(last_4x_vec)
> -       /* Copy from 4 * VEC to 8 * VEC, inclusively. */
> +       jbe     L(last_4x_vec)
> +       /* Copy from 4 * VEC + 1 to 8 * VEC, inclusively. */
>         VMOVU   (%rsi), %VEC(0)
>         VMOVU   VEC_SIZE(%rsi), %VEC(1)
>         VMOVU   (VEC_SIZE * 2)(%rsi), %VEC(2)
> @@ -440,7 +440,7 @@ L(more_2x_vec):
>         VMOVU   %VEC(7), -(VEC_SIZE * 4)(%rdi,%rdx)
>         VZEROUPPER_RETURN
>  L(last_4x_vec):
> -       /* Copy from 2 * VEC to 4 * VEC. */
> +       /* Copy from 2 * VEC + 1 to 4 * VEC, inclusively. */
>         VMOVU   (%rsi), %VEC(0)
>         VMOVU   VEC_SIZE(%rsi), %VEC(1)
>         VMOVU   -VEC_SIZE(%rsi,%rdx), %VEC(2)
> --
> 2.25.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.

-- 
H.J.

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

* Re: [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests
  2021-05-24  3:15   ` [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests Noah Goldstein
  2021-05-24  3:15     ` [PATCH v2 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
@ 2021-05-24  3:22     ` H.J. Lu
  1 sibling, 0 replies; 10+ messages in thread
From: H.J. Lu @ 2021-05-24  3:22 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell

On Sun, May 23, 2021 at 8:15 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> This patch adds support for testing memcpy with both dst > src and dst
> < src. Since memcpy is implemented as memmove which has seperate
> control flows for certain sizes depending on dst > src it seems like
> 1) information that should be provided in the benchtest output and a
> variable that can be controlled for the benchmarks.
>
> Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> ---
>  benchtests/bench-memcpy-large.c | 50 +++++++++++++---------
>  benchtests/bench-memcpy-walk.c  | 33 +++++++++-----
>  benchtests/bench-memcpy.c       | 76 ++++++++++++++++++---------------
>  3 files changed, 94 insertions(+), 65 deletions(-)
>
> diff --git a/benchtests/bench-memcpy-large.c b/benchtests/bench-memcpy-large.c
> index efb9627b1e..0021274e92 100644
> --- a/benchtests/bench-memcpy-large.c
> +++ b/benchtests/bench-memcpy-large.c
> @@ -52,11 +52,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
>  }
>
>  static void
> -do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
> +do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
> +         int both_ways)
>  {
>    size_t i, j;
>    char *s1, *s2;
> -
> +  size_t repeats;
>    align1 &= 4095;
>    if (align1 + len >= page_size)
>      return;
> @@ -68,20 +69,27 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
>    s1 = (char *) (buf1 + align1);
>    s2 = (char *) (buf2 + align2);
>
> -  for (i = 0, j = 1; i < len; i++, j += 23)
> -    s1[i] = j;
> +  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
> +    {
> +      for (i = 0, j = 1; i < len; i++, j += 23)
> +        s1[i] = j;
>
> -  json_element_object_begin (json_ctx);
> -  json_attr_uint (json_ctx, "length", (double) len);
> -  json_attr_uint (json_ctx, "align1", (double) align1);
> -  json_attr_uint (json_ctx, "align2", (double) align2);
> -  json_array_begin (json_ctx, "timings");
> +      json_element_object_begin (json_ctx);
> +      json_attr_uint (json_ctx, "length", (double) len);
> +      json_attr_uint (json_ctx, "align1", (double) align1);
> +      json_attr_uint (json_ctx, "align2", (double) align2);
> +      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
> +      json_array_begin (json_ctx, "timings");
>
> -  FOR_EACH_IMPL (impl, 0)
> -    do_one_test (json_ctx, impl, s2, s1, len);
> +      FOR_EACH_IMPL (impl, 0)
> +        do_one_test (json_ctx, impl, s2, s1, len);
>
> -  json_array_end (json_ctx);
> -  json_element_object_end (json_ctx);
> +      json_array_end (json_ctx);
> +      json_element_object_end (json_ctx);
> +
> +      s1 = (char *) (buf2 + align1);
> +      s2 = (char *) (buf1 + align2);
> +    }
>  }
>
>  int
> @@ -109,14 +117,14 @@ test_main (void)
>    json_array_begin (&json_ctx, "results");
>    for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
>      {
> -      do_test (&json_ctx, 0, 0, i + 7);
> -      do_test (&json_ctx, 0, 3, i + 15);
> -      do_test (&json_ctx, 3, 0, i + 31);
> -      do_test (&json_ctx, 3, 5, i + 63);
> -      do_test (&json_ctx, 0, 127, i);
> -      do_test (&json_ctx, 0, 255, i);
> -      do_test (&json_ctx, 0, 256, i);
> -      do_test (&json_ctx, 0, 4064, i);
> +      do_test (&json_ctx, 0, 0, i + 7, 1);
> +      do_test (&json_ctx, 0, 3, i + 15, 1);
> +      do_test (&json_ctx, 3, 0, i + 31, 1);
> +      do_test (&json_ctx, 3, 5, i + 63, 1);
> +      do_test (&json_ctx, 0, 127, i, 1);
> +      do_test (&json_ctx, 0, 255, i, 1);
> +      do_test (&json_ctx, 0, 256, i, 1);
> +      do_test (&json_ctx, 0, 4064, i, 1);
>      }
>
>    json_array_end (&json_ctx);
> diff --git a/benchtests/bench-memcpy-walk.c b/benchtests/bench-memcpy-walk.c
> index b04d8ac0ed..610529ef1b 100644
> --- a/benchtests/bench-memcpy-walk.c
> +++ b/benchtests/bench-memcpy-walk.c
> @@ -66,17 +66,30 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src,
>  }
>
>  static void
> -do_test (json_ctx_t *json_ctx, size_t len)
> +do_test (json_ctx_t *json_ctx, size_t len, int both_ways)
>  {
> -  json_element_object_begin (json_ctx);
> -  json_attr_uint (json_ctx, "length", (double) len);
> -  json_array_begin (json_ctx, "timings");
>
> -  FOR_EACH_IMPL (impl, 0)
> -    do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len);
> +  char *s1, *s2;
> +  size_t repeats;
> +  s1 = (char *) (buf1);
> +  s2 = (char *) (buf2);
> +
> +  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
> +    {
> +      json_element_object_begin (json_ctx);
> +      json_attr_uint (json_ctx, "length", (double) len);
> +      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
> +      json_array_begin (json_ctx, "timings");
>
> -  json_array_end (json_ctx);
> -  json_element_object_end (json_ctx);
> +      FOR_EACH_IMPL (impl, 0)
> +        do_one_test (json_ctx, impl, s2, s1, len);
> +
> +      json_array_end (json_ctx);
> +      json_element_object_end (json_ctx);
> +
> +      s1 = (char *) (buf2);
> +      s2 = (char *) (buf1);
> +    }
>  }
>
>  int
> @@ -103,8 +116,8 @@ test_main (void)
>    json_array_begin (&json_ctx, "results");
>    for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
>      {
> -      do_test (&json_ctx, i);
> -      do_test (&json_ctx, i + 1);
> +      do_test (&json_ctx, i, 1);
> +      do_test (&json_ctx, i + 1, 1);
>      }
>
>    json_array_end (&json_ctx);
> diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c
> index 184495d539..d9236a2282 100644
> --- a/benchtests/bench-memcpy.c
> +++ b/benchtests/bench-memcpy.c
> @@ -54,11 +54,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
>  }
>
>  static void
> -do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
> +do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
> +         int both_ways)
>  {
>    size_t i, j;
>    char *s1, *s2;
> -
> +  size_t repeats;
>    align1 &= 63;
>    if (align1 + len >= page_size)
>      return;
> @@ -70,20 +71,27 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
>    s1 = (char *) (buf1 + align1);
>    s2 = (char *) (buf2 + align2);
>
> -  for (i = 0, j = 1; i < len; i++, j += 23)
> -    s1[i] = j;
> +  for (repeats = both_ways ? 2 : 1; repeats; --repeats)
> +    {
> +      for (i = 0, j = 1; i < len; i++, j += 23)
> +        s1[i] = j;
>
> -  json_element_object_begin (json_ctx);
> -  json_attr_uint (json_ctx, "length", (double) len);
> -  json_attr_uint (json_ctx, "align1", (double) align1);
> -  json_attr_uint (json_ctx, "align2", (double) align2);
> -  json_array_begin (json_ctx, "timings");
> +      json_element_object_begin (json_ctx);
> +      json_attr_uint (json_ctx, "length", (double) len);
> +      json_attr_uint (json_ctx, "align1", (double) align1);
> +      json_attr_uint (json_ctx, "align2", (double) align2);
> +      json_attr_uint (json_ctx, "dst > src", (double) (s2 > s1));
> +      json_array_begin (json_ctx, "timings");
>
> -  FOR_EACH_IMPL (impl, 0)
> -    do_one_test (json_ctx, impl, s2, s1, len);
> +      FOR_EACH_IMPL (impl, 0)
> +        do_one_test (json_ctx, impl, s2, s1, len);
>
> -  json_array_end (json_ctx);
> -  json_element_object_end (json_ctx);
> +      json_array_end (json_ctx);
> +      json_element_object_end (json_ctx);
> +
> +      s1 = (char *) (buf2 + align1);
> +      s2 = (char *) (buf1 + align2);
> +    }
>  }
>
>  int
> @@ -111,46 +119,46 @@ test_main (void)
>    json_array_begin (&json_ctx, "results");
>    for (i = 0; i < 18; ++i)
>      {
> -      do_test (&json_ctx, 0, 0, 1 << i);
> -      do_test (&json_ctx, i, 0, 1 << i);
> -      do_test (&json_ctx, 0, i, 1 << i);
> -      do_test (&json_ctx, i, i, 1 << i);
> +      do_test (&json_ctx, 0, 0, 1 << i, 1);
> +      do_test (&json_ctx, i, 0, 1 << i, 1);
> +      do_test (&json_ctx, 0, i, 1 << i, 1);
> +      do_test (&json_ctx, i, i, 1 << i, 1);
>      }
>
>    for (i = 0; i < 32; ++i)
>      {
> -      do_test (&json_ctx, 0, 0, i);
> -      do_test (&json_ctx, i, 0, i);
> -      do_test (&json_ctx, 0, i, i);
> -      do_test (&json_ctx, i, i, i);
> +      do_test (&json_ctx, 0, 0, i, 0);
> +      do_test (&json_ctx, i, 0, i, 0);
> +      do_test (&json_ctx, 0, i, i, 0);
> +      do_test (&json_ctx, i, i, i, 0);
>      }
>
>    for (i = 3; i < 32; ++i)
>      {
>        if ((i & (i - 1)) == 0)
>         continue;
> -      do_test (&json_ctx, 0, 0, 16 * i);
> -      do_test (&json_ctx, i, 0, 16 * i);
> -      do_test (&json_ctx, 0, i, 16 * i);
> -      do_test (&json_ctx, i, i, 16 * i);
> +      do_test (&json_ctx, 0, 0, 16 * i, 1);
> +      do_test (&json_ctx, i, 0, 16 * i, 1);
> +      do_test (&json_ctx, 0, i, 16 * i, 1);
> +      do_test (&json_ctx, i, i, 16 * i, 1);
>      }
>
>    for (i = 32; i < 64; ++i)
>      {
> -      do_test (&json_ctx, 0, 0, 32 * i);
> -      do_test (&json_ctx, i, 0, 32 * i);
> -      do_test (&json_ctx, 0, i, 32 * i);
> -      do_test (&json_ctx, i, i, 32 * i);
> +      do_test (&json_ctx, 0, 0, 32 * i, 1);
> +      do_test (&json_ctx, i, 0, 32 * i, 1);
> +      do_test (&json_ctx, 0, i, 32 * i, 1);
> +      do_test (&json_ctx, i, i, 32 * i, 1);
>      }
>
> -  do_test (&json_ctx, 0, 0, getpagesize ());
> +  do_test (&json_ctx, 0, 0, getpagesize (), 1);
>
>    for (i = 0; i <= 32; ++i)
>      {
> -      do_test (&json_ctx, 0, 0, 2048 + 64 * i);
> -      do_test (&json_ctx, i, 0, 2048 + 64 * i);
> -      do_test (&json_ctx, 0, i, 2048 + 64 * i);
> -      do_test (&json_ctx, i, i, 2048 + 64 * i);
> +      do_test (&json_ctx, 0, 0, 2048 + 64 * i, 1);
> +      do_test (&json_ctx, i, 0, 2048 + 64 * i, 1);
> +      do_test (&json_ctx, 0, i, 2048 + 64 * i, 1);
> +      do_test (&json_ctx, i, i, 2048 + 64 * i, 1);
>      }
>
>    json_array_end (&json_ctx);
> --
> 2.25.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.

-- 
H.J.

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

* Re: [PATCH v2 2/2] x86: Improve memmove-vec-unaligned-erms.S
  2021-05-24  3:21       ` H.J. Lu
@ 2022-04-28  0:07         ` Sunil Pandey
  0 siblings, 0 replies; 10+ messages in thread
From: Sunil Pandey @ 2022-04-28  0:07 UTC (permalink / raw)
  To: H.J. Lu, libc-stable; +Cc: Noah Goldstein, GNU C Library

On Sun, May 23, 2021 at 8:40 PM H.J. Lu via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> On Sun, May 23, 2021 at 8:15 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > This patch changes the condition for copy 4x VEC so that if length is
> > exactly equal to 4 * VEC_SIZE it will use the 4x VEC case instead of
> > 8x VEC case.
> >
> > Results For Skylake memcpy-avx2-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 0   , 9.137   , 6.873   , New , 75.22
> > 128 , 7   , 0   , 12.933  , 7.732   , New , 59.79
> > 128 , 0   , 7   , 11.852  , 6.76    , New , 57.04
> > 128 , 7   , 7   , 12.587  , 6.808   , New , 54.09
> >
> > Results For Icelake memcpy-evex-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 0   , 9.963   , 5.416   , New , 54.36
> > 128 , 7   , 0   , 16.467  , 8.061   , New , 48.95
> > 128 , 0   , 7   , 14.388  , 7.644   , New , 53.13
> > 128 , 7   , 7   , 14.546  , 7.642   , New , 52.54
> >
> > Results For Tigerlake memcpy-evex-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 0   , 8.979   , 4.95    , New , 55.13
> > 128 , 7   , 0   , 14.245  , 7.122   , New , 50.0
> > 128 , 0   , 7   , 12.668  , 6.675   , New , 52.69
> > 128 , 7   , 7   , 13.042  , 6.802   , New , 52.15
> >
> > Results For Skylake memmove-avx2-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 32  , 6.181   , 5.691   , New , 92.07
> > 128 , 32  , 0   , 6.165   , 5.752   , New , 93.3
> > 128 , 0   , 7   , 13.923  , 9.37    , New , 67.3
> > 128 , 7   , 0   , 12.049  , 10.182  , New , 84.5
> >
> > Results For Icelake memmove-evex-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 32  , 5.479   , 4.889   , New , 89.23
> > 128 , 32  , 0   , 5.127   , 4.911   , New , 95.79
> > 128 , 0   , 7   , 18.885  , 13.547  , New , 71.73
> > 128 , 7   , 0   , 15.565  , 14.436  , New , 92.75
> >
> > Results For Tigerlake memmove-evex-erms
> > size, al1 , al2 , Cur T   , New T   , Win , New / Cur
> > 128 , 0   , 32  , 5.275   , 4.815   , New , 91.28
> > 128 , 32  , 0   , 5.376   , 4.565   , New , 84.91
> > 128 , 0   , 7   , 19.426  , 14.273  , New , 73.47
> > 128 , 7   , 0   , 15.924  , 14.951  , New , 93.89
> >
> > Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> > ---
> >  sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> > index 5e4a071f16..a783da5de2 100644
> > --- a/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> > +++ b/sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
> > @@ -420,8 +420,8 @@ L(more_2x_vec):
> >         cmpq    $(VEC_SIZE * 8), %rdx
> >         ja      L(more_8x_vec)
> >         cmpq    $(VEC_SIZE * 4), %rdx
> > -       jb      L(last_4x_vec)
> > -       /* Copy from 4 * VEC to 8 * VEC, inclusively. */
> > +       jbe     L(last_4x_vec)
> > +       /* Copy from 4 * VEC + 1 to 8 * VEC, inclusively. */
> >         VMOVU   (%rsi), %VEC(0)
> >         VMOVU   VEC_SIZE(%rsi), %VEC(1)
> >         VMOVU   (VEC_SIZE * 2)(%rsi), %VEC(2)
> > @@ -440,7 +440,7 @@ L(more_2x_vec):
> >         VMOVU   %VEC(7), -(VEC_SIZE * 4)(%rdi,%rdx)
> >         VZEROUPPER_RETURN
> >  L(last_4x_vec):
> > -       /* Copy from 2 * VEC to 4 * VEC. */
> > +       /* Copy from 2 * VEC + 1 to 4 * VEC, inclusively. */
> >         VMOVU   (%rsi), %VEC(0)
> >         VMOVU   VEC_SIZE(%rsi), %VEC(1)
> >         VMOVU   -VEC_SIZE(%rsi,%rdx), %VEC(2)
> > --
> > 2.25.1
> >
>
> LGTM.
>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
>
> Thanks.
>
> --
> H.J.

I would like to backport this patch to release branches.
Any comments or objections?

--Sunil

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

end of thread, other threads:[~2022-04-28  0:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24  1:30 [PATCH v1 1/2] Bench: Add support for choose direction of memcpy in benchtests Noah Goldstein
2021-05-24  1:30 ` [PATCH v1 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
2021-05-24  1:45   ` H.J. Lu
2021-05-24  3:15     ` Noah Goldstein
2021-05-24  3:15   ` [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests Noah Goldstein
2021-05-24  3:15     ` [PATCH v2 2/2] x86: Improve memmove-vec-unaligned-erms.S Noah Goldstein
2021-05-24  3:21       ` H.J. Lu
2022-04-28  0:07         ` Sunil Pandey
2021-05-24  3:22     ` [PATCH v2 1/2] Bench: Add support for choose direction of memcpy in benchtests H.J. Lu
2021-05-24  1:48 ` [PATCH v1 " H.J. Lu

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 read-only IMAP folder(s) and NNTP newsgroup(s).