From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E1D0C1F8C6 for ; Fri, 10 Sep 2021 20:40:55 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C0E7D3858431 for ; Fri, 10 Sep 2021 20:40:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0E7D3858431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1631306454; bh=NDX5RoKoBneBqRyrF/dzrcVWBqLOwehIZEohV7F2zSc=; h=In-Reply-To:References:Subject:To:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GtxMAxlzJXWzie2qZ8FOzatJGSlhzzU1M7X5W1rS5smP5h5uWwS8nOT4cwhQvzj2t S3gvVc2eHw8Z/f7+q+h5DorOLSeMMVCEwXQusbf97WjS1C0YS6TLSA9G1hr1kseqCR PJmDAfKU98yLokj/XUof5xQOmCcrKj9udV6evw5k= Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 3A42D3858D29 for ; Fri, 10 Sep 2021 20:40:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3A42D3858D29 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 18AKYT32120185; Fri, 10 Sep 2021 16:40:27 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b04utvk8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Sep 2021 16:40:27 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 18AKYXCA120296; Fri, 10 Sep 2021 16:40:27 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 3b04utvk7y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Sep 2021 16:40:27 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18AKDokc009032; Fri, 10 Sep 2021 20:40:26 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma03wdc.us.ibm.com with ESMTP id 3axcnr5mgu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Sep 2021 20:40:26 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18AKePBS46072138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Sep 2021 20:40:25 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 281F1C605D; Fri, 10 Sep 2021 20:40:25 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7716C6057; Fri, 10 Sep 2021 20:40:24 +0000 (GMT) Received: from localhost (unknown [9.160.169.186]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 10 Sep 2021 20:40:24 +0000 (GMT) Content-Type: text/plain; charset="utf-8" In-Reply-To: <20210805075053.433538-1-naohirot@fujitsu.com> References: <20210805074733.433430-1-naohirot@fujitsu.com> <20210805075053.433538-1-naohirot@fujitsu.com> Subject: Re: [PATCH v3 2/5] benchtests: Add memset zero fill benchtest To: Naohiro Tamura , Noah Goldstein , Wilco Dijkstra , libc-alpha@sourceware.org Date: Fri, 10 Sep 2021 17:40:22 -0300 Message-ID: <163130642274.404689.6991051609396665932@localhost.localdomain> User-Agent: alot/0.9.1 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Hfi2gLrkjopSsugDZJ1miuG-bMsJX7fj X-Proofpoint-ORIG-GUID: 0sgdAjrHDp7vsP8G3nDe3AeV9ex0u0aH Content-Transfer-Encoding: quoted-printable X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-09-10_08:2021-09-09, 2021-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 clxscore=1011 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109100113 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: , From: "Lucas A. M. Magalhaes via Libc-alpha" Reply-To: "Lucas A. M. Magalhaes" Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Hi Naohiro, Thanks for working on this. Please, correct me if I'm wrong but I guess you= sent an old version by mistake. This patch is lacking the bench-variant implementations mentioned on the commit message. --- Lucas A. M. Magalh=C3=A3es Quoting Naohiro Tamura (2021-08-05 04:50:53) > Memset takes 0 as the second parameter in most cases. > However, we cannot measure the zero fill performance by > bench-memset.c, bench-memset-large.c and bench-memset-walk.c > precisely. > X86_64 micro-architecture has some zero-over-zero optimization, and > AArch64 micro-architecture also has some optimization for DC ZVA > instruction. > This patch provides bench-memset-zerofill.c which is suitable to > analyze the zero fill performance by comparing among 4 patterns, > zero-over-zero, zero-over-one, one-over-zero and one-over-one, from > 256B to 64MB(RAM) through L1, L2 and L3 caches. >=20 > The following commands are examples to analyze a JSON output, > bench-memset-zerofill.out, by 'jq' and 'plot_strings.py'. >=20 > 1) compare zero-over-zero performance >=20 > $ cat bench-memset-zerofill.out | \ > jq -r ' > .functions.memset."bench-variant"=3D"zerofill-0o0" | > del(.functions.memset.results[] | select(.char1 !=3D 0 or .char2 !=3D= 0)) > ' | \ > plot_strings.py -l -p thru -v - >=20 > 2) compare zero paformance >=20 > $ cat bench-memset-zerofill.out | \ > jq -r ' > .functions.memset."bench-variant"=3D"zerofill-zero" | > del(.functions.memset.results[] | select(.char2 !=3D 0)) > ' | \ > plot_strings.py -l -p thru -v - >=20 > 3) compare nonzero paformance >=20 > $ cat bench-memset-zerofill.out | \ > jq -r ' > .functions.memset."bench-variant"=3D"zerofill-nonzero" | > del(.functions.memset.results[] | select(.char2 =3D=3D 0)) > ' | \ > plot_strings.py -l -p thru -v - > --- > benchtests/Makefile | 2 +- > benchtests/bench-memset-zerofill.c | 134 +++++++++++++++++++++++++++++ > 2 files changed, 135 insertions(+), 1 deletion(-) > create mode 100644 benchtests/bench-memset-zerofill.c >=20 > diff --git a/benchtests/Makefile b/benchtests/Makefile > index 1530939a8ce8..21b95c736190 100644 > --- a/benchtests/Makefile > +++ b/benchtests/Makefile > @@ -53,7 +53,7 @@ string-benchset :=3D memccpy memchr memcmp memcpy memme= m memmove \ > strncasecmp strncat strncmp strncpy strnlen strpbrk st= rrchr \ > strspn strstr strcpy_chk stpcpy_chk memrchr strsep str= tok \ > strcoll memcpy-large memcpy-random memmove-large memse= t-large \ > - memcpy-walk memset-walk memmove-walk > + memcpy-walk memset-walk memmove-walk memset-zerofill >=20=20 > # Build and run locale-dependent benchmarks only if we're building nativ= ely. > ifeq (no,$(cross-compiling)) > diff --git a/benchtests/bench-memset-zerofill.c b/benchtests/bench-memset= -zerofill.c > new file mode 100644 > index 000000000000..7aa7fe048574 > --- /dev/null > +++ b/benchtests/bench-memset-zerofill.c > @@ -0,0 +1,134 @@ > +/* Measure memset functions with zero fill data. > + Copyright (C) 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 > + . */ > + > +#define TEST_MAIN > +#define TEST_NAME "memset" > +#define START_SIZE 256 > +#define MIN_PAGE_SIZE (getpagesize () + 64 * 1024 * 1024) > +#define TIMEOUT (20 * 60) > +#include "bench-string.h" > + > +#include "json-lib.h" > + > +void *generic_memset (void *, int, size_t); > +typedef void *(*proto_t) (void *, int, size_t); > + > +IMPL (MEMSET, 1) > +IMPL (generic_memset, 0) > + > +static void > +__attribute__((noinline, noclone)) > +do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, > + int c1 __attribute ((unused)), int c2 __attribute ((unused)), > + size_t n) > +{ > + size_t i, iters =3D 32; > + timing_t start, stop, cur, latency =3D 0; > + > + CALL (impl, s, c2, n); // warm up > + > + for (i =3D 0; i < iters; i++) > + { > + memset (s, c1, n); // alternation > + > + TIMING_NOW (start); > + > + CALL (impl, s, c2, n); > + > + TIMING_NOW (stop); > + TIMING_DIFF (cur, start, stop); > + TIMING_ACCUM (latency, cur); > + } > + > + json_element_double (json_ctx, (double) latency / (double) iters); > +} > + > +static void > +do_test (json_ctx_t *json_ctx, size_t align, int c1, int c2, size_t len) > +{ > + align &=3D getpagesize () - 1; > + if ((align + len) * sizeof (CHAR) > page_size) > + return; > + > + json_element_object_begin (json_ctx); > + json_attr_uint (json_ctx, "length", len); > + json_attr_uint (json_ctx, "alignment", align); > + json_attr_int (json_ctx, "char1", c1); > + json_attr_int (json_ctx, "char2", c2); > + json_array_begin (json_ctx, "timings"); > + > + FOR_EACH_IMPL (impl, 0) > + { > + do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, c1, c2, len); > + alloc_bufs (); > + } > + > + json_array_end (json_ctx); > + json_element_object_end (json_ctx); > +} > + > +int > +test_main (void) > +{ > + json_ctx_t json_ctx; > + size_t i; > + int c1, c2; > + > + test_init (); > + > + json_init (&json_ctx, 0, stdout); > + > + json_document_begin (&json_ctx); > + json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); > + > + json_attr_object_begin (&json_ctx, "functions"); > + json_attr_object_begin (&json_ctx, TEST_NAME); > + json_attr_string (&json_ctx, "bench-variant", "zerofill"); > + > + json_array_begin (&json_ctx, "ifuncs"); > + FOR_EACH_IMPL (impl, 0) > + json_element_string (&json_ctx, impl->name); > + json_array_end (&json_ctx); > + > + json_array_begin (&json_ctx, "results"); > + > + for (c1 =3D 0; c1 < 2; c1++) > + for (c2 =3D 0; c2 < 2; c2++) > + for (i =3D START_SIZE; i <=3D MIN_PAGE_SIZE; i <<=3D 1) > + { > + do_test (&json_ctx, 0, c1, c2, i); > + do_test (&json_ctx, 3, c1, c2, i); > + } > + > + json_array_end (&json_ctx); > + json_attr_object_end (&json_ctx); > + json_attr_object_end (&json_ctx); > + json_document_end (&json_ctx); > + > + return ret; > +} > + > +#include > + > +#define libc_hidden_builtin_def(X) > +#define libc_hidden_def(X) > +#define libc_hidden_weak(X) > +#define weak_alias(X,Y) > +#undef MEMSET > +#define MEMSET generic_memset > +#include > --=20 > 2.17.1 >