From patchwork Thu Jul 9 10:46:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hongbo.zhang@freescale.com X-Patchwork-Id: 50938 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C7D7C228E5 for ; Thu, 9 Jul 2015 10:50:49 +0000 (UTC) Received: by lbbei7 with SMTP id ei7sf1513703lbb.3 for ; Thu, 09 Jul 2015 03:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:mime-version:subject:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=14JQsU2tVBTovS2Xqt1HShIgYbSjI3KxhWfNzkDlBek=; b=iX8JmIBqXd6+jS9R4H/tT6ojytKbXFZlmrgsUCEWeCRRqrZH3I9vN/+JizGazGmfI2 LBiIpYrFkDsxIZFAcRrX9nFKhbLobGfsT676ByWEez30yA3IwGhgykd7ewJuO/+hqcX4 sgvX/Cr2eR3ptcWr6e9jjlmUm+xbebeGHsIqfPvODmn/BSmBLgjzjpl4pYPQKJsHmX6S NDjh68CErHNUFJyJejsDX3VsJpEvqq7yp0zjSR5u+ULCeJl2JaaOt4akKO22PLmastV+ 3p3gvAv9svZTI+gzFwsu+jhO5U0byUsyeI79CeiR0buG+85T7cY+cQ+Exs+VJzueoA5+ uMMA== X-Gm-Message-State: ALoCoQk1kIbZeZzTrTn2JmCz1hMlHLHfb1N3sBW5f6RQjBm1VYZU8ECFePoFRJmAQK0QxI/lJap1 X-Received: by 10.152.2.196 with SMTP id 4mr7617337law.10.1436439048815; Thu, 09 Jul 2015 03:50:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.2 with SMTP id t2ls1084290laz.8.gmail; Thu, 09 Jul 2015 03:50:48 -0700 (PDT) X-Received: by 10.112.89.201 with SMTP id bq9mr13845568lbb.39.1436439048555; Thu, 09 Jul 2015 03:50:48 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id o3si4129574laj.143.2015.07.09.03.50.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jul 2015 03:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbpo10 with SMTP id po10so72660594lbb.3 for ; Thu, 09 Jul 2015 03:50:48 -0700 (PDT) X-Received: by 10.152.36.102 with SMTP id p6mr14100156laj.19.1436439048354; Thu, 09 Jul 2015 03:50:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp578436lbb; Thu, 9 Jul 2015 03:50:47 -0700 (PDT) X-Received: by 10.55.27.70 with SMTP id b67mr23898787qkb.86.1436439047079; Thu, 09 Jul 2015 03:50:47 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k39si6358257qgk.87.2015.07.09.03.50.46; Thu, 09 Jul 2015 03:50:47 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 0307E61842; Thu, 9 Jul 2015 10:50:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 393AF61FD3; Thu, 9 Jul 2015 10:47:16 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id F215561F6F; Thu, 9 Jul 2015 10:46:54 +0000 (UTC) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0106.outbound.protection.outlook.com [207.46.100.106]) by lists.linaro.org (Postfix) with ESMTPS id 9DC2861FBB for ; Thu, 9 Jul 2015 10:46:21 +0000 (UTC) Received: from BN3PR0301CA0012.namprd03.prod.outlook.com (10.160.180.150) by BY2PR03MB287.namprd03.prod.outlook.com (10.242.37.26) with Microsoft SMTP Server (TLS) id 15.1.207.12; Thu, 9 Jul 2015 10:46:19 +0000 Received: from BN1BFFO11FD027.protection.gbl (2a01:111:f400:7c10::1:103) by BN3PR0301CA0012.outlook.office365.com (2a01:111:e400:4000::22) with Microsoft SMTP Server (TLS) id 15.1.213.14 via Frontend Transport; Thu, 9 Jul 2015 10:46:19 +0000 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD027.mail.protection.outlook.com (10.58.144.90) with Microsoft SMTP Server (TLS) id 15.1.201.10 via Frontend Transport; Thu, 9 Jul 2015 10:46:18 +0000 Received: from hongbo.ap.freescale.net (hongbo.ap.freescale.net [10.193.20.67]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t69AkBff022771; Thu, 9 Jul 2015 03:46:17 -0700 From: To: Date: Thu, 9 Jul 2015 18:46:04 +0800 Message-ID: <1436438768-4258-5-git-send-email-hongbo.zhang@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436438768-4258-1-git-send-email-hongbo.zhang@freescale.com> References: <1436438768-4258-1-git-send-email-hongbo.zhang@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD027; 1:uBxwnqnFobTSmoiN/uOdz9Gc2gQ5ukObbt7VSiV/58IkYny8DMuY0/1LerAhdkO9Y9zY7VnJBSOjsnFCms3+DaTG9M45ktZXOxWyEtoyZnBBAgeIB+FgOavA/QFNO8b9eOCdYIQjWtFJK4CpKuc6OCpWEdVTmPM+JnYnQTYZgKx0rWsIk3A2PCSar1ebK5Xa3wdet8/5fhN4v1kWrIRnJPXYic5pPp+vI/VK6e1AuKcAnq/72ieAyHq1oR5KKGHKO83sACM+IA6270KgtV7cSpRVcs9DnhcZiZdHegtTKRnYvUrGp0J5ioZUOFG7Os/E X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(105606002)(62966003)(5001960100002)(189998001)(87936001)(575784001)(46102003)(47776003)(106466001)(85426001)(86362001)(50226001)(86152002)(77156002)(92566002)(104016003)(33646002)(2351001)(5003940100001)(110136002)(76176999)(50986999)(6806004)(229853001)(2950100001)(19580405001)(50466002)(48376002)(77096005)(19580395003)(36756003)(41533002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB287; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB287; 2:Xci5Q7d/b26aI7lPJHhIv0xu7q7rDpoisVK836kUAj5MTsoU53u0AK/L2jvKfswo; 3:Go8syFsnV6Uwm0fshayOO2hx7W1t8tfEM6H8jLYx6L7PvNNuPKUEEZqd6hZ+dZ0WHqfTSqntV4oRAc0GUsbcKp5LZqg7yYnMjJCvQDKtT1uRpGA/AmM1bo9X5Vdo3abph2V9t9BnND8F5XX2Jt7hjiloIW2Q2SF4OqKyLq5dvyWNcSMYkAsB89MhoVWK96FmYUjwQ8wHkRpkv2zp3F5N9wPWiboe3cMzPah8pZKch1s=; 25:2x5u5zmAMn1GTOO+qj6HpBFu9Ups8nkXGQRClVwjBYlr+IJyvO/NvfjIqZIk42opwFlBIi6m2O3lNRP5kP9V/kp4HArnO0ZACmn2TAruKzL98QZLgIa8Ck9qGoQgc4JFB8q4SisU2f7vsnXzZBhERJT3opT8FjwuGiTfLyNq6UYdfOHZhIAHVCxr+vQo1IpbDDwA3yBbmA4G/2v6Cr19q1vR/mGyx+yK17fUYHRrx7NWUUPFvES2FzLowVmZh9tzXaZ0+P6wLWpMzXusWy0wzg==; 20:ZzfM+aQ86Jws3DuCDMUaGlQ8xMMjzXA3nJ20K3hmIMvAONfT9h3ErkCWbCGqOAdzFhYxLs49UkmGKuCsxnZ5LOkYVWpm8jFRhAHaALdd2q+r/2kAcwL8aehp5i1EZMmx/037/c+GLb8Oc72AEilzV3hL2VRv7dY+j5ChMCtcbvOdRC1ECApDR3jGCVDbaB7+5M9LMz4bQF5m1ed+VI0Od0lrFrFRP0Dp3WEm+kZJOPLxqnQAAjQ6Y0SIAC5MhPT91vcYJ8R6Mbyax45epffMWcHXYSQ+Zrv39QFHhhVnW7ngkfWqQTuT6QD8IcTAdYF3nzUHhsOWIJKBHAH77FkDI2IrL5F0TcPNkq2Pr+A1jmE= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB287; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BY2PR03MB287; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB287; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB287; 4:P7/gcqp6v9cmjm3Jonr15h5jyy4JNrw31bTeNWGmw8+X36smcaWE5s7z6LB/zj/IoiwpXqhxjd0TcgBysDFju275drieMBpQzgJMa4yEnI6RsGuTVYFAVsUO5manraUWxdpBpQZadj4Ps6ndMquxwhoq4+FQM7iHitb+ptVFL4sogsdax8pjPn0rcjJFOi8hUzb70NP2visllKCSgMUOTbm/g0vrxMcUt7L62nH86i4lN8zdcGb3NFiCD4Hwb2Bjx89OsSGowgfEXOijM/09M9W6ESpH3LOl7YgBIP4RcWE= X-Forefront-PRVS: 0632519F33 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB287; 23:Qdum7tf++Fe5zm/2ILWhV7cQjb4vjk1UliKMcdwM55?= =?us-ascii?Q?JFEj7A0GKpanEypugsPt2lHlq43FXjg0r6HrDMqLDt/V+5G81ooI+5TM/mcw?= =?us-ascii?Q?OFHmrb6Hxu2JB5UiJX/QdCl2zkEO38cRFNlnMeR3CAwfA4l/Fm4opeN+0/Lf?= =?us-ascii?Q?E6KVHQAHlCkEd3gjDNeUw8ErBxd7lwGq41F8BoB4HNp5G79bzfA+0F78Mn7Y?= =?us-ascii?Q?E8XGYJgHBiThbNr2gq4pxO8qu2jj2Vh+cJwM8R6BcAShbsbiQ/EEGTB8gfFD?= =?us-ascii?Q?7fzfx4CQ0xlzXXf2QHLlcF79atZnHwB46hAL9BxFBiQUsyTWll4/4h3j7BGv?= =?us-ascii?Q?EJ6M10NuiNQuLh/Ck1/51QMfCqE6bPRhpua0PmWkt6dyjjJS2bv+V1wY+NRa?= =?us-ascii?Q?9tTyg3H5mbvde0eBZS0eVVrtQXJFd5/QZFGyGDNr8gqdCcY+vk5iQOmkpF03?= =?us-ascii?Q?KdGxFTPPnWJQqQ4+4eZW6DXVlQ3No1+Q7CxJ36kpWKp3GpYSLKNHmO6RZQnf?= =?us-ascii?Q?iAQaA8O1FifwjoVrBvG+bvZMytqd1aTsn4CDOXieBJrfzmnZZXHcrc4hp/KP?= =?us-ascii?Q?P3YNKu4iGb4AFhMaHRDhY+iNSnwQvhMgTU1ahXuD7rf1xRdOld701uyyu4tz?= =?us-ascii?Q?jvVV4e9WywWWJOkLiPc6CLfARr6qD7xr+ZAJJVfU2KnzHADPhv3EWgiG05Jp?= =?us-ascii?Q?cpsFCSupOYudmucGX2j6sgvTPk19jkZZvS2kF5gJADw2ns5jSOKP7NFMVTy0?= =?us-ascii?Q?QuRgNeq50olsOXMBm6c9Z0//w6XDS3n5Z7JsN6gOOb0yPinGsHB1tbFIRLdI?= =?us-ascii?Q?0ivcENFUS+nsbnM/7X7LymTMX3MhQR1lE0akQ/MPsJHlR6EY2Zw4w5D8/P6h?= =?us-ascii?Q?/i0cXYonwB7WYA0GtsnAsbjED60FQWTydpJn7xgbo+3iCy2dsktp8rhP4XXa?= =?us-ascii?Q?U3MLtlNGeOpIS3VcFDx5nbhB61sSQjwpSSXIMIp0uXmwYR2lYT8EPMqvFL51?= =?us-ascii?Q?s=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB287; 5:NWcRUW5afaOlWS9A1D6vkDBfhpGdxQ74rGp6Mp19R1wRMzN00MfVS1//GK/sd+haYwY19UFjtujz/8X532x/5zohP/aNpXldo3CSyX1F8m8ODJEaK4W9Ug+iK/49BB2ghmWLD36O+poRmt0OxpetOg==; 24:H4PfmKT/Qgw4kc3AaNU5u8cfJSvBMQ11YEgbfbVdY0+UVqWHMEhcHZPab6Xd5ekeJEpGdmiMjkV7dBi0jiWtgbBpOfglSXBFjO8ka6YvbU4=; 20:nx2JUDrd0Q3dfRZ0Gy0gAACfnSWA9yUtnyi4NOmvxo5f2+WN33HAgdAl9weM5E9F/qisIifYRCJbt+UkN3zALg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2015 10:46:18.8487 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB287 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v3 4/8] linux-generic: sysinfo: clarify the API for max CPU frequency X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Hongbo Zhang Currently the API to get CPU frequency is vague, it needs to be clarified whether max or current frequency is returned, and now most use cases want to get max capacity of CPU in fact, so this patch makes it clear that the cpu_hz stand for max CPU frequency. (there is no need to store current instant frequency) Accordingly the API odp_cpu_hz() is renamed to odp_cpu_hz_max(). While there may still be some use case of acquiring the current CPU frequency, so the previous odp_cpu_hz() will be re-implemented for this purpose in the next patch. As to platforms other than x86, if their cpu_hz's don't stand for max CPU frequency, they should be changed following up this patch, and then max or current frequency of CPU should be clear. Signed-off-by: Hongbo Zhang --- example/classifier/odp_classifier.c | 2 +- example/generator/odp_generator.c | 2 +- example/ipsec/odp_ipsec.c | 2 +- example/packet/odp_pktio.c | 2 +- example/timer/odp_timer_test.c | 4 ++-- include/odp/api/cpu.h | 6 ++++-- platform/linux-generic/arch/linux/odp_time.c | 2 +- platform/linux-generic/odp_system_info.c | 22 +++++++--------------- platform/linux-generic/odp_time.c | 4 ++-- test/api_test/odp_common.c | 2 +- test/performance/odp_atomic.c | 2 +- test/performance/odp_l2fwd.c | 2 +- test/performance/odp_scheduling.c | 2 +- test/validation/ver_abt_log_dbg/odp_system.c | 6 +++--- 14 files changed, 27 insertions(+), 33 deletions(-) diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c index c695741..25670b2 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -728,7 +728,7 @@ static void print_info(char *progname, appl_args_t *appl_args) "CPU count: %i\n" "\n", odp_version_api_str(), odp_cpu_model_str(), - odp_cpu_hz(), odp_sys_cache_line_size(), + odp_cpu_hz_max(), odp_sys_cache_line_size(), odp_cpu_count()); printf("Running ODP appl: \"%s\"\n" diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 8920146..d847008 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -978,7 +978,7 @@ static void print_info(char *progname, appl_args_t *appl_args) "Cache line size: %i\n" "CPU count: %i\n" "\n", - odp_version_api_str(), odp_cpu_model_str(), odp_cpu_hz(), + odp_version_api_str(), odp_cpu_model_str(), odp_cpu_hz_max(), odp_sys_cache_line_size(), odp_cpu_count()); printf("Running ODP appl: \"%s\"\n" diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 5fcc9dd..58ff99a 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -1517,7 +1517,7 @@ static void print_info(char *progname, appl_args_t *appl_args) "Cache line size: %i\n" "CPU count: %i\n" "\n", - odp_version_api_str(), odp_cpu_model_str(), odp_cpu_hz(), + odp_version_api_str(), odp_cpu_model_str(), odp_cpu_hz_max(), odp_sys_cache_line_size(), odp_cpu_count()); printf("Running ODP appl: \"%s\"\n" diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index d0b6e7c..deaa5a0 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -626,7 +626,7 @@ static void print_info(char *progname, appl_args_t *appl_args) "Cache line size: %i\n" "CPU count: %i\n" "\n", - odp_version_api_str(), odp_cpu_model_str(), odp_cpu_hz(), + odp_version_api_str(), odp_cpu_model_str(), odp_cpu_hz_max(), odp_sys_cache_line_size(), odp_cpu_count()); printf("Running ODP appl: \"%s\"\n" diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 01abe04..0bd1a7e 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -365,7 +365,7 @@ int main(int argc, char *argv[]) printf("---------------\n"); printf("ODP API version: %s\n", odp_version_api_str()); printf("CPU model: %s\n", odp_cpu_model_str()); - printf("CPU freq (hz): %"PRIu64"\n", odp_cpu_hz()); + printf("CPU freq (hz): %"PRIu64"\n", odp_cpu_hz_max()); printf("Cache line size: %i\n", odp_sys_cache_line_size()); printf("Max CPU count: %i\n", odp_cpu_count()); @@ -463,7 +463,7 @@ int main(int argc, char *argv[]) return -1; } - printf("CPU freq %"PRIu64" Hz\n", odp_cpu_hz()); + printf("CPU freq %"PRIu64" Hz\n", odp_cpu_hz_max()); printf("Cycles vs nanoseconds:\n"); ns = 0; cycles = odp_time_ns_to_cycles(ns); diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h index 7b548ce..56efe14 100644 --- a/include/odp/api/cpu.h +++ b/include/odp/api/cpu.h @@ -44,11 +44,13 @@ int odp_cpu_id(void); int odp_cpu_count(void); /** - * CPU frequency in Hz + * Maximum CPU frequency in Hz + * + * Returns maximum frequency of this CPU * * @return CPU frequency in Hz */ -uint64_t odp_cpu_hz(void); +uint64_t odp_cpu_hz_max(void); /** * CPU model name diff --git a/platform/linux-generic/arch/linux/odp_time.c b/platform/linux-generic/arch/linux/odp_time.c index 3309da0..ed6e560 100644 --- a/platform/linux-generic/arch/linux/odp_time.c +++ b/platform/linux-generic/arch/linux/odp_time.c @@ -28,7 +28,7 @@ uint64_t odp_time_cycles(void) if (ret != 0) ODP_ABORT("clock_gettime failed\n"); - hz = odp_cpu_hz(); + hz = odp_cpu_hz_max(); sec = (uint64_t) time.tv_sec; ns = (uint64_t) time.tv_nsec; diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 26fe2c8..225deea 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -120,35 +120,27 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) { char str[1024]; char *pos; - double mhz = 0.0; + double ghz = 0.0; int model = 0; - int count = 2; + int count = 1; while (fgets(str, sizeof(str), file) != NULL && count > 0) { - if (!mhz) { - pos = strstr(str, "cpu MHz"); - if (pos) { - sscanf(pos, "cpu MHz : %lf", &mhz); - count--; - } - } - if (!model) { pos = strstr(str, "model name"); if (pos) { - int len; pos = strchr(str, ':'); strncpy(sysinfo->model_str[0], pos + 2, sizeof(sysinfo->model_str[0])); - len = strlen(sysinfo->model_str[0]); - sysinfo->model_str[0][len - 1] = 0; + pos = strchr(sysinfo->model_str[0], '@'); + *(pos - 1) = '\0'; + sscanf(pos, "@ %lfGHz", &ghz); model = 1; count--; } } } - sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); + sysinfo->cpu_hz[0] = (uint64_t)(ghz * 1000000000.0); return 0; } @@ -373,7 +365,7 @@ int odp_system_info_init(void) * Public access functions ************************* */ -uint64_t odp_cpu_hz(void) +uint64_t odp_cpu_hz_max(void) { return odp_global_data.system_info.cpu_hz[0]; } diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c index a137a36..f864ade 100644 --- a/platform/linux-generic/odp_time.c +++ b/platform/linux-generic/odp_time.c @@ -23,7 +23,7 @@ uint64_t odp_time_diff_cycles(uint64_t t1, uint64_t t2) uint64_t odp_time_cycles_to_ns(uint64_t cycles) { - uint64_t hz = odp_cpu_hz(); + uint64_t hz = odp_cpu_hz_max(); if (cycles > (UINT64_MAX / GIGA)) return (cycles/hz)*GIGA; @@ -34,7 +34,7 @@ uint64_t odp_time_cycles_to_ns(uint64_t cycles) uint64_t odp_time_ns_to_cycles(uint64_t ns) { - uint64_t hz = odp_cpu_hz(); + uint64_t hz = odp_cpu_hz_max(); if (ns > (UINT64_MAX / hz)) return (ns/GIGA)*hz; diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c index 0a2b184..a5f09f2 100644 --- a/test/api_test/odp_common.c +++ b/test/api_test/odp_common.c @@ -42,7 +42,7 @@ void odp_print_system_info(void) printf("---------------\n"); printf("ODP API version: %s\n", odp_version_api_str()); printf("CPU model: %s\n", odp_cpu_model_str()); - printf("CPU freq (hz): %"PRIu64"\n", odp_cpu_hz()); + printf("CPU freq (hz): %"PRIu64"\n", odp_cpu_hz_max()); printf("Cache line size: %i\n", odp_sys_cache_line_size()); printf("CPU count: %i\n", odp_cpu_count()); printf("CPU mask: %s\n", str); diff --git a/test/performance/odp_atomic.c b/test/performance/odp_atomic.c index 7fcd0b0..d741d05 100644 --- a/test/performance/odp_atomic.c +++ b/test/performance/odp_atomic.c @@ -338,7 +338,7 @@ void odp_print_system_info(void) printf("---------------\n"); printf("ODP API version: %s\n", odp_version_api_str()); printf("CPU model: %s\n", odp_cpu_model_str()); - printf("CPU freq (hz): %"PRIu64"\n", odp_cpu_hz()); + printf("CPU freq (hz): %"PRIu64"\n", odp_cpu_hz_max()); printf("Cache line size: %i\n", odp_sys_cache_line_size()); printf("CPU count: %i\n", odp_cpu_count()); printf("CPU mask: %s\n", str); diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index 877be14..4e83975 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -639,7 +639,7 @@ static void print_info(char *progname, appl_args_t *appl_args) "Cache line size: %i\n" "CPU count: %i\n" "\n", - odp_version_api_str(), odp_cpu_model_str(), odp_cpu_hz(), + odp_version_api_str(), odp_cpu_model_str(), odp_cpu_hz_max(), odp_sys_cache_line_size(), odp_cpu_count()); printf("Running ODP appl: \"%s\"\n" diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 69e74f4..bef3172 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -870,7 +870,7 @@ int main(int argc, char *argv[]) printf("---------------\n"); printf("ODP API version: %s\n", odp_version_api_str()); printf("CPU model: %s\n", odp_cpu_model_str()); - printf("CPU freq (hz): %"PRIu64"\n", odp_cpu_hz()); + printf("CPU freq (hz): %"PRIu64"\n", odp_cpu_hz_max()); printf("Cache line size: %i\n", odp_sys_cache_line_size()); printf("Max CPU count: %i\n", odp_cpu_count()); diff --git a/test/validation/ver_abt_log_dbg/odp_system.c b/test/validation/ver_abt_log_dbg/odp_system.c index 22e8db3..9058c6c 100644 --- a/test/validation/ver_abt_log_dbg/odp_system.c +++ b/test/validation/ver_abt_log_dbg/odp_system.c @@ -74,18 +74,18 @@ static void test_odp_sys_huge_page_size(void) CU_ASSERT(0 < page); } -static void test_odp_cpu_hz(void) +static void test_odp_cpu_hz_max(void) { uint64_t hz; - hz = odp_cpu_hz(); + hz = odp_cpu_hz_max(); CU_ASSERT(0 < hz); } CU_TestInfo test_odp_system[] = { {"odp version", test_odp_version_numbers}, {"odp_cpu_count", test_odp_cpu_count}, - {"odp_cpu_hz", test_odp_cpu_hz}, + {"odp_cpu_hz_max", test_odp_cpu_hz_max}, {"odp_cpu_model_str", test_odp_cpu_model_str}, {"odp_sys_cache_line_size", test_odp_sys_cache_line_size}, {"odp_sys_page_size", test_odp_sys_page_size},