From: Matt Turner <mattst88@gmail.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org,
Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
"H . J . Lu" <hjl.tools@gmail.com>,
kirill <kirill.okhotnikov@gmail.com>
Subject: Re: [PATCH 4/4] math: Improve fmodf
Date: Mon, 13 Mar 2023 11:19:58 -0400 [thread overview]
Message-ID: <CAEdQ38GP4Lvik9Pgt_4Q+5O2DLtCNc6YVmQPAkywTKz-mz9L_Q@mail.gmail.com> (raw)
In-Reply-To: <20230310175900.2388957-5-adhemerval.zanella@linaro.org>
On Fri, Mar 10, 2023 at 1:01 PM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> This uses a new algorithm similar to already proposed earlier [1].
> With x = mx * 2^ex and y = my * 2^ey (mx, my, ex, ey being integers),
> the simplest implementation is:
>
> mx * 2^ex == 2 * mx * 2^(ex - 1)
>
> while (ex > ey)
> {
> mx *= 2;
> --ex;
> mx %= my;
> }
>
> With mx/my being mantissa of double floating pointer, on each step the
> argument reduction can be improved 8 (which is sizeof of uint32_t minus
> MANTISSA_WIDTH plus the signal bit):
>
> while (ex > ey)
> {
> mx << 8;
> ex -= 8;
> mx %= my;
> } */
>
> The implementation uses builtin clz and ctz, along with shifts to
> convert hx/hy back to doubles. Different than the original patch,
> this path assume modulo/divide operation is slow, so use multiplication
> with invert values.
>
> I see the following performance improvements using fmod benchtests
> (result only show the 'mean' result):
>
> Architecture | Input | master | patch
> -----------------|-----------------|----------|--------
> x86_64 (Ryzen 9) | subnormals | 17.2549 | 12.3214
> x86_64 (Ryzen 9) | normal | 85.4096 | 52.6625
> x86_64 (Ryzen 9) | close-exponents | 19.1072 | 17.4622
> aarch64 (N1) | subnormal | 10.2182 | 6.81778
> aarch64 (N1) | normal | 60.0616 | 158.339
Is this line correct? 60 -> 158?
next prev parent reply other threads:[~2023-03-13 15:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 17:58 [PATCH 0/4] Improve fmod and fmodf Adhemerval Zanella
2023-03-10 17:58 ` [PATCH 1/4] benchtests: Add fmod benchmark Adhemerval Zanella
2023-03-10 17:58 ` [PATCH 2/4] benchtests: Add fmodf benchmark Adhemerval Zanella
2023-03-10 17:58 ` [PATCH 3/4] math: Improve fmod Adhemerval Zanella
2023-03-10 17:59 ` [PATCH 4/4] math: Improve fmodf Adhemerval Zanella
2023-03-10 23:17 ` H.J. Lu
2023-03-13 15:19 ` Matt Turner [this message]
2023-03-13 16:38 ` Adhemerval Zanella Netto
2023-03-14 16:42 ` Wilco Dijkstra
2023-03-15 17:50 ` Adhemerval Zanella Netto
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=CAEdQ38GP4Lvik9Pgt_4Q+5O2DLtCNc6YVmQPAkywTKz-mz9L_Q@mail.gmail.com \
--to=mattst88@gmail.com \
--cc=Wilco.Dijkstra@arm.com \
--cc=adhemerval.zanella@linaro.org \
--cc=hjl.tools@gmail.com \
--cc=kirill.okhotnikov@gmail.com \
--cc=libc-alpha@sourceware.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).