From patchwork Fri Jan 25 16:20:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1031178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99561-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="nP6GMhsC"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="pCWdnklZ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43mPQ841shz9s4s for ; Sat, 26 Jan 2019 03:20:32 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=oJt7PUmGgyIr//juQogSgJwobs9lSft0h08WhMJgzQl7P3adp4cds /EDumpyYhHDHYRa5yHGNB0rmrvES7EjN2eJzaH9H8Lr41IMjXo85iZpoqrKP2GiF SGE2bZoXbv3ioMC557lMPe18SGcfwtkABGZW8QOiedif0/C6k2gN/A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :content-type:content-transfer-encoding:mime-version; s=default; bh=w2h5iooB81jWCJT4ryFxL4onfMc=; b=nP6GMhsCU44KCbzB6cR8JKUlkWzF u/B+gCgjkk6kBbnJjrrtY1eMVf3jXpQQ5GVU18ohB9hM6Lw5wrecdq0iy5UsDI30 uldbLOEx4yjPA12P4Zos71TF1x701WvL/BbFUoEc+pecaKlLpJJwW9mTs9p6TsDd mDDye1OmdZDbi+4= Received: (qmail 54543 invoked by alias); 25 Jan 2019 16:20:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 53448 invoked by uid 89); 25 Jan 2019 16:20:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=sparcv9 X-HELO: EUR04-DB3-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L3KABdoTmFh35wxMR2WrIIrsudjAz1/GSYRD1wKElh8=; b=pCWdnklZnLHqame5ZtZrFd4bDQi4isHbQeQDbIh5D3Y4YkV4lShLWK+tLZQPyabENubwx+BkPzFOVIMCDxRGdVqJsJ/N9Y89yq6YAR/cndzsb9ooH4JIlqzllWLyaQzjOvoFr156Q11Oo/PXG8TmnoUpKkJvvxJE2qk/JmjKP98= From: Wilco Dijkstra To: 'GNU C Library' CC: nd Subject: [PATCHv2 3/4] Add generic hp-timing support Date: Fri, 25 Jan 2019 16:20:20 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 v2: use stdint.h rather than inttypes.h Add missing generic hp_timing support. Remove unused HP_TIMING_AVAIL and HP_SMALL_TIMING_AVAIL. Use the VDSO clock_gettime (CLOCK_MONOTONIC, ) on targets which don't use an inlined instruction returning time/cycles. ChangeLog: 2019-01-25 Wilco Dijkstra * sysdeps/alpha/hp-timing.h (HP_TIMING_AVAIL): Remove define. (HP_SMALL_TIMING_AVAIL) Remove. * sysdeps/generic/hp-timing.h (HP_TIMING_NONAVAIL): Remove. (HP_TIMING_NOW): Add generic implementation. * sysdeps/generic/hp-timing-common.h (HP_TIMING_AVAIL): Remove. * sysdeps/ia64/hp-timing.h (HP_TIMING_AVAIL): Remove define. (HP_SMALL_TIMING_AVAIL) Remove. * sysdeps/powerpc/powerpc32/power4/hp-timing.h: Likewise. * sysdeps/powerpc/powerpc64/hp-timing.h: Likewise. * sysdeps/sparc/sparc32/sparcv9/hp-timing.h: Likewise. * sysdeps/sparc/sparc64/hp-timing.h: Likewise. * sysdeps/x86/hp-timing.h: Likewise. diff --git a/sysdeps/alpha/hp-timing.h b/sysdeps/alpha/hp-timing.h index 481132663ce0268de1b3384a7a01084e70d9af66..65db6031ee19dbd86ae42806faa66d00bf09ab12 100644 --- a/sysdeps/alpha/hp-timing.h +++ b/sysdeps/alpha/hp-timing.h @@ -21,12 +21,8 @@ #define _HP_TIMING_H 1 /* We always have the timestamp register, but it's got only a 4 second - range. Use it for ld.so profiling only. */ -#define HP_TIMING_AVAIL (0) -#define HP_SMALL_TIMING_AVAIL (1) - -/* We indeed have inlined functions. */ -#define HP_TIMING_INLINE (1) + range. Only use it for benchmarking. */ +#define HP_TIMING_INLINE (0) /* We use 32 bit values for the times. */ typedef unsigned int hp_timing_t; diff --git a/sysdeps/generic/hp-timing-common.h b/sysdeps/generic/hp-timing-common.h index 0ffb8534442165bdb93628bf973cb758bb8546f6..f7a0147a4f2788ae9c7a14b248fd580e7cc04b07 100644 --- a/sysdeps/generic/hp-timing-common.h +++ b/sysdeps/generic/hp-timing-common.h @@ -20,8 +20,6 @@ /* In case a platform supports timers in the hardware the following macros and types must be defined: - - HP_TIMING_AVAIL: test for availability. - - HP_TIMING_INLINE: this macro is non-zero if the functionality is not implemented using function calls but instead uses some inlined code which might simply consist of a few assembler instructions. We have to diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h index fb2a6036fc9a208b7d5524c45927c273c96746a8..aad768dc849ff4b81844c4a7514e15f144ffa2f3 100644 --- a/sysdeps/generic/hp-timing.h +++ b/sysdeps/generic/hp-timing.h @@ -20,21 +20,19 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -/* There are no generic definitions for the times. We could write something - using the `gettimeofday' system call where available but the overhead of - the system call might be too high. */ +#include +#include +#include -/* Provide dummy definitions. */ -#define HP_TIMING_AVAIL (0) -#define HP_SMALL_TIMING_AVAIL (0) #define HP_TIMING_INLINE (0) -typedef int hp_timing_t; -#define HP_TIMING_NOW(var) -#define HP_TIMING_DIFF(Diff, Start, End) -#define HP_TIMING_ACCUM_NT(Sum, Diff) -#define HP_TIMING_PRINT(Buf, Len, Val) - -/* Since this implementation is not available we tell the user about it. */ -#define HP_TIMING_NONAVAIL 1 + +typedef uint64_t hp_timing_t; + +#define HP_TIMING_NOW(var) \ +({ \ + struct timespec tv; \ + __clock_gettime (CLOCK_MONOTONIC, &tv); \ + (var) = (tv.tv_nsec + (uint64_t) 1000000000 * tv.tv_sec); \ +}) #endif /* hp-timing.h */ diff --git a/sysdeps/ia64/hp-timing.h b/sysdeps/ia64/hp-timing.h index 17ef023a11564de9afd4eb9bfb706539d4400163..2ca248a530ab239c4789a00fb0e46d6ca43861ef 100644 --- a/sysdeps/ia64/hp-timing.h +++ b/sysdeps/ia64/hp-timing.h @@ -20,10 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -/* We always assume having the timestamp register. */ -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) - /* We indeed have inlined functions. */ #define HP_TIMING_INLINE (1) diff --git a/sysdeps/powerpc/powerpc32/power4/hp-timing.h b/sysdeps/powerpc/powerpc32/power4/hp-timing.h index 0d77aa0992afd2487abb5bdf894585d81a4c02ee..ed2ca9bc7a0506945fcea65b9ebf699dba0f6ea0 100644 --- a/sysdeps/powerpc/powerpc32/power4/hp-timing.h +++ b/sysdeps/powerpc/powerpc32/power4/hp-timing.h @@ -20,10 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -/* We always assume having the timestamp register. */ -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) - /* We indeed have inlined functions. */ #define HP_TIMING_INLINE (1) diff --git a/sysdeps/powerpc/powerpc64/hp-timing.h b/sysdeps/powerpc/powerpc64/hp-timing.h index fb9ac1ce2a5e70f4c185380ca8df43cabcc6fd48..01678cd63432a8edd19f274122add87fc7e8a7e8 100644 --- a/sysdeps/powerpc/powerpc64/hp-timing.h +++ b/sysdeps/powerpc/powerpc64/hp-timing.h @@ -20,10 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -/* We always assume having the timestamp register. */ -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) - /* We indeed have inlined functions. */ #define HP_TIMING_INLINE (1) diff --git a/sysdeps/sparc/sparc32/sparcv9/hp-timing.h b/sysdeps/sparc/sparc32/sparcv9/hp-timing.h index 6a4ab08679330b019fc419ec64d4f4bd0079f609..3270c5b40a17c4af5e4c3d9c1f5b028a9a7a8a62 100644 --- a/sysdeps/sparc/sparc32/sparcv9/hp-timing.h +++ b/sysdeps/sparc/sparc32/sparcv9/hp-timing.h @@ -20,8 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) #define HP_TIMING_INLINE (1) typedef unsigned long long int hp_timing_t; diff --git a/sysdeps/sparc/sparc64/hp-timing.h b/sysdeps/sparc/sparc64/hp-timing.h index db95c02a8d91eea8db4a00d542c331e30f9f38e9..0f02b2a98f267d0e90e5297d5855753bc58c907c 100644 --- a/sysdeps/sparc/sparc64/hp-timing.h +++ b/sysdeps/sparc/sparc64/hp-timing.h @@ -20,8 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) #define HP_TIMING_INLINE (1) typedef unsigned long int hp_timing_t; diff --git a/sysdeps/x86/hp-timing.h b/sysdeps/x86/hp-timing.h index 9b6a998bcdd594d6260f0be9a8a783edbc8d333b..57b4c293cd65485669d359127e580d2ffacd3644 100644 --- a/sysdeps/x86/hp-timing.h +++ b/sysdeps/x86/hp-timing.h @@ -22,9 +22,6 @@ #include #if MINIMUM_ISA == 686 || MINIMUM_ISA == 8664 -/* We always assume having the timestamp register. */ -# define HP_TIMING_AVAIL (1) -# define HP_SMALL_TIMING_AVAIL (1) /* We indeed have inlined functions. */ # define HP_TIMING_INLINE (1)