From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>, "H.J. Lu" <hjl.tools@gmail.com>
Cc: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
kirill <kirill.okhotnikov@gmail.com>
Subject: Re: [PATCH v2 3/5] math: Improve fmod
Date: Thu, 16 Mar 2023 17:39:22 -0300 [thread overview]
Message-ID: <ee04ba02-653d-0cf6-8496-e5894918d7b9@linaro.org> (raw)
In-Reply-To: <PAWPR08MB8982CC4CAA371CB30CF8AE7483BC9@PAWPR08MB8982.eurprd08.prod.outlook.com>
On 16/03/23 13:13, Wilco Dijkstra wrote:
> Hi,
>
> It's these cases where x87 is still faster than the generic version:
>
>> E5-2640 | close-exponents | 39.298 | 22.2742
>>
>> i7-4510U | close-exponents | 29.463 | 22.8572
>
> Are these mostly x < y or cases where the exponent difference is just over 11 and
> thus we do not use the fast path?
In fact the fast path will be used on ~83% of the cases (849 from 1024 entries).
Profiling shows that the initial checks might be the culprit, since generic
compat wrapper uses compiler builtins that might map to fp instructions. But even
trying to mimic did not improve much. It seems that for some CPU the integer
operations to create the final floating number is what is costly.
>
>> I am also checking a algorithm change to use simple loop for the normal inputs,
>> where integer modulo operation is used instead of inverse multiplication.
>
> Adding another fast path for a wider range of exponent difference could be faster
> than the generic modulo loop. This could do 2 modulo steps and maybe handle
> tail zeroes (which I think is what HJ's testcase will benefit from).
>
> For really large exponent differences, the generic modulo code could process 30
> or 60 bits per iteration instead of just 11. It's more complex (so would be a separate
> patch) but it should help CPUs with relatively high latency multipliers.
Yes, it might be an improvement indeed.
next prev parent reply other threads:[~2023-03-16 20:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 20:59 [PATCH v2 0/5] Improve fmod and fmodf Adhemerval Zanella
2023-03-15 20:59 ` [PATCH v2 1/5] benchtests: Add fmod benchmark Adhemerval Zanella
2023-03-15 20:59 ` [PATCH v2 2/5] benchtests: Add fmodf benchmark Adhemerval Zanella
2023-03-15 20:59 ` [PATCH v2 3/5] math: Improve fmod Adhemerval Zanella
2023-03-16 0:58 ` H.J. Lu
2023-03-16 14:28 ` Adhemerval Zanella Netto
2023-03-16 16:13 ` Wilco Dijkstra
2023-03-16 20:39 ` Adhemerval Zanella Netto [this message]
2023-03-17 14:55 ` Wilco Dijkstra
2023-03-17 16:07 ` H.J. Lu
2023-03-17 18:22 ` Wilco Dijkstra
2023-03-15 20:59 ` [PATCH v2 4/5] math: Improve fmodf Adhemerval Zanella
2023-03-16 18:11 ` Wilco Dijkstra
2023-03-16 18:38 ` Adhemerval Zanella Netto
2023-03-16 19:15 ` Wilco Dijkstra
2023-03-16 19:45 ` Adhemerval Zanella Netto
2023-03-15 20:59 ` [PATCH v2 5/5] math: Remove the error handling wrapper from fmod and fmodf Adhemerval Zanella
2023-03-16 17:21 ` Wilco Dijkstra
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=ee04ba02-653d-0cf6-8496-e5894918d7b9@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=Wilco.Dijkstra@arm.com \
--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).