View Single Post
Old January 22nd 15, 12:27 AM posted to
[email protected]
external usenet poster
Posts: 2
Default Transcendental floating point functions are now unfixably brokenon Intel processors

On Friday, October 10, 2014 at 6:58:43 AM UTC-4, Yousuf Khan wrote:
" This error has tragically become un-fixable because of the
compatibility requirements from one generation to the next. The fix for
this problem was figured out quite a long time ago. In the excellent
paper The K5 transcendental functions by T. Lynch, A. Ahmed, M. Schulte,
T. Callaway, and R. Tisdale a technique is described for doing argument
reduction as if you had an infinitely precise value for pi. As far as I
know, the K5 is the only x86 family CPU that did sin/cos accurately. AMD
went back to being bit-for-bit compatibile with the old x87 behavior,
assumably because too many applications broke. Oddly enough, this is
fixed in Itanium.

What we do in the JVM on x86 is moderately obvious: we range check the
argument, and if it's outside the range [-pi/4, pi/4]we do the precise
range reduction by hand, and then call fsin.

So Java is accurate, but slower. I've never been a fan of "fast, but
wrong" when "wrong" is roughly random(). Benchmarks rarely test
accuracy. "double sin(double theta) { return 0; }" would be a great
benchmark-compatible implementation of sin(). For large values of theta,
0 would be arguably more accurate since the absolute error is never
greater than 1. fsin/fcos can have absolute errors as large as 2
(correct answer=1; returned result=-1). "

Wow, you're still here. I haven't peeked at comp.chips in years, maybe a decade. Is Keith / KRW still around? I haven't seen or heard from him since he retired. I see John Corse is still around, same-old-same-old.

To be on-topic, it's interesting to see the transcendentals broken on Intel.. I'm looking into AMD's HSA, and though the math can be double-precision, I'd heard that transcendentals were fudged single-precision. I'd thought of Intel as the gold standard on this, at least after the integer bruising was fixed.