From patchwork Wed Mar 8 10:57:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 66123 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5501D385021F for ; Wed, 8 Mar 2023 10:58:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5501D385021F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678273093; bh=2kItQnZmHOjpilRRo5Q4eGCuVZW79RvTVFN1IA/f0Sg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ssHOi/2dXCjzEETpMEY05GGQBh77+pKLA8z3AYPHlwn13N4zqo27scI5nYzRQc68a Yxnap8J9CBTzqtAsy5BPcyyDzNxKulN0wMM0yfPuDfn9P9KVV2wkWWHilzkjTTsKrI CMHV9d9ojqFK+fnLWI8zQ6/CBj8N0MO3GAr+7RzY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2089.outbound.protection.outlook.com [40.107.7.89]) by sourceware.org (Postfix) with ESMTPS id D8F8A3858C30 for ; Wed, 8 Mar 2023 10:57:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D8F8A3858C30 Received: from FR3P281CA0025.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::23) by AS8PR08MB8634.eurprd08.prod.outlook.com (2603:10a6:20b:564::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 10:57:46 +0000 Received: from VI1EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:1c:cafe::8b) by FR3P281CA0025.outlook.office365.com (2603:10a6:d10:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17 via Frontend Transport; Wed, 8 Mar 2023 10:57:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VI1EUR03FT061.mail.protection.outlook.com (100.127.144.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.31 via Frontend Transport; Wed, 8 Mar 2023 10:57:45 +0000 Received: ("Tessian outbound b29c0599cbc9:v135"); Wed, 08 Mar 2023 10:57:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fcee49828ee75282 X-CR-MTA-TID: 64aa7808 Received: from 700fcd9c594d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 99FAE580-0024-41F9-89BB-944239883B2F.1; Wed, 08 Mar 2023 10:57:38 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 700fcd9c594d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Mar 2023 10:57:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eRkf0uzCWwGiKYgEF0wG2JJjJwTd/OiC85LGLtssyLynj3KjgEypGZ57DdZe6rGvI9RHPEIZJtQOT4aOyTi5JMUlx5R+zLZnwGRal+3w+8/BZdHVAH85AdNZUrLNTieHcgOlJay6YVGGcIlgWoC6PH949qImzDbY8n0D/1EwAz9D3ScDv9+t1yAwAb6gYljuTcD00aP84ox+vIeBOVyLG3nhYwZOcMtfrEXTOFR3jgTmkc+gVaqeBFHfs7RPhKUoZhckRupbiK/pvJrxt3OrxwM+SmRTts3OBw33wtw8ddq43XEW76hlyvzUQltAYs4JWHRXHjAdhTO8dW5lnhM2cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2kItQnZmHOjpilRRo5Q4eGCuVZW79RvTVFN1IA/f0Sg=; b=iJ0MliV5DidjhLC23MAZZ89vA9wcKEO2jC4Ge89EZDy3PoCXIWtJz9zbQAKKG+8ucDdHRXQBo6NCoVhyasgUNk2oME1fvwEGSIwDpvLGhWDY/CfaI2F63888vAgHvT5CdpwXCiGdb8n+xbna+DjoFfB/AbEB8KYEWFugkEG40zxq8lNcitL6t+EAdqLaPdjE7uD2A0cVFH/5N8AanZYhxT0NGtaJTBThjIyUTZ+GUam2AeDmZZk5R175VaRtPtIDJUYH0UEJSEMT+L+azZYYw1UBjMQz1VzO/tIqz0TixmS61cP5mjjZKFiFE94Uai72w7Fktl1UsUWmarRyu0S18g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from PAWPR08MB8982.eurprd08.prod.outlook.com (2603:10a6:102:33f::20) by PAXPR08MB6606.eurprd08.prod.outlook.com (2603:10a6:102:157::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 10:57:30 +0000 Received: from PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::dc17:8fa2:cce5:3573]) by PAWPR08MB8982.eurprd08.prod.outlook.com ([fe80::dc17:8fa2:cce5:3573%7]) with mapi id 15.20.6156.025; Wed, 8 Mar 2023 10:57:30 +0000 To: 'GNU C Library' Subject: [PATCH] Benchtests: Remove simple_str(r)chr Thread-Topic: [PATCH] Benchtests: Remove simple_str(r)chr Thread-Index: AQHZUaykru6CBahYvUSWEbRnVlkRcg== Date: Wed, 8 Mar 2023 10:57:30 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAWPR08MB8982:EE_|PAXPR08MB6606:EE_|VI1EUR03FT061:EE_|AS8PR08MB8634:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fd2fe49-5905-420c-2dc8-08db1fc3f2f2 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: bMjfr57tsj+EWr0Abt5qfZ4A03fYpBWh9j+o/vuX0VlmSqwAIEoYQPn+nMiC18Xpcv8rsbJxdI0xgfcrGsfBY21dX6kbscx3/6eMPUCrsMuRXV3Apdwqrbj50vbwKz5bx5B9aveprJYGyD9nz2JMpP2XZ+w8YTMvdm9HM37mo94UvP4VtdKleVnPIwI93nbr2mjm4A2J2Mc7mp6TVITD5J4Y48imNbXlR4PY/z2g9y6C3QVpU581hla0id8rkTuRbnLKGBUvZyWlGomkz4SoG3L/HvI+KjyJRkDpifEHqS+2BwsHJuK+cI1rkNlPCwXxCV/hQkCRjeJRefRPx9SSpA4TnN2Lgj9fTAc1ZUhzHKj72D+qxuwWEIXrwJOcFWXBc+bYFe7Fq+3TMIHIBNzWa7dgVzxQ3Ug51fmOwZmX0k0FVXtmTezC5KAMcKZG1k0gxpDIwxBN91wpl2JBqNmg6C+wviYseyRgw5wh67rRBt/fOpo7OrZFEAhpHJpQXTHAq2u9xcGHXoytl+iwf7CFUjFD53hvbbIFM3qj054e8DrIwv48RADlXP8+11wTXupTi/gnvwCKjbaePNOvsJyQBBSQQ3l2KLSHuKuKs1nYFGF0y05I4h/MrBDiHQNaudwqLnfc+qazgqYEaVcMFA6C/Nc2n+vd893jdNOna1IB0BwfWDBiXQDlrqj/ZE5pktBQbpdtw6S4q1dg/7PzgYxE9A== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8982.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(346002)(39860400002)(396003)(376002)(136003)(366004)(451199018)(76116006)(86362001)(41300700001)(64756008)(8676002)(66556008)(66476007)(66446008)(66946007)(6916009)(91956017)(55016003)(71200400001)(7696005)(33656002)(316002)(2906002)(186003)(478600001)(122000001)(38100700002)(38070700005)(6506007)(52536014)(9686003)(26005)(8936002)(5660300002); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6606 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VI1EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8178ae28-3851-4c92-2924-08db1fc3e9d2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WFIZBBh6Lpxw8K4Q6ZYr/IePHyRKbTH0lcGAGo8v7kb/oO7ozMsBuRe2nag7HVyUVd4XeHGR2jdyj0UjiN+iwyeqQR4ozUsejtVlsD9/s4dkWU95Df23wTE5OwAel+cl0Z3cWnk1ncLhs+M1FNhsAbxT8jTiiFDV9W7XlaDPeFl+NqbYkaGwXXeD0ImZITrb8be3+w6k8ufp7qQ0qcUUVt7kz8JKAv/eDfhrJxFcmIXi6XFy7NiIGAeFbPGPz41Nfpbbdj3kkJNkLRv7QngEm1ShmZkttPOCH9Mqdfh7FbHsJw82ZlAUHiXwkMDesE69HC8xK0TfDHf8hyik33oDTgS0D2Ev3n5ew/g4Wa87B59IGyRADYjvi6YcjBSmXyci4LxbBUx6PmToXC3mLQfV2YihEg1ysPBcU+P/Ntrm2rijNiOSh1Ac8EaaqV3Gu2kd3FJtkheIpe0mpQcNoB3mpFKhMoyrWIS56rrpwj0Y147PuIog3av9N0fLdYSCfTuulMJlBQyQ0bN0/6kIg5supmbi2iuiWVZOBw6oEC5PAcGcHaijquDU7gk9bynxghixq/0whOxn8n9cvV5+kPz3G/ZamwFwyB6yzr7T1YwLdL3tnKbG+hpAd35LPbfjDnIpSp3r1y3cR5iJ01SoZSixAYDEDfDNH97NFSwhOznQs4HIpjsN74aboZ4IS5plbPZgniwVjf/L0j5cAF1O5e1cmg== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230025)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199018)(40470700004)(46966006)(36840700001)(36860700001)(81166007)(82740400003)(47076005)(26005)(336012)(40460700003)(6506007)(9686003)(41300700001)(186003)(33656002)(52536014)(40480700001)(70206006)(8676002)(6916009)(2906002)(70586007)(8936002)(5660300002)(7696005)(356005)(316002)(55016003)(478600001)(86362001)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 10:57:45.6380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2fd2fe49-5905-420c-2dc8-08db1fc3f2f2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VI1EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8634 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Instead of benchmarking slow byte oriented loops, include the optimized generic strchr and strrchr implementation. Adjust iteration count to reduce benchmark time. 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