From patchwork Tue May 19 20:30:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 39339 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 4AC03389500B; Tue, 19 May 2020 20:30:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4AC03389500B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589920259; bh=ltSAe6aca2JtRF5MlVqZgUb9UYKqky9vo9NY5e7jt1c=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gPjMrt72y11+D55TEk/ag1f4hIXT2wDs9sie+dwBpHImlkVzt4PndDsu0F0ncP3Tp MeZYT+wguMEolspm4dXv0MhnIqmxMgfVv3+rv7msWXyrLdbYe+wM+IEJhM03oFr9El 92qh//5i7Gyc+/Io5m7BRBrzHsmbPIgVq22UBDf8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 14CD0389500B for ; Tue, 19 May 2020 20:30:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 14CD0389500B Received: by mail-pl1-x62c.google.com with SMTP id f15so365579plr.3 for ; Tue, 19 May 2020 13:30:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ltSAe6aca2JtRF5MlVqZgUb9UYKqky9vo9NY5e7jt1c=; b=BDcmomkY+3qMlFdULxG8nF2o02pH0fI7cY3SlkMoCDQBoccl/nfmFl7CCtLPEcxvu8 NGuWhluH8lEjLIHT6oTatY3+Wp+9yFrq0Vlwz/jOk32AUVyCsYCrPIA27hGFbSp91jwF CjJQmtwce7wc/F4F6Pykw23hswf+7Q0uuqbOhbVApLGrIlU1qXfVF0vCXeah1+S/L6YX i/dI9hErt3iGw16LwZjELOGhCdfn/S4/yBsIZuy/q9gH7inPSrFXA59c/92vFYUFRW5V QEiYNz6zQWf1bM1X5IaiSecUcHaf0o1gCUjZsgE6osyqeRCC/fi8GwNUoXZxwSWyo4Gd PZ6A== X-Gm-Message-State: AOAM530cgJN0RCuLVZMXdrd5B4DcJlILErrH7VxWPLfMr23o1PSt5OKM 1b2tN1ZtFYhzMfFxv4n4yrBy+nBb X-Google-Smtp-Source: ABdhPJw8nBI7cu/FkQCkuHFVva2vPk/iZT9isV/7cfR1G2+vnJhScifNiHy63i/AQAJkB0ngh7P3RQ== X-Received: by 2002:a17:90a:aa8d:: with SMTP id l13mr1480979pjq.92.1589920254859; Tue, 19 May 2020 13:30:54 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id s36sm271279pgl.35.2020.05.19.13.30.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 13:30:54 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 89EF21A00D0 for ; Tue, 19 May 2020 13:30:53 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] benchtests: Restore the clock_gettime option Date: Tue, 19 May 2020 13:30:53 -0700 Message-Id: <20200519203053.9854-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Status: No, score=-15.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" commit 7621e38bf3c58b2d0359545f1f2898017fd89d05 Author: Wilco Dijkstra Date: Tue Jan 29 17:43:45 2019 +0000 Add generic hp-timing support removed the clock_gettime option. On x86, fewer cycles doesn't necessarily mean faster exection due to frequency drop. We should restore the clock_gettime option. --- benchtests/Makefile | 6 ++++++ benchtests/README | 7 ++++++- benchtests/bench-timing.h | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/benchtests/Makefile b/benchtests/Makefile index 335d643ecb..99e90d17a0 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -132,11 +132,17 @@ endif CPPFLAGS-nonlib += -DDURATION=$(BENCH_DURATION) -D_ISOMAC +# Use clock_gettime to measure performance of functions. The default is +# to use the architecture-specific high precision timing instructions. +ifdef USE_CLOCK_GETTIME +CPPFLAGS-nonlib += -DUSE_CLOCK_GETTIME +else # On x86 processors, use RDTSCP, instead of RDTSC, to measure performance # of functions. All x86 processors since 2010 support RDTSCP instruction. ifdef USE_RDTSCP CPPFLAGS-nonlib += -DUSE_RDTSCP endif +endif DETAILED_OPT := diff --git a/benchtests/README b/benchtests/README index c4f03fd872..f440f3295a 100644 --- a/benchtests/README +++ b/benchtests/README @@ -27,7 +27,12 @@ BENCH_DURATION. The benchmark suite does function call measurements using architecture-specific high precision timing instructions whenever available. When such support is -not available, it uses clock_gettime (CLOCK_MONOTONIC). +not available, it uses clock_gettime (CLOCK_MONOTONIC). One can force the +benchmark to use clock_gettime by invoking make as follows: + + $ make USE_CLOCK_GETTIME=1 bench + +Again, one must run `make bench-clean' before changing the measurement method. On x86 processors, RDTSCP instruction provides more precise timing data than RDTSC instruction. All x86 processors since 2010 support RDTSCP diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h index 5b9a8384bb..844a7727c9 100644 --- a/benchtests/bench-timing.h +++ b/benchtests/bench-timing.h @@ -19,7 +19,11 @@ #undef attribute_hidden #define attribute_hidden #define __clock_gettime clock_gettime -#include +#ifdef USE_CLOCK_GETTIME +# include +#else +# include +#endif #include #define GL(x) _##x