public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	"Carlos O'Donell" <carlos@systemhalted.org>
Subject: Re: [PATCH v6 2/2] x86: Expanding test-memmove.c, test-memcpy.c, bench-memcpy-large.c
Date: Fri, 2 Apr 2021 17:35:48 -0400	[thread overview]
Message-ID: <CAFUsyfJr_3qb0Qxorg663E0M2DdenaXp0UFLbuiOzw=Z9YoJQQ@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOqar7-nM4o96VUJFZeUUare-7mPP7CKVL69shuoAt91cw@mail.gmail.com>

On Fri, Apr 2, 2021 at 4:36 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Apr 2, 2021 at 1:26 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > From: noah <goldstein.w.n@gmail.com>
> >
> > No Bug. This commit expanding the range of tests / benchmarks for
> > memmove and memcpy. The test expansion is mostly in the vein of
> > increasing the maximum size, increasing the number of unique
> > alignments tested, and testing both source < destination and vice
> > versa. The benchmark expansaion is just to increase the number of
> > unique alignments. test-memcpy, test-memccpy, test-mempcpy,
> > test-memmove, and tst-memmove-overflow all pass.
> >
> > Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> > ---
> >  benchtests/bench-memcpy-large.c |  8 +++-
> >  string/test-memcpy.c            | 61 ++++++++++++++++------------
> >  string/test-memmove.c           | 70 ++++++++++++++++++++-------------
> >  3 files changed, 83 insertions(+), 56 deletions(-)
> >
> > diff --git a/benchtests/bench-memcpy-large.c b/benchtests/bench-memcpy-large.c
> > index 3df1575514..efb9627b1e 100644
> > --- a/benchtests/bench-memcpy-large.c
> > +++ b/benchtests/bench-memcpy-large.c
> > @@ -57,11 +57,11 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
> >    size_t i, j;
> >    char *s1, *s2;
> >
> > -  align1 &= 63;
> > +  align1 &= 4095;
> >    if (align1 + len >= page_size)
> >      return;
> >
> > -  align2 &= 63;
> > +  align2 &= 4095;
> >    if (align2 + len >= page_size)
> >      return;
> >
> > @@ -113,6 +113,10 @@ test_main (void)
> >        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);
> >      }
> >
> >    json_array_end (&json_ctx);
> > diff --git a/string/test-memcpy.c b/string/test-memcpy.c
> > index 2e9c6bd099..c9dfc88fed 100644
> > --- a/string/test-memcpy.c
> > +++ b/string/test-memcpy.c
> > @@ -82,11 +82,11 @@ do_test (size_t align1, size_t align2, size_t len)
> >    size_t i, j;
> >    char *s1, *s2;
> >
> > -  align1 &= 63;
> > +  align1 &= 4095;
> >    if (align1 + len >= page_size)
> >      return;
> >
> > -  align2 &= 63;
> > +  align2 &= 4095;
> >    if (align2 + len >= page_size)
> >      return;
> >
> > @@ -213,11 +213,9 @@ do_random_tests (void)
> >  }
> >
> >  static void
> > -do_test1 (void)
> > +do_test1 (size_t size)
> >  {
> > -  size_t size = 0x100000;
> >    void *large_buf;
> > -
> >    large_buf = mmap (NULL, size * 2 + page_size, PROT_READ | PROT_WRITE,
> >                     MAP_PRIVATE | MAP_ANON, -1, 0);
> >    if (large_buf == MAP_FAILED)
> > @@ -233,27 +231,32 @@ do_test1 (void)
> >    uint32_t *dest = large_buf;
> >    uint32_t *src = large_buf + size + page_size;
> >    size_t i;
> > -
> > -  for (i = 0; i < arrary_size; i++)
> > -    src[i] = (uint32_t) i;
> > -
> > -  FOR_EACH_IMPL (impl, 0)
> > +  size_t repeats;
> > +  for(repeats = 0; repeats < 2; repeats++)
> >      {
> > -      memset (dest, -1, size);
> > -      CALL (impl, (char *) dest, (char *) src, size);
> >        for (i = 0; i < arrary_size; i++)
> > -       if (dest[i] != src[i])
> > -         {
> > -           error (0, 0,
> > -                  "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"",
> > -                  impl->name, dest, src, i);
> > -           ret = 1;
> > -           break;
> > -         }
> > +        src[i] = (uint32_t) i;
> > +
> > +      FOR_EACH_IMPL (impl, 0)
> > +        {
> > +            printf ("\t\tRunning: %s\n", impl->name);
> > +          memset (dest, -1, size);
> > +          CALL (impl, (char *) dest, (char *) src, size);
> > +          for (i = 0; i < arrary_size; i++)
> > +        if (dest[i] != src[i])
> > +          {
> > +            error (0, 0,
> > +               "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"",
> > +               impl->name, dest, src, i);
> > +            ret = 1;
> > +            munmap ((void *) large_buf, size * 2 + page_size);
> > +            return;
> > +          }
> > +        }
> > +      dest = src;
> > +      src = large_buf;
> >      }
> > -
> > -  munmap ((void *) dest, size);
> > -  munmap ((void *) src, size);
> > +  munmap ((void *) large_buf, size * 2 + page_size);
> >  }
> >
> >  int
> > @@ -275,7 +278,6 @@ test_main (void)
> >        do_test (0, i, 1 << i);
> >        do_test (i, i, 1 << i);
> >      }
> > -
> >    for (i = 0; i < 32; ++i)
> >      {
> >        do_test (0, 0, i);
> > @@ -294,12 +296,19 @@ test_main (void)
> >        do_test (i, i, 16 * i);
> >      }
> >
> > +  for (i = 19; i <= 25; ++i)
> > +    {
> > +      do_test (255, 0, 1 << i);
> > +      do_test (0, 255, i);
> > +      do_test (0, 4000, i);
> > +    }
> > +
> >    do_test (0, 0, getpagesize ());
> >
> >    do_random_tests ();
> >
> > -  do_test1 ();
> > -
> > +  do_test1 (0x100000);
> > +  do_test1 (0x2000000);
> >    return ret;
> >  }
> >
> > diff --git a/string/test-memmove.c b/string/test-memmove.c
> > index 2e3ce75b9b..ff8099d12f 100644
> > --- a/string/test-memmove.c
> > +++ b/string/test-memmove.c
> > @@ -247,7 +247,7 @@ do_random_tests (void)
> >  }
> >
> >  static void
> > -do_test2 (void)
> > +do_test2 (size_t offset)
> >  {
> >    size_t size = 0x20000000;
> >    uint32_t * large_buf;
> > @@ -268,33 +268,45 @@ do_test2 (void)
> >      }
> >
> >    size_t bytes_move = 0x80000000 - (uintptr_t) large_buf;
> > +  if (bytes_move + offset * sizeof (uint32_t) > size)
> > +    {
> > +      munmap ((void *) large_buf, size);
> > +      return;
> > +    }
> >    size_t arr_size = bytes_move / sizeof (uint32_t);
> >    size_t i;
> > -
> > -  FOR_EACH_IMPL (impl, 0)
> > -    {
> > -      for (i = 0; i < arr_size; i++)
> > -        large_buf[i] = (uint32_t) i;
> > -
> > -      uint32_t * dst = &large_buf[33];
> > -
> > -#ifdef TEST_BCOPY
> > -      CALL (impl, (char *) large_buf, (char *) dst, bytes_move);
> > -#else
> > -      CALL (impl, (char *) dst, (char *) large_buf, bytes_move);
> > -#endif
> > -
> > -      for (i = 0; i < arr_size; i++)
> > -       {
> > -         if (dst[i] != (uint32_t) i)
> > -           {
> > -             error (0, 0,
> > -                    "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"",
> > -                    impl->name, dst, large_buf, i);
> > -             ret = 1;
> > -             break;
> > -           }
> > -       }
> > +  size_t repeats;
> > +  uint32_t * src = large_buf;
> > +  uint32_t * dst = &large_buf[offset];
> > +  for (repeats = 0; repeats < 2; ++repeats)
> > +    {
>             ^  Trailing whitespaces.

fixed.
>
> > +      FOR_EACH_IMPL (impl, 0)
> > +        {
> > +          for (i = 0; i < arr_size; i++)
> > +            src[i] = (uint32_t) i;
> > +
> > +
> > +    #ifdef TEST_BCOPY
> > +          CALL (impl, (char *) src, (char *) dst, bytes_move);
> > +    #else
> > +          CALL (impl, (char *) dst, (char *) src, bytes_move);
> > +    #endif
> > +
> > +          for (i = 0; i < arr_size; i++)
> > +        {
> > +          if (dst[i] != (uint32_t) i)
> > +            {
> > +              error (0, 0,
> > +                 "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"",
> > +                 impl->name, dst, large_buf, i);
> > +              ret = 1;
> > +              munmap ((void *) large_buf, size);
> > +              return;
> > +            }
> > +        }
> > +        }
> > +      src = dst;
> > +      dst = large_buf;
> >      }
> >
> >    munmap ((void *) large_buf, size);
> > @@ -340,8 +352,10 @@ test_main (void)
> >
> >    do_random_tests ();
> >
> > -  do_test2 ();
> > -
> > +  do_test2 (33);
> > +  do_test2 (0x200000);
> > +  do_test2 (0x4000000 - 1);
> > +  do_test2 (0x4000000);
> >    return ret;
> >  }
> >
> > --
> > 2.29.2
> >
>
>
> --
> H.J.

  reply	other threads:[~2021-04-02 21:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 20:26 [PATCH v6 1/2] x86: Update large memcpy case in memmove-vec-unaligned-erms.S Noah Goldstein
2021-04-02 20:26 ` [PATCH v6 2/2] x86: Expanding test-memmove.c, test-memcpy.c, bench-memcpy-large.c Noah Goldstein
2021-04-02 20:35   ` H.J. Lu
2021-04-02 21:35     ` Noah Goldstein [this message]
2021-04-02 22:08 ` [PATCH v6 1/2] x86: Update large memcpy case in memmove-vec-unaligned-erms.S H.J. Lu
2021-04-02 23:09   ` Noah Goldstein
2021-04-02 23:15     ` H.J. Lu

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='CAFUsyfJr_3qb0Qxorg663E0M2DdenaXp0UFLbuiOzw=Z9YoJQQ@mail.gmail.com' \
    --to=goldstein.w.n@gmail.com \
    --cc=carlos@systemhalted.org \
    --cc=hjl.tools@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).