public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Noah Goldstein <goldstein.w.n@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	"Carlos O'Donell" <carlos@systemhalted.org>
Subject: Re: [PATCH v2 1/3] x86: Expand bench-memcmp.c and test-memcmp.c
Date: Tue, 18 May 2021 19:29:13 -0700	[thread overview]
Message-ID: <CAMe9rOrUPigveS9BKEfy63uh24qxsbwnYsUsmWUmXucO=gS7tQ@mail.gmail.com> (raw)
In-Reply-To: <20210519022438.2986411-1-goldstein.w.n@gmail.com>

On Tue, May 18, 2021 at 7:24 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> No bug. This commit adds some additional performance test cases to
> bench-memcmp.c and test-memcmp.c. The new benchtests include some
> medium range sizes, as well as small sizes near page cross. The new
> correctness tests correspond with the new benchtests though add some
> additional cases for checking the page cross logic.
>
> Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> ---
>  benchtests/bench-memcmp.c | 32 +++++++++++++++++++++++++------
>  string/test-memcmp.c      | 40 +++++++++++++++++++++++++++++++++------
>  2 files changed, 60 insertions(+), 12 deletions(-)
>
> diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
> index eb0f94a0f1..744c7ec5ba 100644
> --- a/benchtests/bench-memcmp.c
> +++ b/benchtests/bench-memcmp.c
> @@ -88,11 +88,11 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
>    if (len == 0)
>      return;
>
> -  align1 &= 63;
> +  align1 &= (4096 - CHARBYTES);
>    if (align1 + (len + 1) * CHARBYTES >= page_size)
>      return;
>
> -  align2 &= 63;
> +  align2 &= (4096 - CHARBYTES);
>    if (align2 + (len + 1) * CHARBYTES >= page_size)
>      return;
>
> @@ -100,6 +100,7 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
>    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, "result", (double) exp_result);
>    json_array_begin (json_ctx, "timings");
>
>    FOR_EACH_IMPL (impl, 0)
> @@ -145,18 +146,31 @@ test_main (void)
>    json_array_end (&json_ctx);
>
>    json_array_begin (&json_ctx, "results");
> -  for (i = 1; i < 16; ++i)
> +  for (i = 1; i < 32; ++i)
>      {
>        do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, 0);
>        do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, 1);
>        do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, -1);
>      }
>
> -  for (i = 0; i < 16; ++i)
> +  for (i = 0; i < 32; ++i)
>      {
>        do_test (&json_ctx, 0, 0, i, 0);
>        do_test (&json_ctx, 0, 0, i, 1);
>        do_test (&json_ctx, 0, 0, i, -1);
> +      do_test (&json_ctx, 4096 - i, 0, i, 0);
> +      do_test (&json_ctx, 4096 - i, 0, i, 1);
> +      do_test (&json_ctx, 4096 - i, 0, i, -1);
> +    }
> +
> +  for (i = 33; i < 385; i += 32)
> +    {
> +      do_test (&json_ctx, 0, 0, i, 0);
> +      do_test (&json_ctx, 0, 0, i, 1);
> +      do_test (&json_ctx, 0, 0, i, -1);
> +      do_test (&json_ctx, i, 0, i, 0);
> +      do_test (&json_ctx, 0, i, i, 1);
> +      do_test (&json_ctx, i, i, i, -1);
>      }
>
>    for (i = 1; i < 10; ++i)
> @@ -164,13 +178,19 @@ test_main (void)
>        do_test (&json_ctx, 0, 0, 2 << i, 0);
>        do_test (&json_ctx, 0, 0, 2 << i, 1);
>        do_test (&json_ctx, 0, 0, 2 << i, -1);
> -      do_test (&json_ctx, 0, 0, 16 << i, 0);
>        do_test (&json_ctx, (8 - i) * CHARBYTES, (2 * i) * CHARBYTES, 16 << i, 0);
> +      do_test (&json_ctx, 0, 0, 16 << i, 0);
>        do_test (&json_ctx, 0, 0, 16 << i, 1);
>        do_test (&json_ctx, 0, 0, 16 << i, -1);
> +      do_test (&json_ctx, i, 0, 2 << i, 0);
> +      do_test (&json_ctx, 0, i, 2 << i, 1);
> +      do_test (&json_ctx, i, i, 2 << i, -1);
> +      do_test (&json_ctx, i, 0, 16 << i, 0);
> +      do_test (&json_ctx, 0, i, 16 << i, 1);
> +      do_test (&json_ctx, i, i, 16 << i, -1);
>      }
>
> -  for (i = 1; i < 8; ++i)
> +  for (i = 1; i < 10; ++i)
>      {
>        do_test (&json_ctx, i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 0);
>        do_test (&json_ctx, i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 1);
> diff --git a/string/test-memcmp.c b/string/test-memcmp.c
> index 02ea9b782d..fbda26a41e 100644
> --- a/string/test-memcmp.c
> +++ b/string/test-memcmp.c
> @@ -111,11 +111,11 @@ do_test (size_t align1, size_t align2, size_t len, int exp_result)
>    if (len == 0)
>      return;
>
> -  align1 &= 63;
> +  align1 &= (4096 - CHARBYTES);
>    if (align1 + (len + 1) * CHARBYTES >= page_size)
>      return;
>
> -  align2 &= 63;
> +  align2 &= (4096 - CHARBYTES);
>    if (align2 + (len + 1) * CHARBYTES >= page_size)
>      return;
>
> @@ -487,18 +487,40 @@ test_main (void)
>      printf ("\t%s", impl->name);
>    putchar ('\n');
>
> -  for (i = 1; i < 16; ++i)
> +  for (i = 1; i < 32; ++i)
>      {
>        do_test (i * CHARBYTES, i * CHARBYTES, i, 0);
>        do_test (i * CHARBYTES, i * CHARBYTES, i, 1);
>        do_test (i * CHARBYTES, i * CHARBYTES, i, -1);
>      }
>
> -  for (i = 0; i < 16; ++i)
> +  for (i = 0; i < 32; ++i)
>      {
>        do_test (0, 0, i, 0);
>        do_test (0, 0, i, 1);
>        do_test (0, 0, i, -1);
> +      do_test (4096 - i, 0, i, 0);
> +      do_test (4096 - i, 0, i, 1);
> +      do_test (4096 - i, 0, i, -1);
> +      do_test (4095, 0, i, 0);
> +      do_test (4095, 0, i, 1);
> +      do_test (4095, 0, i, -1);
> +      do_test (4095, 4095, i, 0);
> +      do_test (4095, 4095, i, 1);
> +      do_test (4095, 4095, i, -1);
> +      do_test (4000, 95, i, 0);
> +      do_test (4000, 95, i, 1);
> +      do_test (4000, 95, i, -1);
> +    }
> +
> +  for (i = 33; i < 385; i += 32)
> +    {
> +      do_test (0, 0, i, 0);
> +      do_test (0, 0, i, 1);
> +      do_test (0, 0, i, -1);
> +      do_test (i, 0, i, 0);
> +      do_test (0, i, i, 1);
> +      do_test (i, i, i, -1);
>      }
>
>    for (i = 1; i < 10; ++i)
> @@ -506,13 +528,19 @@ test_main (void)
>        do_test (0, 0, 2 << i, 0);
>        do_test (0, 0, 2 << i, 1);
>        do_test (0, 0, 2 << i, -1);
> -      do_test (0, 0, 16 << i, 0);
>        do_test ((8 - i) * CHARBYTES, (2 * i) * CHARBYTES, 16 << i, 0);
> +      do_test (0, 0, 16 << i, 0);
>        do_test (0, 0, 16 << i, 1);
>        do_test (0, 0, 16 << i, -1);
> +      do_test (i, 0, 2 << i, 0);
> +      do_test (0, i, 2 << i, 1);
> +      do_test (i, i, 2 << i, -1);
> +      do_test (i, 0, 16 << i, 0);
> +      do_test (0, i, 16 << i, 1);
> +      do_test (i, i, 16 << i, -1);
>      }
>
> -  for (i = 1; i < 8; ++i)
> +  for (i = 1; i < 10; ++i)
>      {
>        do_test (i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 0);
>        do_test (i * CHARBYTES, 2 * (i * CHARBYTES), 8 << i, 1);
> --
> 2.29.2
>

LGTM.

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

Thanks.

-- 
H.J.

      parent reply	other threads:[~2021-05-19  2:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 18:44 [PATCH v1 " Noah Goldstein
2021-05-17 18:44 ` [PATCH v1 2/3] x86: Optimize memcmp-avx2-movbe.S Noah Goldstein
2021-05-19  1:01   ` H.J. Lu
2021-05-19  2:25     ` Noah Goldstein
2021-05-17 18:44 ` [PATCH v1 3/3] x86: Optimize memcmp-evex-movbe.S Noah Goldstein
2021-05-19  1:03   ` H.J. Lu
2021-05-19  2:25     ` Noah Goldstein
2021-05-19  1:04 ` [PATCH v1 1/3] x86: Expand bench-memcmp.c and test-memcmp.c H.J. Lu
2021-05-19  1:53   ` Noah Goldstein
2021-05-19  2:24 ` [PATCH v2 " Noah Goldstein
2021-05-19  2:24   ` [PATCH v2 2/3] x86: Optimize memcmp-avx2-movbe.S Noah Goldstein
2021-05-19  2:27     ` H.J. Lu
2022-04-28  0:01       ` Sunil Pandey
2021-05-19  2:24   ` [PATCH v2 3/3] x86: Optimize memcmp-evex-movbe.S Noah Goldstein
2021-05-19  2:28     ` H.J. Lu
2022-04-28  0:03       ` Sunil Pandey
2021-05-19  2:29   ` H.J. Lu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOrUPigveS9BKEfy63uh24qxsbwnYsUsmWUmXucO=gS7tQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=carlos@systemhalted.org \
    --cc=goldstein.w.n@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).