public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Tang, Jun" <juntangc@amazon.com>
To: Zack Weinberg <zack@owlfolio.org>,
	GNU libc development <libc-alpha@sourceware.org>
Subject: RE: bug fix for hp-timing.h (aarch64)
Date: Tue, 31 Jan 2023 14:47:26 +0000	[thread overview]
Message-ID: <4c349a9a330940a78e0e05de192542b6@amazon.com> (raw)
In-Reply-To: <3dd92ee4-00b4-4bf2-ae8c-908a29752198@app.fastmail.com>

Zack,

After rounds of discussion, the suggested solution is the best option and works for all existing benches.  Let me know if I need to submit another request to get this merged

> -   (Diff) = ((End) - (Start)) * (UINT64_C(1000000000) / freq); \
> +   (Diff) = (((End) - (Start)) * UINT64_C(1000000000)) / freq; \

Regards,

Jun

-----Original Message-----
From: Zack Weinberg <zack@owlfolio.org> 
Sent: Wednesday, January 11, 2023 11:22 AM
To: GNU libc development <libc-alpha@sourceware.org>
Subject: Re: bug fix for hp-timing.h (aarch64)

On Wed, Jan 11, 2023, at 11:44 AM, Tang, Jun wrote:
> On Graviton 3 the frequency is 1050000000 and the original function 
> hp-timing.h no longer gives the correct answer. The following patch 
> can fix the bug:

Please try this instead:

> -   (Diff) = ((End) - (Start)) * (UINT64_C(1000000000) / freq); \
> +   (Diff) = (((End) - (Start)) * UINT64_C(1000000000)) / freq; \

This avoids using floating-point arithmetic but should still do the rescale correctly.
(The multiplier and divisor are both guaranteed to be less than 2**32, so, as long as we do the multiplication in 64-bit arithmetic, we cannot lose bits via overflow.)

zw


  reply	other threads:[~2023-01-31 14:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 16:44 Tang, Jun
2023-01-11 17:22 ` Zack Weinberg
2023-01-31 14:47   ` Tang, Jun [this message]
2023-01-11 22:49 Wilco Dijkstra
2023-01-12 14:38 ` Tang, Jun
2023-01-12 18:07   ` Wilco Dijkstra
2023-01-12 18:54     ` Zack Weinberg
2023-01-12 20:32       ` Wilco Dijkstra
2023-01-12 20:51         ` Noah Goldstein
2023-01-16 16:33           ` Wilco Dijkstra
2023-01-16 17:01             ` Noah Goldstein
2023-01-16 18:35               ` Wilco Dijkstra
2023-01-12 15:11 ` Zack Weinberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c349a9a330940a78e0e05de192542b6@amazon.com \
    --to=juntangc@amazon.com \
    --cc=libc-alpha@sourceware.org \
    --cc=zack@owlfolio.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).