From patchwork Thu Aug 3 13:38:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Malcomson X-Patchwork-Id: 130609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp1155103vqx; Thu, 3 Aug 2023 06:39:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlFCSnU04Xe2e2qjcGFz+Q29vBDt+Ls4O/REiVQuU+NUWGo1Ce6LoOWLHfQzsE7i5Q895f2f X-Received: by 2002:a2e:8503:0:b0:2b9:dfd0:c3ce with SMTP id j3-20020a2e8503000000b002b9dfd0c3cemr6958021lji.46.1691069984333; Thu, 03 Aug 2023 06:39:44 -0700 (PDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f5-20020a1709064dc500b00993150e5327si7113083ejw.341.2023.08.03.06.39.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 06:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DnctRc91; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E6093858035 for ; Thu, 3 Aug 2023 13:39:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E6093858035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691069983; bh=saLcOqzihr7q2u+x5LR7GvLu1FCDXP6PtNd/xLrNtkA=; h=To:CC:References:In-Reply-To:Subject:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=DnctRc91uTows+GgMva24WkUFYdWsNZnXQKVtl8UVoBWc0KRWuu1SlTS8JfW2QSDZ ILwc6+OUlX0yP944xTZiI2pdTmCBJStso6dOfLesDaUaDXH5dE5Kkmf1TBHnK1hUcs V6ICRGCxf1ZsvoECba+vXrP1857BBuMDTr54r02M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2057.outbound.protection.outlook.com [40.107.247.57]) by sourceware.org (Postfix) with ESMTPS id 1DAC53858D1E for ; Thu, 3 Aug 2023 13:38:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1DAC53858D1E Received: from DB9PR01CA0027.eurprd01.prod.exchangelabs.com (2603:10a6:10:1d8::32) by PAXPR08MB6367.eurprd08.prod.outlook.com (2603:10a6:102:15b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Thu, 3 Aug 2023 13:38:45 +0000 Received: from DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d8:cafe::b7) by DB9PR01CA0027.outlook.office365.com (2603:10a6:10:1d8::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.20 via Frontend Transport; Thu, 3 Aug 2023 13:38: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 DBAEUR03FT045.mail.protection.outlook.com (100.127.142.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47 via Frontend Transport; Thu, 3 Aug 2023 13:38:45 +0000 Received: ("Tessian outbound e1fdbe8a48d3:v145"); Thu, 03 Aug 2023 13:38:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 56a532edaacd661b X-CR-MTA-TID: 64aa7808 Received: from 209f40d9bb93.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2CF23E32-E022-4DB0-AB13-225C94014EEC.1; Thu, 03 Aug 2023 13:38:38 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 209f40d9bb93.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Aug 2023 13:38:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GLxj3DkN8oJDXbGvc6NNuUgMK1SZ4U0iXJPTJqrG47e/hADaYrYfBeA5nwLOntVkPWauo9hwSgDVNr7MWIchi1UDPPxGQPI229ncHITZEwmxJPNBilMCloYBJjEvCCruZ5ec6LL4bNo2y6gXHecjY1+OaBf/NrF3NJIoNf5JkgHfkmyAYjVZCawljg/eV0nnqAmi2QHEUStg/rxcDsrY39tJM/xFdNxkp6iFkx8hvEF+AQWWYX4Dgl+V+5S8XWtoZO2p/WeIrnmYqH4Fqj5uDe8SgRtF3rKKz9vbZC1ExDk2zVul7MUoq8gAHBHpRNArZyTr+DWKGYpwwNt3Uy25VQ== 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=saLcOqzihr7q2u+x5LR7GvLu1FCDXP6PtNd/xLrNtkA=; b=W+ga02/VoNHaZxfL027H3x05Thf82xPGgEMd5J2kdYcBtGCZCBED8FY/Q4q2H4sCjOaMN30jpIJQjbsW4ZV5yT/PLZmIWtdyasd4xoOErNUsvXoUR0TZu54Iy9JVlqNH6tZxl/FlXYJhyphQcJLb5iwmA2FJTG6u4SmW19el47SbmuZoqTVSRgp3JuY0asvDmsOW7D/cslB7tNpvrfPfuf0Qc/q3AwAUMpSs+P5nqXLHg9dVjHUZcDKMWNjFVBUNrm4AxOmHEcpb4QcR7coQYMzBnb/TkT2dNuX6x5C0Of9U6gEmbszIIyFwRWxwu9PmCOpLlNBRgmIVUyllOQ34oA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=suse.de smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from AS9PR05CA0049.eurprd05.prod.outlook.com (2603:10a6:20b:489::9) by GV2PR08MB8702.eurprd08.prod.outlook.com (2603:10a6:150:b6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Thu, 3 Aug 2023 13:38:34 +0000 Received: from AM7EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::41) by AS9PR05CA0049.outlook.office365.com (2603:10a6:20b:489::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.19 via Frontend Transport; Thu, 3 Aug 2023 13:38:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT019.mail.protection.outlook.com (100.127.140.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6631.47 via Frontend Transport; Thu, 3 Aug 2023 13:38:34 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 3 Aug 2023 13:38:33 +0000 Received: from e124762.cambridge.arm.com (10.57.32.40) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Thu, 3 Aug 2023 13:38:33 +0000 MIME-Version: 1.0 To: Richard Biener CC: , , Xi Ruoyao , Andrew Pinski References: In-Reply-To: Subject: [PATCH] mid-end: Use integral time intervals in timevar.cc Date: Thu, 3 Aug 2023 14:38:32 +0100 Message-ID: X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT019:EE_|GV2PR08MB8702:EE_|DBAEUR03FT045:EE_|PAXPR08MB6367:EE_ X-MS-Office365-Filtering-Correlation-Id: d7a1d40b-c762-445f-6611-08db9426f594 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: KxPTTJBHI/4bm8Nv4SxupYfkOdFbdED+CRwkeq/rTs6WJOCja/sPgj2FPKYjew7hy9hVpCa8JzgbeWWPa9sRh7NpAq0+ea6NiArLm1D1ne14pOe/34sSwpf7ZwdicaDrlqiRwLDr1Z6R2Ue89mpEey+1w7pRu3UlVlXZ9TiSmilvsLzhKNZZe2bQs2tMkxsNrpLnEEtq49NpXkcLatnIYcNyzP60s6OJBWZcyL4/kT1eeRjkm2OBiV6z7z8SuAlJHJaOhnvxvcdQGHd89nhldhZ3YP7U4hJOxkQQAd4FJ9QHhDcByYrAf9Bqf4rbGopHNOPK+fGbf+qEz+gJ9oWWqo5lg/ONdiir7IxnzgLn5KIVOjGU+AE34J5y2l8gQjj3el+wNqpnYOv8poMUb3nC5/cnFA/7qiSZC7noDepY+Kil916QqdOmcwAsr7/pe9CKvjpOtcuBsRGmOn/KVJfOiBwqGTnxLtVBSlrWrd1frxotw0hELuSQw+O3gGoQ+4av+t0tqQIRbr+/lGQrEvpwHtvC0O0FsknrbC5OA3yY/q9WncXjJVzoofEYvgc2cMhLFZPYOsf1OMT7G8R0tjTBpYeskh0j7bsnT8FKSGNues1+Ig6DoTYGy7Anr6vRtC/MjLCTFAJ/t1fdWhfqNSkcZzMcPbXenrf76EYwNCdl0BXWh5np9stGHBLFY+DJkAQwIQ79tlTQ/F+mzV0hzM1HhgRIlxGn2Mh2KNY9ZOigKDRnienA8jsp8sUrols0JJlS X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(396003)(346002)(39860400002)(451199021)(82310400008)(36840700001)(46966006)(41300700001)(8936002)(8676002)(36860700001)(83380400001)(47076005)(336012)(186003)(26005)(86362001)(31696002)(426003)(81166007)(356005)(82740400003)(316002)(40480700001)(54906003)(478600001)(33964004)(6916009)(4326008)(70586007)(70206006)(30864003)(31686004)(2906002)(235185007)(66899021)(5660300002)(44832011)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8702 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 3acb6d8e-e491-463e-af91-08db9426eef7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OsleAk6IMaOJdan0a5iX8Zk6Fx05sqDzGB+c7SvmMybqVma16T1QNSXeFoSHSz+f14AloXl9BS9FuwHuGlgN2hb1db9RdZstkaA6D+srlWMX0cRX2WgUqDl+MHrt2qHqKp/BUo++id3XBjnoSgBXi+hRM+O6EbC6dMtbe+bHCTN67OzrQvqkZDiedumg6en9iXukb4Ezhs3umWdvsmbsYycTL4K+7W4gsQ/VFtITXlVplJdO1DY7hPWVHfbeZlvHp6EE/ZvShkPobWF3h0J0wY97/c2EnGyPMsZAEEn2jaw93EAs0LAgDmDH28f+7uKZa5US+AG/QLe/+3VwjHIoXHKkYiNUCikpos4PKfPcXFQM+bfBEB0QjprsyyVyykJSOutmp9LCX87+J4+nKvNy9z/1NERssbQ3hs7bIQ3wXq4s+d/wsTX0mRgGB5U5Je4yqLrmP/iEAefZZ+5pQY4C+EFjWBug+IG4+opRqw2c/gfB/DlcR70qjG4744MnrBBWnuzbUQHH99IIxVg+FtHEVvfalnJLKVT5iTwhxlW0Ie4K6KS/ZgTsuvwDwmhymjmfYoPqoMC5yJCsMtMwdXwGQ8v67Qs4bsBr4VLmcX0VioaHYq8pyPn6MIh2r8kfE9zLgbxe42VMxjpLvOWZVcLauRfuALiXAf+pUEO4daSeaHW/tc9Ep6wTpkbDc5bGZMv391AtEGZ+w8fWf3Jl2b+zOUhNjLocPsbAD+SbYevYt/0d4WwmJFpWz4hHsSTMRnNz 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:(13230028)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199021)(82310400008)(40470700004)(36840700001)(46966006)(30864003)(41300700001)(40460700003)(316002)(2906002)(4326008)(70206006)(70586007)(44832011)(6862004)(235185007)(8936002)(8676002)(5660300002)(81166007)(82740400003)(26005)(186003)(86362001)(83380400001)(426003)(336012)(31696002)(47076005)(36860700001)(478600001)(54906003)(33964004)(107886003)(40480700001)(31686004)(66899021); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2023 13:38:45.2712 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7a1d40b-c762-445f-6611-08db9426f594 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: DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6367 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matthew Malcomson via Gcc-patches From: Matthew Malcomson Reply-To: Matthew Malcomson Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773215400217085438 X-GMAIL-MSGID: 1773215400217085438 > > I think this is undesriable. With fused you mean we use FMA? > I think you could use -ffp-contract=off for the TU instead. > > Note you can't use __attribute__((noinline)) literally since the > host compiler might not support this. > > Richard. > Trying to make the timevar store integral time intervals. Hope this is acceptable -- I had originally planned to use `-ffp-contract` as agreed until I saw the email mentioning the old x86 bug in the same area which was not to do with floating point contraction of operations (PR 99903) and figured it would be better to try and solve both at the same time while making things in general a bit more robust. diff --git a/gcc/timevar.h b/gcc/timevar.h index ad46573160957c6461190204c5181ec9e904e204..882954a527e11a90873f25a45e9073149709dd05 100644 --- a/gcc/timevar.h +++ b/gcc/timevar.h @@ -44,7 +44,7 @@ */ /* This structure stores the various varieties of time that can be - measured. Times are stored in seconds. The time may be an + measured. Times are stored in nanoseconds. The time may be an absolute time or a time difference; in the former case, the time base is undefined, except that the difference between two times produces a valid time difference. */ @@ -52,14 +52,13 @@ struct timevar_time_def { /* User time in this process. */ - double user; + uint64_t user; - /* System time (if applicable for this host platform) in this - process. */ - double sys; + /* System time (if applicable for this host platform) in this process. */ + uint64_t sys; /* Wall clock time. */ - double wall; + uint64_t wall; /* Garbage collector memory. */ size_t ggc_mem; diff --git a/gcc/timevar.cc b/gcc/timevar.cc index d695297aae7f6b2a6de01a37fe86c2a232338df0..c6094b1c336c30e5a404ff8fd5c79795edbd59f7 100644 --- a/gcc/timevar.cc +++ b/gcc/timevar.cc @@ -42,7 +42,7 @@ struct tms # define RUSAGE_SELF 0 #endif -/* Calculation of scale factor to convert ticks to microseconds. +/* Calculation of scale factor to convert ticks to seconds. We mustn't use CLOCKS_PER_SEC except with clock(). */ #if HAVE_SYSCONF && defined _SC_CLK_TCK # define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */ @@ -91,14 +91,15 @@ struct tms the underlying constants, and that can be very slow, so we have to precompute them. Whose wonderful idea was it to make all those _constants_ variable at run time, anyway? */ +#define NANOSEC_PER_SEC 1000000000 #ifdef USE_TIMES -static double ticks_to_msec; -#define TICKS_TO_MSEC (1 / (double)TICKS_PER_SECOND) +static uint64_t ticks_to_nanosec; +#define TICKS_TO_NANOSEC (NANOSEC_PER_SEC / TICKS_PER_SECOND) #endif #ifdef USE_CLOCK -static double clocks_to_msec; -#define CLOCKS_TO_MSEC (1 / (double)CLOCKS_PER_SEC) +static uint64_t clocks_to_nanosec; +#define CLOCKS_TO_NANOSEC (NANOSEC_PER_SEC / CLOCKS_PER_SEC) #endif /* Non-NULL if timevars should be used. In GCC, this happens with @@ -222,18 +223,20 @@ get_time (struct timevar_time_def *now) { #ifdef USE_TIMES struct tms tms; - now->wall = times (&tms) * ticks_to_msec; - now->user = tms.tms_utime * ticks_to_msec; - now->sys = tms.tms_stime * ticks_to_msec; + now->wall = times (&tms) * ticks_to_nanosec; + now->user = tms.tms_utime * ticks_to_nanosec; + now->sys = tms.tms_stime * ticks_to_nanosec; #endif #ifdef USE_GETRUSAGE struct rusage rusage; getrusage (RUSAGE_SELF, &rusage); - now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6; - now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6; + now->user = rusage.ru_utime.tv_sec * NANOSEC_PER_SEC + + rusage.ru_utime.tv_usec * 1000; + now->sys = rusage.ru_stime.tv_sec * NANOSEC_PER_SEC + + rusage.ru_stime.tv_usec * 1000; #endif #ifdef USE_CLOCK - now->user = clock () * clocks_to_msec; + now->user = clock () * clocks_to_nanosec; #endif } } @@ -271,10 +274,10 @@ timer::timer () : /* Initialize configuration-specific state. Ideally this would be one-time initialization. */ #ifdef USE_TIMES - ticks_to_msec = TICKS_TO_MSEC; + ticks_to_nanosec = TICKS_TO_NANOSEC; #endif #ifdef USE_CLOCK - clocks_to_msec = CLOCKS_TO_MSEC; + clocks_to_nanosec = CLOCKS_TO_NANOSEC; #endif } @@ -583,12 +586,11 @@ timer::validate_phases (FILE *fp) const { unsigned int /* timevar_id_t */ id; const timevar_time_def *total = &m_timevars[TV_TOTAL].elapsed; - double phase_user = 0.0; - double phase_sys = 0.0; - double phase_wall = 0.0; + uint64_t phase_user = 0; + uint64_t phase_sys = 0; + uint64_t phase_wall = 0; size_t phase_ggc_mem = 0; static char phase_prefix[] = "phase "; - const double tolerance = 1.000001; /* One part in a million. */ for (id = 0; id < (unsigned int) TIMEVAR_LAST; ++id) { @@ -607,26 +609,32 @@ timer::validate_phases (FILE *fp) const } } - if (phase_user > total->user * tolerance - || phase_sys > total->sys * tolerance - || phase_wall > total->wall * tolerance - || phase_ggc_mem > total->ggc_mem * tolerance) + if (phase_user > total->user + || phase_sys > total->sys + || phase_wall > total->wall + || phase_ggc_mem > total->ggc_mem) { fprintf (fp, "Timing error: total of phase timers exceeds total time.\n"); if (phase_user > total->user) - fprintf (fp, "user %24.18e > %24.18e\n", phase_user, total->user); + fprintf (fp, "user %13" PRIu64 " > %13" PRIu64 "\n", + phase_user, total->user); if (phase_sys > total->sys) - fprintf (fp, "sys %24.18e > %24.18e\n", phase_sys, total->sys); + fprintf (fp, "sys %13" PRIu64 " > %13" PRIu64 "\n", + phase_sys, total->sys); if (phase_wall > total->wall) - fprintf (fp, "wall %24.18e > %24.18e\n", phase_wall, total->wall); + fprintf (fp, "wall %13" PRIu64 " > %13" PRIu64 "\n", + phase_wall, total->wall); if (phase_ggc_mem > total->ggc_mem) - fprintf (fp, "ggc_mem %24lu > %24lu\n", (unsigned long)phase_ggc_mem, + fprintf (fp, "ggc_mem %13lu > %13lu\n", (unsigned long)phase_ggc_mem, (unsigned long)total->ggc_mem); gcc_unreachable (); } } +#define nanosec_to_floating_sec(NANO) ((double)(NANO) * 1e-9) +#define percent_of(TOTAL, SUBTOTAL) \ + ((TOTAL) == 0 ? 0 : ((double)SUBTOTAL / TOTAL) * 100) /* Helper function for timer::print. */ void @@ -640,22 +648,22 @@ timer::print_row (FILE *fp, #ifdef HAVE_USER_TIME /* Print user-mode time for this process. */ fprintf (fp, "%7.2f (%3.0f%%)", - elapsed.user, - (total->user == 0 ? 0 : elapsed.user / total->user) * 100); + nanosec_to_floating_sec (elapsed.user), + percent_of (total->user, elapsed.user)); #endif /* HAVE_USER_TIME */ #ifdef HAVE_SYS_TIME /* Print system-mode time for this process. */ fprintf (fp, "%7.2f (%3.0f%%)", - elapsed.sys, - (total->sys == 0 ? 0 : elapsed.sys / total->sys) * 100); + nanosec_to_floating_sec (elapsed.sys), + percent_of (total->sys, elapsed.sys)); #endif /* HAVE_SYS_TIME */ #ifdef HAVE_WALL_TIME /* Print wall clock time elapsed. */ fprintf (fp, "%7.2f (%3.0f%%)", - elapsed.wall, - (total->wall == 0 ? 0 : elapsed.wall / total->wall) * 100); + nanosec_to_floating_sec (elapsed.wall), + percent_of (total->wall, elapsed.wall)); #endif /* HAVE_WALL_TIME */ /* Print the amount of ggc memory allocated. */ @@ -673,7 +681,8 @@ timer::print_row (FILE *fp, bool timer::all_zero (const timevar_time_def &elapsed) { - const double tiny = 5e-3; + /* 5000000 nanosec == 5e-3 seconds. */ + uint64_t tiny = 5000000; return (elapsed.user < tiny && elapsed.sys < tiny && elapsed.wall < tiny @@ -766,13 +775,13 @@ timer::print (FILE *fp) /* Print total time. */ fprintf (fp, " %-35s:", "TOTAL"); #ifdef HAVE_USER_TIME - fprintf (fp, "%7.2f ", total->user); + fprintf (fp, "%7.2f ", nanosec_to_floating_sec (total->user)); #endif #ifdef HAVE_SYS_TIME - fprintf (fp, "%8.2f ", total->sys); + fprintf (fp, "%8.2f ", nanosec_to_floating_sec (total->sys)); #endif #ifdef HAVE_WALL_TIME - fprintf (fp, "%8.2f ", total->wall); + fprintf (fp, "%8.2f ", nanosec_to_floating_sec (total->wall)); #endif fprintf (fp, PRsa (7) "\n", SIZE_AMOUNT (total->ggc_mem)); @@ -790,6 +799,8 @@ timer::print (FILE *fp) validate_phases (fp); } +#undef nanosec_to_floating_sec +#undef percent_of /* Get the name of the topmost item. For use by jit for validating inputs to gcc_jit_timer_pop. */