public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* More efficient fmod()
@ 2022-10-03 22:28 Wilco Dijkstra
  0 siblings, 0 replies; 3+ messages in thread
From: Wilco Dijkstra @ 2022-10-03 22:28 UTC (permalink / raw)
  To: oliver.schaedlich, Adhemerval Zanella; +Cc: 'GNU C Library'

Hi Oliver,

> I've benchmarkey my code against e_fmod.c and
> the difference in the performance is still the same:

That looks like a random test over the full range - this tests 2 cases:
x < y and x > y with a large average exponent difference.
The first case is common and should have an early exit returning x.
The other is rare, and while it is worth reducing the worst-case timing,
this requires an algorithm which processes many bits at a time.
What is missing is the common case where the exponent difference is
small - here you can also have an early exit after doing a division.

For benchmarking it is best to test each case separately. When possible
we extract a representative trace from a benchmark and replay that so
we optimize for real-world inputs.

To add to Adhemerval's comments, the code needs to work efficiently on
32-bit targets as well as targets that don't have a count leading zeroes
instruction. Since there are many uses of both, the overhead of emulating
them is likely going to be expensive, so that might require an alternative
approach to make sure the new version is always faster.

Cheers,
Wilco

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-03 22:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <211e8b64-519a-6037-62fc-7fcac1983ac4@gmail.com>
2022-10-01 20:16 ` More efficient fmod() Adhemerval Zanella Netto
2022-10-02  6:45   ` Oliver Schädlich
2022-10-03 22:28 Wilco Dijkstra

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).