Intel 'underestimates error bounds by 1.3 QUINTILLION'
Not enough Pi makes FSIN instruction unreliable
Sharp-eyed and mathematically-savvy coder and blogger Bruce Dawson has spotted something interesting: the fsin instruction in x86/x64 chippery can produce a “worst-case error [of] 1.37 quintillion units in the last place”. That's not helpful because Intel's documentation suggests far smaller errors are the norm. And because a quintillion is a very big number.
Intel has acknowledged the issue and says “the documentation could explain more clearly the limitations inherent to the FSIN instruction, and we intend to do that in the next update of the manual. The same applies to other instructions: FCOS, FSINCOS, and FPTAN.”
Chipzilla says the problem happens for the following reasons:
“Accuracy problems may arise from the fact that the 66-bit finite approximation PI of the number ∏ (3.1415926…) stored in the x87 ROM and used for calculating the reduced argument (see below) of the trigonometric function approximations for FSIN, FCOS, etc. will be insufficient in some cases. As a result, the reduced argument can be inaccurate (or even very inaccurate) in some cases, leading to equally inaccurate results.”
Intel isn't saying this is a bug and Dawson agrees. His take on the situation is that “Intel’s implementation of fsinis clearly weak, but for compatibility reasons it probably can’t be changed so it can’t really be considered a bug at this point.”
“However the documentation is buggy,” he adds. “By claiming near-perfect accuracy across a huge domain and then only providing it in a tiny domain Intel has misled developers and caused them to make poor decisions.”
Hence Intel's decision to update the Intel 64 and IA-32 Architectures Software Developer’s Manual [PDF] at the next available opportunity.
Chipzilla says the most important change will be to modify Section 8.3.10 on Transcendental Instruction Accuracy. That section currently reads as follows:
“With the Pentium processor and later IA-32 processors, the worst case error on transcendental functions is less than 1 ulp when rounding to the nearest (even) and less than 1.5 ulps when rounding in other modes.”
Intel says it would be more accurate to instead say the following:
“With the Pentium processor and later IA-32 and Intel64 processors, the worst case error on transcendental functions, when applied to the reduced argument, is less than 1 ulp when rounding to the nearest (even) and less than 1.5 ulps when rounding in other modes.”
It doesn't appear that this problem has real-world implications. Dawson explains how it made some of his coding efforts less elegant, but there's no suggestion The Reg can find that planes will start falling out of the sky because of this issue.
Both Intel's and Dawson's posts go into considerable mathematical detail about the issue. If you've stronger numeracy and coding skills than your correspondent, feel free to point out how this issue may manifest. ®