From patchwork Wed May 20 18:14:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1294532 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Yg3IKlBf; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 ozlabs.org (Postfix) with ESMTPS id 49S1B13tdTz9sT9 for ; Thu, 21 May 2020 04:14:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93A2F395A049; Wed, 20 May 2020 18:14:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93A2F395A049 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589998487; bh=rePapKeEGnVStIUuaxO+0dLiLgpPPn40uPuL9AyzHYE=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Yg3IKlBfjv/r1r08eBpH+FmKUbJsnmm8xgGHz+W+YPi5zZijNVfIhl9vh7YuLwu4u xKeZisvZHGAmmGJK45HqeGkmxAynqh54sq3Jfh0NWY01aNKUsHfrqX8FNndGx641U4 wbCbtmovJrRG42TKHafqgMyQ+heAvdwwLO3y39Xk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by sourceware.org (Postfix) with ESMTPS id E5E3D385DC32 for ; Wed, 20 May 2020 18:14:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E5E3D385DC32 Received: by mail-io1-xd29.google.com with SMTP id f3so4280117ioj.1 for ; Wed, 20 May 2020 11:14:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rePapKeEGnVStIUuaxO+0dLiLgpPPn40uPuL9AyzHYE=; b=b+bNw6JnmNLyhgihdP6Ks4qM966SuqcDaQebXMHZwXNt6VOtxH/z4074CZv0Ho7DJI vEMsSoqHukmaj8ggrTczX4jHVwHATFvRxdTMBGHpMNQOcHknKgRV91r6+CZ5eB1oIxVO zz6ISWiseQGCqSgRwE3JbsZXg/GElSFmGwWNfUk2zTGSakXFlPg/YpVwM/akKmM3gev6 ZA3ue6HQtqOhupbpboBlqa5n/2jb0bZQg4ETSwTv6b8i5V5+cZ6fTwY0tIEQecqZKXSG qoeQNC6NHLmmR1/y5wwlH/BDDrpn5cy8FS6AkuL4voQ02g4O4t5l8yXF/KNyj1kBxTRa rkeA== X-Gm-Message-State: AOAM533iFHjHF0Pf7ERrZxfTQwQEeriJMsLFmo7IU4DZrqT5cayuMc79 2p8dtDcHzbHb+mgFpdfWof3Pd2XvbfLLaBNqyOU= X-Google-Smtp-Source: ABdhPJwbfxypZhtnzuN/jUGIY4XKKpYDhKWbDKFJifHqUctGtCFgHp3dXy04+S+TyYwPlKbrQ9fp+WATxnwWo5ZcNpY= X-Received: by 2002:a02:394d:: with SMTP id w13mr329859jae.58.1589998484238; Wed, 20 May 2020 11:14:44 -0700 (PDT) MIME-Version: 1.0 References: <20200519203053.9854-1-hjl.tools@gmail.com> <87zha28ots.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87zha28ots.fsf@oldenburg2.str.redhat.com> Date: Wed, 20 May 2020 11:14:08 -0700 Message-ID: Subject: V2 [PATCH] benchtests: Restore the clock_gettime option To: Florian Weimer X-Spam-Status: No, score=-9.5 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" Cc: Alexander Monakov via Libc-alpha Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On Wed, May 20, 2020 at 11:05 AM Florian Weimer wrote: > > * Alexander Monakov via Libc-alpha: > > > I am well aware. Again: rdtsc does not count CPU cycles on recent > > Intel CPUs. > > H.J. probably has a different view on what those “recent Intel CPUs” > are. 8-) I have not reviewed the mechanics of the patch, but if we need > this for some CPUs, we should make the change. > Here the patch with updated commit message: commit 7621e38bf3c58b2d0359545f1f2898017fd89d05 Author: Wilco Dijkstra Date: Tue Jan 29 17:43:45 2019 +0000 Add generic hp-timing support removed the clock_gettime option. Restore the clock_gettime option for some x86 CPUs on which value from RDTSC may not be incremented at a fixed rate. OK for master? Thanks. Reviewed-by: Carlos O'Donell From 7e48f7adbd53c18df7ab5fdd488bfcc134627480 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 18 May 2020 17:28:42 -0700 Subject: [PATCH] benchtests: Restore the clock_gettime option commit 7621e38bf3c58b2d0359545f1f2898017fd89d05 Author: Wilco Dijkstra Date: Tue Jan 29 17:43:45 2019 +0000 Add generic hp-timing support removed the clock_gettime option. Restore the clock_gettime option for some x86 CPUs on which value from RDTSC may not be incremented at a fixed rate. --- 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 -- 2.26.2