The Intel 8087 chip: floating-point addition and subtraction
Posted by pwg 3 days ago
Comments
Comment by WalterBright 3 days ago
I've always been proud to support the 8087 with my compilers, and am baffled why the numerics people ignore it.
Comment by indymike 3 days ago
Comment by Forgeties79 3 days ago
Comment by HexPhantom 3 days ago
Comment by downut 3 days ago
I dunno Walter but as the first(?) IEEE754 implementation in a PC system it seemed like a pretty damn big deal to us people working in numerical algorithms. It was a big enough deal to me at the time (I was in graduate school) that I've kept my 8087 chip all my life and have it before me now. I see the old boy has lost a pin during the last move, dammit.
Chip has "3716150AA MALAY BEV 22" embossed on the pin side. Search gets me nothing.
Comment by WalterBright 3 days ago
Comment by downut 3 days ago
Is that inaccurate? If not how did you store the extra 16 bits (DP)? I should've bought a zortech compiler back in the day? ;-)
I am sorry that Borland hooked me with turbo-p and then jacked me up with turbo-c/c++.
Comment by to11mtm 3 days ago
Downside is, of course, 10 bytes is a fairly awkward size; it is not nearly as fast as 32/64 bits to move in and out, plus it -has- to be memory (i.e. can't just borrow another register) and then the potential impacts around alignment of data structures/etc to consider.
Comment by WalterBright 3 days ago
Zortech's `long double` was 80 bits. In D, the `real` type is 80 bits. Sadly, that isn't available on the AArch64 processor.
Comment by jcranmer 3 days ago
The main problem with the x87 floating-point unit is that it only properly works on a weird 80-bit floating-point type that doesn't have the properties you expect of regular IEEE 754 floating-point types, thanks to the explicit integer bit. The design makes it hard to properly emulate the more common 32-bit and 64-bit single and double-precision floating-point arithmetic bit-equivalently, and this is compounded by many compilers' decision to spill floating-point registers incorrectly (they're spilled as 32-bit or 64-bit, not 80-bit), which makes the numerical results of your program effectively random. Also, the size of the 80-bit types isn't really conducive to vectorization, so the floating-point unit gets left behind as SIMD programming starts to become more important.
So what happens is that the x87 is essentially the last of the pre-IEEE 754 floating-point systems that's still hanging around. A lot of the features that would make it interesting in an environment where every vendor has a different floating-point system are now just vestigial weirdness in a world where everybody is following the same floating-point system, and not worth supporting.
Comment by downut 3 days ago
As far as delivered accuracy of the 8087, performing the operations at 80 bits, rather than 64 it was better than non-extended formats. Anyway you can read all about it here:
https://en.wikipedia.org/wiki/Extended_precision#x86_extende...
Kahan endorsed is all I needed to know.
I can't remember the details from back then but the initial Sun java implementation did something weird with this.
Comment by rofluto 3 days ago
Comment by downut 3 days ago
With the NAS Parallel Benchmarks we were trying to encourage as wide a diversity of hardware and algorithms as possible so we were lenient with the acceptable "valid" interval of "correct" behavior. I've already discussed heretical Cray FP. Those were fantastic systems. No way would we disqualify some weird/different algorithm/architecture if it meaningfully advanced the SOA in performance/efficiency. OTOH wars were fought over having any firm accuracy requirements at all. So this jvm thing looked... pointless at best?
This is all nostalgia for a past that actually was. Those were the days my friends.
Comment by rofluto 3 days ago
Spoken like someone who never had to implement multi precision library. Thankfully Sun's idea won, the 80bit shape shifting to 64 bit upon register spill is a distant past, all modern processors implement fully deterministic +-*/ float64 ops, which allows sane and portable libraries for quadfloats, multi precision, interval arithmetic and the like
Comment by downut 3 days ago
The 80 bit format was an at-the-time (ATT) engineering optimization that made ATT double precision (DP) more attractive given the better round-off behavior, at "no-cost".
So the interesting question here (that I don't know) is: is "deterministic" quad-precision (QP) as the accuracy upgrade from "non-deterministic" 80bit internal DP, always better economically?
Depends on what the computational problem is, given a budget. And that budget buys things that are only available on the market.
I used to think technology monocultures were a good thing but given the current state of things I have reversed myself. I am happy that life has simplified for you though.
I've been watching, lightly, interval arithmetic for 40 years. As you know algorithm sensitivity information is mandatory. We used intel 80bit FP do evaluate that, slowly, back in the day. We didn't use interval arithmetic, though we knew about it. It wasn't economically viable. Hey C++ what can you do for us? Templates, damn.
How important is interval arithmetic, economically, now?
Comment by librasteve 3 days ago
I spent months in all the corners of P754 and can attest to it being the most carefully thought through and subtly powerful document.
At this time we built custom FPUs for non P754 such as DEC format which iirc was deliberately close to P754 but slightly twisted to maintain code incompatibility.
Anyone who thinks FPU math is deterministic has not got close to circuit design for these beasts. I suppose MAYBE that got fixed in the last 40 years, but the move to GPU leads me to suspect that determinism in all the myriad corner cases is not top of the list.
Comment by WalterBright 3 days ago
My compilers behaved properly.
Comment by WalterBright 3 days ago
Comment by dsign 3 days ago
Comment by jart 3 days ago
Comment by russdill 3 days ago
Comment by shakna 3 days ago
They tried, with the H- and P- lines to effectively make it a paid extra over the regular productions. At least they accepted when the market disagreed.
Comment by kens 3 days ago
Comment by n923263 3 days ago
Comment by kens 3 days ago
Comment by jakzurr 3 days ago
Comment by bell-cot 3 days ago
Comment by bonzini 3 days ago
Comment by kens 3 days ago
Comment by bonzini 3 days ago
Comment by rep_lodsb 3 days ago
So FSTSW AX was handled by the CPU microcode, which would read the status word from a reserved I/O port and put it into AX.
The 386 was even more tightly integrated, with some of the FPU state duplicated inside the CPU, so that it could store it to memory in different formats depending on whether it was currently in 16- or 32-bit mode.
Comment by russdill 3 days ago
Comment by chj 3 days ago
Comment by bonzini 3 days ago
They definitely were used back in the day, now the x87 isn't used much at all.
Comment by fithisux 3 days ago
Comment by kar1181 3 days ago
Comment by nyxthreepi 3 days ago