public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq
@ 2021-11-01 13:56 Wilco Dijkstra
  2021-11-01 16:01 ` Noah Goldstein
  0 siblings, 1 reply; 7+ messages in thread
From: Wilco Dijkstra @ 2021-11-01 13:56 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: 'GNU C Library'

Hi Noah,

As committed, it's literally the same benchmark as memcmp, however I
expected it to call __memcmpeq... You'll need to change the definition of
MEMCMP as well.

Cheers,
Wilco

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

* Re: [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq
  2021-11-01 13:56 [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq Wilco Dijkstra
@ 2021-11-01 16:01 ` Noah Goldstein
  2021-11-02 20:57   ` Noah Goldstein
  0 siblings, 1 reply; 7+ messages in thread
From: Noah Goldstein @ 2021-11-01 16:01 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: GNU C Library

On Mon, Nov 1, 2021 at 8:56 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
> Hi Noah,
>
> As committed, it's literally the same benchmark as memcmp, however I
> expected it to call __memcmpeq... You'll need to change the definition of
> MEMCMP as well.

Is this also true for 'wmemcmp'? I don't see it defining MEMCMP either.

>
> Cheers,
> Wilco

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

* Re: [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq
  2021-11-01 16:01 ` Noah Goldstein
@ 2021-11-02 20:57   ` Noah Goldstein
  2021-11-03 13:39     ` Wilco Dijkstra
  0 siblings, 1 reply; 7+ messages in thread
From: Noah Goldstein @ 2021-11-02 20:57 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: GNU C Library

On Mon, Nov 1, 2021 at 11:01 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> On Mon, Nov 1, 2021 at 8:56 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
> >
> > Hi Noah,
> >
> > As committed, it's literally the same benchmark as memcmp, however I
> > expected it to call __memcmpeq... You'll need to change the definition of
> > MEMCMP as well.
>

Not certain why, but it does seem to be getting the right ifuncs. Can update it
if desirable.

> Is this also true for 'wmemcmp'? I don't see it defining MEMCMP either.
>
> >
> > Cheers,
> > Wilco

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

* Re: [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq
  2021-11-02 20:57   ` Noah Goldstein
@ 2021-11-03 13:39     ` Wilco Dijkstra
  2021-11-03 17:17       ` Noah Goldstein
  0 siblings, 1 reply; 7+ messages in thread
From: Wilco Dijkstra @ 2021-11-03 13:39 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library

Hi Noah,

> > As committed, it's literally the same benchmark as memcmp, however I
> > expected it to call __memcmpeq... You'll need to change the definition of
> > MEMCMP as well.

> Not certain why, but it does seem to be getting the right ifuncs. Can update it
> if desirable.

> Is this also true for 'wmemcmp'? I don't see it defining MEMCMP either.

Ifuncs use TEST_NAME (which is right) while there is also IMPL (MEMCMP, 1)
which is not correct. It is defined in bench-string - it does support wmemcmp,
but it is missing support for __memcmpeq.

Cheers,
Wilco

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

* Re: [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq
  2021-11-03 13:39     ` Wilco Dijkstra
@ 2021-11-03 17:17       ` Noah Goldstein
  0 siblings, 0 replies; 7+ messages in thread
From: Noah Goldstein @ 2021-11-03 17:17 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: GNU C Library

On Wed, Nov 3, 2021 at 8:39 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
> Hi Noah,
>
> > > As committed, it's literally the same benchmark as memcmp, however I
> > > expected it to call __memcmpeq... You'll need to change the definition of
> > > MEMCMP as well.
>
> > Not certain why, but it does seem to be getting the right ifuncs. Can update it
> > if desirable.
>
> > Is this also true for 'wmemcmp'? I don't see it defining MEMCMP either.
>
> Ifuncs use TEST_NAME (which is right) while there is also IMPL (MEMCMP, 1)
> which is not correct. It is defined in bench-string - it does support wmemcmp,
> but it is missing support for __memcmpeq.

That all makes sense. What's confusing is that despite not setting MEMCMP
for __memcmpeq, the benchmarks still test the correct implementations.

It appears that in FOR_EACH_IMPL:
https://sourceware.org/git/?p=glibc.git;a=blob;f=benchtests/bench-string.h;h=12f27473ff5714e50a94f3f1c5b06a56b99bc742;hb=HEAD#l200

The only check if selecting the function from the ifunc list is that
its name is not
an exact match of whatever MEMCMP is defined as.

Will post a patch to fix but is a bit odd.

>
> Cheers,
> Wilco

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

* Re: [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq
  2021-10-27 16:07 ` [PATCH v2 " Noah Goldstein
@ 2021-10-27 17:59   ` H.J. Lu
  0 siblings, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2021-10-27 17:59 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library

On Wed, Oct 27, 2021 at 9:08 AM Noah Goldstein via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> No bug. This commit adds __memcmpeq benchmarks. The benchmarks just
> use the existing ones in memcmp. This will be useful for testing
> implementations of __memcmpeq that do not just alias memcmp.
> ---
>  benchtests/Makefile         |  2 +-
>  benchtests/bench-memcmp.c   | 14 ++++++++------
>  benchtests/bench-memcmpeq.c | 20 ++++++++++++++++++++
>  3 files changed, 29 insertions(+), 7 deletions(-)
>  create mode 100644 benchtests/bench-memcmpeq.c
>
> diff --git a/benchtests/Makefile b/benchtests/Makefile
> index b690aaf65b..7be0e47c47 100644
> --- a/benchtests/Makefile
> +++ b/benchtests/Makefile
> @@ -103,7 +103,7 @@ bench := $(foreach B,$(filter bench-%,${BENCHSET}), ${${B}})
>  endif
>
>  # String function benchmarks.
> -string-benchset := memccpy memchr memcmp memcpy memmem memmove \
> +string-benchset := memccpy memchr memcmp memcmpeq memcpy memmem memmove \
>                    mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \
>                    strcat strchr strchrnul strcmp strcpy strcspn strlen \
>                    strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
> diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
> index 0d6a93bf29..2cf65525bb 100644
> --- a/benchtests/bench-memcmp.c
> +++ b/benchtests/bench-memcmp.c
> @@ -17,17 +17,21 @@
>     <https://www.gnu.org/licenses/>.  */
>
>  #define TEST_MAIN
> -#ifdef WIDE
> +#ifdef TEST_MEMCMPEQ
> +# define TEST_NAME "__memcmpeq"
> +# define SIMPLE_MEMCMP simple_memcmpeq
> +#elif defined WIDE
>  # define TEST_NAME "wmemcmp"
> +# define SIMPLE_MEMCMP simple_wmemcmp
>  #else
>  # define TEST_NAME "memcmp"
> +# define SIMPLE_MEMCMP simple_memcmp
>  #endif
>  #include "bench-string.h"
>  #ifdef WIDE
>
> -# define SIMPLE_MEMCMP simple_wmemcmp
>  int
> -simple_wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n)
> +SIMPLE_MEMCMP (const wchar_t *s1, const wchar_t *s2, size_t n)
>  {
>    int ret = 0;
>    /* Warning!
> @@ -40,10 +44,8 @@ simple_wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n)
>  #else
>  # include <limits.h>
>
> -# define SIMPLE_MEMCMP simple_memcmp
> -
>  int
> -simple_memcmp (const char *s1, const char *s2, size_t n)
> +SIMPLE_MEMCMP (const char *s1, const char *s2, size_t n)
>  {
>    int ret = 0;
>
> diff --git a/benchtests/bench-memcmpeq.c b/benchtests/bench-memcmpeq.c
> new file mode 100644
> index 0000000000..e918d4f77c
> --- /dev/null
> +++ b/benchtests/bench-memcmpeq.c
> @@ -0,0 +1,20 @@
> +/* Measure __memcmpeq functions.
> +   Copyright (C) 2015-2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#define TEST_MEMCMPEQ 1
> +#include "bench-memcmp.c"
> --
> 2.25.1
>

LGTM.

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

Thanks.

-- 
H.J.

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

* [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq
  2021-10-27  2:43 [PATCH v1 " Noah Goldstein
@ 2021-10-27 16:07 ` Noah Goldstein
  2021-10-27 17:59   ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Noah Goldstein @ 2021-10-27 16:07 UTC (permalink / raw)
  To: libc-alpha

No bug. This commit adds __memcmpeq benchmarks. The benchmarks just
use the existing ones in memcmp. This will be useful for testing
implementations of __memcmpeq that do not just alias memcmp.
---
 benchtests/Makefile         |  2 +-
 benchtests/bench-memcmp.c   | 14 ++++++++------
 benchtests/bench-memcmpeq.c | 20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 7 deletions(-)
 create mode 100644 benchtests/bench-memcmpeq.c

diff --git a/benchtests/Makefile b/benchtests/Makefile
index b690aaf65b..7be0e47c47 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -103,7 +103,7 @@ bench := $(foreach B,$(filter bench-%,${BENCHSET}), ${${B}})
 endif
 
 # String function benchmarks.
-string-benchset := memccpy memchr memcmp memcpy memmem memmove \
+string-benchset := memccpy memchr memcmp memcmpeq memcpy memmem memmove \
 		   mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \
 		   strcat strchr strchrnul strcmp strcpy strcspn strlen \
 		   strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
index 0d6a93bf29..2cf65525bb 100644
--- a/benchtests/bench-memcmp.c
+++ b/benchtests/bench-memcmp.c
@@ -17,17 +17,21 @@
    <https://www.gnu.org/licenses/>.  */
 
 #define TEST_MAIN
-#ifdef WIDE
+#ifdef TEST_MEMCMPEQ
+# define TEST_NAME "__memcmpeq"
+# define SIMPLE_MEMCMP simple_memcmpeq
+#elif defined WIDE
 # define TEST_NAME "wmemcmp"
+# define SIMPLE_MEMCMP simple_wmemcmp
 #else
 # define TEST_NAME "memcmp"
+# define SIMPLE_MEMCMP simple_memcmp
 #endif
 #include "bench-string.h"
 #ifdef WIDE
 
-# define SIMPLE_MEMCMP simple_wmemcmp
 int
-simple_wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n)
+SIMPLE_MEMCMP (const wchar_t *s1, const wchar_t *s2, size_t n)
 {
   int ret = 0;
   /* Warning!
@@ -40,10 +44,8 @@ simple_wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n)
 #else
 # include <limits.h>
 
-# define SIMPLE_MEMCMP simple_memcmp
-
 int
-simple_memcmp (const char *s1, const char *s2, size_t n)
+SIMPLE_MEMCMP (const char *s1, const char *s2, size_t n)
 {
   int ret = 0;
 
diff --git a/benchtests/bench-memcmpeq.c b/benchtests/bench-memcmpeq.c
new file mode 100644
index 0000000000..e918d4f77c
--- /dev/null
+++ b/benchtests/bench-memcmpeq.c
@@ -0,0 +1,20 @@
+/* Measure __memcmpeq functions.
+   Copyright (C) 2015-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#define TEST_MEMCMPEQ 1
+#include "bench-memcmp.c"
-- 
2.25.1


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

end of thread, other threads:[~2021-11-03 17:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01 13:56 [PATCH v2 2/6] Benchtests: Add benchtests for __memcmpeq Wilco Dijkstra
2021-11-01 16:01 ` Noah Goldstein
2021-11-02 20:57   ` Noah Goldstein
2021-11-03 13:39     ` Wilco Dijkstra
2021-11-03 17:17       ` Noah Goldstein
  -- strict thread matches above, loose matches on Subject: below --
2021-10-27  2:43 [PATCH v1 " Noah Goldstein
2021-10-27 16:07 ` [PATCH v2 " Noah Goldstein
2021-10-27 17:59   ` 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).