From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 244473858289 for ; Wed, 8 Mar 2023 15:23:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 244473858289 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x332.google.com with SMTP id o4-20020a9d6d04000000b00694127788f4so9169825otp.6 for ; Wed, 08 Mar 2023 07:23:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678289001; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Br/PbvFzQBrCsW2q3UhwL3NmNFHHpAQIqA4nLCiVrF0=; b=U76poySzMyaGiRzaKlk+iDU74VvXMK4G6V/Dv05AMQgrJEaWOLdeQfPNZSKWPN8pag iO5fkp4BrOJVWqb+7on/94lW34uX6Mb9g0wWhXTEhrsqFfVXet9yekgE2tHS5NddY7k2 C5o4k9qwJ1sO354uC3ncojy3vLm3JwKnuMgiV8J980Q++W/9ut8oq1OXqRZ41kBjgvRj yWdJ5ICi1aDt3MahbqkKNAQurWpc1Gd76Blzzjrcea/3FhtSnwT4FL+aLOZZUVQmizCD EnDv5r0CCVfCOltxwwMrY+IrhcQ8lU3eVcgswaQvaR+9xonOLkywD3r/g9CTLqPcRil1 Yrrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678289001; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Br/PbvFzQBrCsW2q3UhwL3NmNFHHpAQIqA4nLCiVrF0=; b=0so02jJXbTureUkKrV1sfWpd6F3R3HZsM1f5HFTEPqR+FRo5xL/0Ej+wSc/PnyNNL4 baJ1/4j70hhG+rBeQnWdGnyo8bj0edq+IWlx0cPjVg0Z/2aKJBEuB3l7b2WJR9VFbNnl 3MvZO0NVKbib38pvwU5La1+QbDcvf3HB90s4swEEwFOOZ8N4k28dv1H8cq3Nh19oyCUa 1l6cC8QB4XL/yqnBAm65WLP1r+opvBQLqdzHzOTG5/+Ohm3HOYFYnzJTvIyBDM3BA14B nIxK3H5TT6GIUUjLv5OxOAzcdLRYGIheXD2SITYDegDmh+w0UwNKZtrrU5cdu4DrujD1 h++g== X-Gm-Message-State: AO0yUKXgky5zJbZMZj4Ndb34O7VX8v+NmYPWPA4/O0OVDQv7jgrtH99Q YtRH8trGYt1M4oaax/JPEd2z+SWpObTE77Iwy1nJzA== X-Google-Smtp-Source: AK7set+O+U26U6es9NaxbRURe2l1RvG7KXaquJyNNhlmt9j9kQzHRkuCz/IpfcFegV2uMCnqRuynxQ== X-Received: by 2002:a9d:60d0:0:b0:686:50ca:7404 with SMTP id b16-20020a9d60d0000000b0068650ca7404mr8183567otk.4.1678289001293; Wed, 08 Mar 2023 07:23:21 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c0:544b:655d:5559:758d:90f7? ([2804:1b3:a7c0:544b:655d:5559:758d:90f7]) by smtp.gmail.com with ESMTPSA id v17-20020a05683011d100b0068d3ec1427bsm6508202otq.69.2023.03.08.07.23.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Mar 2023 07:23:20 -0800 (PST) Message-ID: Date: Wed, 8 Mar 2023 12:23:18 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] Benchtests: Remove simple_str(r)chr Content-Language: en-US To: Wilco Dijkstra , 'GNU C Library' References: From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 08/03/23 07:57, Wilco Dijkstra via Libc-alpha wrote: > > Instead of benchmarking slow byte oriented loops, include the optimized generic > strchr and strrchr implementation. Adjust iteration count to reduce benchmark time. LGTM, thanks. Reviewed-by: Adhemerval Zanella  > > --- > > diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c > index 420930d558e4c6f9de0eb4fc0bff4b536e4cfab3..116ec197603cc784e36d2a990eb9e47b7e90e74f 100644 > --- a/benchtests/bench-strchr.c > +++ b/benchtests/bench-strchr.c > @@ -39,7 +39,6 @@ > # ifdef USE_FOR_STRCHRNUL > # undef STRCHR > # define STRCHR strchrnul > -# define simple_STRCHR simple_STRCHRNUL > # endif /* !USE_FOR_STRCHRNUL */ > # define MIDDLE_CHAR 127 > # define SMALL_CHAR 23 > @@ -47,7 +46,6 @@ > # ifdef USE_FOR_STRCHRNUL > # undef STRCHR > # define STRCHR wcschrnul > -# define simple_STRCHR simple_WCSCHRNUL > # endif /* !USE_FOR_STRCHRNUL */ > # define MIDDLE_CHAR 1121 > # define SMALL_CHAR 851 > @@ -67,18 +65,19 @@ > > typedef CHAR *(*proto_t) (const CHAR *, int); > > -CHAR * > -simple_STRCHR (const CHAR *s, int c) > -{ > - for (; *s != (CHAR) c; ++s) > - if (*s == '\0') > - return NULLRET ((CHAR *) s); > - return (CHAR *) s; > -} > - > -IMPL (simple_STRCHR, 0) > IMPL (STRCHR, 1) > > +#ifndef WIDE > +char *generic_strchr (const char *, int); > +char *generic_strchrnul (const char *, int); > + > +# ifndef USE_FOR_STRCHRNUL > +IMPL (generic_strchr, 0) > +# else > +IMPL (generic_strchrnul, 0) > +# endif > +#endif > + > #ifndef USE_FOR_STRCHRNUL > /* Random benchmarks for strchr (if return is CHAR or NULL). The > rational for the benchmark is returning null/char can be done with > @@ -97,7 +96,7 @@ static void __attribute__ ((noinline, noclone)) > do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl, > const CHAR *s, const CHAR *c) > { > - size_t i, iters = INNER_LOOP_ITERS_LARGE; > + size_t i, iters = INNER_LOOP_ITERS8; > int must_execute = 0; > timing_t start, stop, cur; > TIMING_NOW (start); > @@ -122,7 +121,7 @@ static void __attribute__ ((noinline, noclone)) > do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, > const CHAR *c) > { > - size_t i, iters = INNER_LOOP_ITERS_LARGE; > + size_t i, iters = INNER_LOOP_ITERS8; > timing_t start, stop, cur; > TIMING_NOW (start); > for (i = 0; i < iters; ++i) > @@ -210,7 +209,7 @@ static void > do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, int c, > const CHAR *exp_res) > { > - size_t i, iters = INNER_LOOP_ITERS_LARGE; > + size_t i, iters = INNER_LOOP_ITERS8; > timing_t start, stop, cur; > const CHAR *res = CALL (impl, s, c); > if (res != exp_res) > @@ -401,3 +400,12 @@ test_main (void) > } > > #include > + > +#ifndef WIDE > +# undef STRCHRNUL > +# define STRCHRNUL generic_strchrnul > +# undef STRCHR > +# define STRCHR generic_strchr > +# include > +# include > +#endif > diff --git a/benchtests/bench-strrchr.c b/benchtests/bench-strrchr.c > index a33a657a275416b0cb0c42ba2689e3685c1b62aa..f846797770f9384fcde8eb3d66b3b8c720866452 100644 > --- a/benchtests/bench-strrchr.c > +++ b/benchtests/bench-strrchr.c > @@ -28,30 +28,20 @@ > #define BIG_CHAR MAX_CHAR > > #ifdef WIDE > -# define SIMPLE_STRRCHR simple_wcsrchr > # define SMALL_CHAR 1273 > #else > -# define SIMPLE_STRRCHR simple_strrchr > # define SMALL_CHAR 127 > -#endif > > -typedef CHAR *(*proto_t) (const CHAR *, int); > -CHAR *SIMPLE_STRRCHR (const CHAR *, int); > +char * > +generic_strrchr (const char *, int); > > -IMPL (SIMPLE_STRRCHR, 0) > -IMPL (STRRCHR, 1) > +IMPL (generic_strrchr, 0) > > -CHAR * > -SIMPLE_STRRCHR (const CHAR *s, int c) > -{ > - const CHAR *ret = NULL; > +#endif > > - for (; *s != '\0'; ++s) > - if (*s == (CHAR) c) > - ret = s; > +typedef CHAR *(*proto_t) (const CHAR *, int); > > - return (CHAR *) (c == '\0' ? s : ret); > -} > +IMPL (STRRCHR, 1) > > static void > do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, int c, > @@ -237,3 +227,12 @@ test_main (void) > } > > #include > + > +#define weak_alias(X,Y) > +#define libc_hidden_builtin_def(X) > +#ifndef WIDE > +# undef STRRCHR > +# define STRRCHR generic_strrchr > +# define __memrchr memrchr > +# include > +#endif >