[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Proposal: Eliminating use of long double
From: |
Shawn Wagner |
Subject: |
Proposal: Eliminating use of long double |
Date: |
Wed, 18 May 2022 04:52:07 -0700 |
Now that I'm (mostly) caught up on outstanding minor patches (largely
documentation fixes from Erik) and my own queued up small
improvements, time to talk about some bigger/higher impact things I
had in the back of my mind.
First is switching numbers from the C long double type currently being
used to plain double. They're already the same thing on most
architectures. x86 is, I believe, the only common one where long
double is bigger (80 bits vs 64), and requires using the old FPU
instructions instead of SSE ones. I haven't benchmarked, but I
strongly suspect that more time is spent in converting between strings
and C floating point numbers than is spent actually doing
computations, but there are definitely some loops over arrays of
numbers that could benefit from SSE/AVX vectorization.
This will cause a slight loss of precision on CPUs where sizeof(long
double) > sizeof(double), but I'm 99.9% sure that won't be an issue;
the default number to string settings don't print out more digits than
a double can represent.
If anyone actually depends on those additional bits, I think a better
(Definitely more portable) option would be to use MPFR'/GMPs arbitrary
precision types; maybe toggle between double and them with an option
like gawk's -N/--bignum (Though supporting both would require a major
refactoring of datamash).
Thoughts?
- Proposal: Eliminating use of long double,
Shawn Wagner <=