Slashdot Mirror


Where Intel Processors Fail At Math (Again)

rastos1 writes: In a recent blog, software developer Bruce Dawson pointed out some issues with the way the FSIN instruction is described in the "Intel® 64 and IA-32 Architectures Software Developer's Manual," noting that the result of FSIN can be very inaccurate in some cases, if compared to the exact mathematical value of the sine function.

Dawson says, "I was shocked when I discovered this. Both the fsin instruction and Intel's documentation are hugely inaccurate, and the inaccurate documentation has led to poor decisions being made. ... Intel has known for years that these instructions are not as accurate as promised. They are now making updates to their documentation. Updating the instruction is not a realistic option."

Intel processors have had a problem with math in the past, too.

239 comments

  1. Intel Common Core i7 by Spy+Handler · · Score: 5, Funny

    with new maths

    1. Re:Intel Common Core i7 by Falos · · Score: 4, Funny

      1+1=3 for particularly large values of 1

    2. Re:Intel Common Core i7 by Anonymous Coward · · Score: 0

      >plagerizing a t-shirt

      >and doing it incorrectly

    3. Re:Intel Common Core i7 by Anonymous Coward · · Score: 0

      with new maths

      But can it compute 342 - 173 in base 8?

    4. Re: Intel Common Core i7 by Anonymous Coward · · Score: 0

      Calling bullshit. I was helping my daughter with her math homework the other night. One of the questions was: 8 + 5 = 10. True or false ? The lesson's answer was true. How can that be ? By somehow ignoring the extra 3.

      What kind of crap is that ?

    5. Re: Intel Common Core i7 by iggymanz · · Score: 4, Insightful

      what's the problem, 8 + 5 = 10, absolutely true in base 13

    6. Re: Intel Common Core i7 by Anonymous Coward · · Score: 3, Funny

      "'8 + 5 = 10' is True or false"

      Is True.

    7. Re: Intel Common Core i7 by sexconker · · Score: 2

      Thats true though. Using nearest integer rounding, 1.4 can be accurately represented as one and produce a sum of 2.8, which can be represented by three.

      In other words, 1+1=3 for sufficiently large values of 1.

      That would be 1.4 + 1.4 = 2.8. 2.8 could be then rounded to 3, at which point you could say 1.4 + 1.4 ~= 3,
      Anything beyond that, though, is horseshit.

    8. Re: Intel Common Core i7 by EdwinV · · Score: 0

      It's about an answer not having more significant digits than the input. It does require mentioning that the value are actually part of the set of real numbers. In which case you could also write it as:

      8*10^0 + 5*10^0 = 1*10^1

      Funny is that it was a big thing in high school, but that nobody cared in university.

    9. Re: Intel Common Core i7 by Anonymous Coward · · Score: 0

      Stick A: actual length 1.4; stick B: actual length 1.4; Combined: actual length 2.8
      1. Measure stick A, get a result of "1" (whole number precision)
      2. Measure stick B, get a result of "1" (whole number precision)
      3. Measure stick A stacked on stick B, get a result of "3" (whole number precision)

      1.+1.=3.

      However, I always thought the significant figure stuff was a sloppy shorthand (but useful in a pinch).

      What you really have above is 1±½ + 1±½ = 2±1. 2.8 (and 3) is within that range.

    10. Re: Intel Common Core i7 by Anonymous Coward · · Score: 0

      Wrong. 1 is always 1, not 1.4, not 2.8, just 1. You are a fucking idiot and you fail basic mathematics and comprehension.

    11. Re: Intel Common Core i7 by Dragonslicer · · Score: 0

      Calling bullshit. I was helping my daughter with her math homework the other night. One of the questions was: 8 + 5 = 10. True or false ? The lesson's answer was true. How can that be ? By somehow ignoring the extra 3.

      What kind of crap is that ?

      The kind of crap known as "significant figures".

    12. Re: Intel Common Core i7 by Anonymous Coward · · Score: 0

      Except even there it's not true and any teachers say that ought to be retrained.

      Significant figures are an approximation based upon the level of precision in the measurements you're using. The moment you have rounding errors and imprecision in the measurements you're no longer allowed to use an = sign as it's no longer equal, you have an inequality.

      In the science world that's OK because in practice the numbers are close enough that you can't tell the difference with any reliability, but it's complete non-mathematical bullshit and shouldn't ever be included in a math course.

    13. Re: Intel Common Core i7 by Kalium70 · · Score: 2

      The idea of significant figures is to avoid grossly overstating the precision of a measurement (or a calculation involving measurements). For example, if substance A is measured as 25 g with spring-type kitchen scale and substance B is measured as 10.3682 g with a digital analytical balance, it would be misleading to report the result as 35.3682 g.

      Taken out of context, without further instructions, the issue about 8 + 5 = 10 is unclear. As an instructor, I suspect that the intend was to see if the student can use the rule for significant figures when performing addition. A student who confuses the sigfig rules for addition and multiplication would conclude that since 8 and 5 each have 1 sigfig, the result should have 1 sigfig.

      A couple notes: Numbers with 0 on the right without any decimal point (e.g. 10, 2500) create an ambiguity with sigfigs as to whether those zeros are significant or not. Some authors put a bar over the last significant figure to clarify, but many do not. In fact, one of the textbooks I used --- I believe it was for trig --- changed its practice in a later addition regarding whether those zeros are significant or not.

    14. Re: Intel Common Core i7 by itzly · · Score: 1

      The kind of crap known as "significant figures".

      Which don't apply here, because this is math. And even if it were a physics problem, "10" still has the same number of significant digits as "13".

    15. Re: Intel Common Core i7 by Anonymous Coward · · Score: 0

      Integer values are assumed to have infinite significant figures.

    16. Re:Intel Common Core i7 by Calydor · · Score: 2

      > Writing a fancy word.

      > And doing it incorrectly.

      --
      -=This sig has nothing to do with my comment. Move along now=-
    17. Re:Intel Common Core i7 by michelcolman · · Score: 1

      Well, it's only wrong if you compare it to the exact mathematical value. But then you're just being pedantic.

    18. Re: Intel Common Core i7 by michelcolman · · Score: 2

      And even if you try to justify with significant digits, treating anything up to 14.99 as "equal" to 10 (relative error 50%?!) while the original numbers had relative errors of less than 20% shows a staggering lack of comprehension. These people should not be allowed to teach. One significant digit for 10 is way less precise than one significant digit on 5 or 8, use some common sense for crying out loud.

    19. Re: Intel Common Core i7 by gl4ss · · Score: 0

      more probable that the textbook just fudged something. if it was about significant figures, the question should have stated that (and used different notation, but I'm unsure of how the american schooling teaches on that. then again, it's possible that it was "biblical math on meth" where anything goes if it's for gods word).

      -lassi

      --
      world was created 5 seconds before this post as it is.
    20. Re: Intel Common Core i7 by michelcolman · · Score: 1

      By the same logic, 1023 - 1021 = 2.000 which I hope you'll agree is completely ridiculous. Just as ridiculous as saying 8+5=10, just the other way around.

    21. Re:Intel Common Core i7 by ganjadude · · Score: 1

      in MATH class, I would expect that to be the case. sciences, "close enough" is usually enough at the MS and HS level

      --
      have you seen my sig? there are many others like it but none that are the same
    22. Re: Intel Common Core i7 by sexconker · · Score: 1

      Except you can't equate those measurements.
      You can calculate the length of the two sticks stacked end-to-end as 1+1=2. You can measure it as 3.
      You can't equate those separate measurements because of the precision (and accuracy) issues inherent with measuring shit. You don't equate data to data for this very reason.

      If you know your upper and lower bounds then you absolutely should use them throughout the use of the data, as you showed with 1±½ + 1±½ = 2±1 .

    23. Re:Intel Common Core i7 by cwsumner · · Score: 1

      Well, it's only wrong if you compare it to the exact mathematical value. But then you're just being pedantic.

      If it doesn't matter to you, thats fine...
      But mother nature's punishments are quite severe.
      In the real world, be pedantic or be dead. 8-P

    24. Re: Intel Common Core i7 by toddestan · · Score: 1

      A couple notes: Numbers with 0 on the right without any decimal point (e.g. 10, 2500) create an ambiguity with sigfigs as to whether those zeros are significant or not. Some authors put a bar over the last significant figure to clarify, but many do not. In fact, one of the textbooks I used --- I believe it was for trig --- changed its practice in a later addition regarding whether those zeros are significant or not.

      I've never heard of that. I've always just used scientific notation to remove any ambiguity. Sure, 1 x 10^1 or 1.0 x 10^1 is a bit more cumbersome than 10, but at least it's clear.

    25. Re: Intel Common Core i7 by gzuckier · · Score: 1

      "plus or minus" is additive for addition or subtraction. therefore, (1 plus or minus .5) + (1 plus or minus .5) = 2 plus or minus 1.0. which covers 1.4+1.4=2.8 quite nicely.

      --
      Star Trek transporters are just 3d printers.
    26. Re:Intel Common Core i7 by Anonymous Coward · · Score: 0

      Woosh. He was refering to the summary, which also used the term "exact mathematical value" as if that's just one of the ways of determining its accuracy.

    27. Re: Intel Common Core i7 by lucmer44 · · Score: 1

      Ok insignificant figure. Give me 8 $100 bills then give me 3 $100 bills . I will give you 10 $100 and we will be even . Ok

    28. Re: Intel Common Core i7 by WolfWithoutAClause · · Score: 1

      Nope. It's:

      1±½ + 1±½ = 2±SQT(1/2)

      virtually always, because the ± notation is standard deviations, and standard deviations add in quadrature for statistical reasons.

      --

      -WolfWithoutAClause

      "Gravity is only a theory, not a fact!"
    29. Re: Intel Common Core i7 by Anonymous Coward · · Score: 0

      10 = 1 significant digit, 13 = 2 significant digits, so no, they are not the same. However, 10. (With the decimal point) does have two significant digits. What significant digits do is provide an easy way of describing the error in measured values. Note that it does not apply to defined values, just values with error.

      5 measured plus 8 measured is closest to 10 measured and shows that that was the degree of accuracy you were using to measure it ( in this case, would be like trying to measure a 5mm+ 8mm object with a ruler that only has 1 cm marks). Of course, using a finer measuring device would allow us to get a more accurate answer.

    30. Re:Intel Common Core i7 by Anonymous Coward · · Score: 0

      Common Core! LOLOL I hate common core!

  2. What this mean... by __aaclcg7560 · · Score: 4, Interesting

    I should get an AMD CPU and put the extra money towards a graphic card since GPUs do math extremely well in parallel.

    1. Re:What this mean... by Anonymous Coward · · Score: 1

      AMD put a GPU on their core for a reason, and that reason is floating point math. Only problem is that GPUs suck at dual precision math unless they are of the "commercial" kind...

    2. Re:What this mean... by Austerity+Empowers · · Score: 3, Insightful

      I would test that theory first. I have a hunch some GPUs are going to take shortcuts with math that someone like the guy who wrote this article will object to.

    3. Re:What this mean... by rasmusbr · · Score: 4, Insightful

      AMD CPU:s reportedly return exactly the same values as Intel CPU:s. I'm guessing they do so for compatibility reasons, so that any workarounds that software developers have implemented work as expected.

    4. Re:What this mean... by armanox · · Score: 1

      Get a processor that isn't crippled in the Floating Point department, if you really care that much.

      Intel sucks less then AMD does on that one (1/3 speed on Core i-series (1-3rd gen tested) vs 1/5 on FX). FP performance is much better on other types of processors - MIPS, Itanium, and POWER all show much better FP performance then x86-based processors (and SPARC runs faster then AMD).

      --
      I'm starting to think GNU is the problem with "GNU/Linux" these days.
    5. Re:What this mean... by K.+S.+Kyosuke · · Score: 2

      AMD CPU:s reportedly return exactly the same values as Intel CPU:s.

      What, for transcendental functions? That's both impractical and useless. No "compatiblity reasons" could potentially justify this. If you take the table maker's dilemma into consideration, there's absolutely no reason to standardize on specific implementations of transcendental function - there's no fundamental simple way of "doing them right". I don't believe that IEEE-754 even standardizes anything beyond basic operations, and for good reason; the thing you're proposing could easily lull numerical developers into a sense of false security from bugs: if your algorithms are hugely sensitive to small differences in rounding, perhaps something is wrong with them. Having a lot of FPUs produce binary-identical results often just masks problems, just like deterministic execution of concurrent programs can mask deeper flaws in those.

      --
      Ezekiel 23:20
    6. Re:What this mean... by the_humeister · · Score: 1

      Do you have any benchmarks to back that up? The ones I see from SPEC pretty much has Intel dominating in FP (compared to what few Itanium and POWER results there are).

    7. Re:What this mean... by Anonymous Coward · · Score: 0

      It was mentioned in a public talk by G.H. that the Windows NT 4 boot CD relied upon the broken behavior of an instruction on Pentium, so VIA had to mimic the broken behavior in order to be compatible. Do you want to be compatible or correct? Which is cheaper?

    8. Re:What this mean... by Anonymous Coward · · Score: 0

      And Lose the benchmarks...

    9. Re:What this mean... by numbertheo · · Score: 2

      Compatibility is the reason these instructions will never be fixed. AMD implemented correct behavior in the K5 family. It was then reverted to preserve compatibility.

    10. Re:What this mean... by hairyfeet · · Score: 1, Interesting

      That is what I've been telling folks here for years, the bang for the buck is still in the AMD camp and with their new GCN arch you can use the GPU for the heavy FP math which beats the FP in any CPU by a country mile so there really ain't any point in putting a bunch of heavy FP in the CPU anymore.

      As you can see the difference in number crunching between Intel and AMD in real world applications is crazy low, we are talking around 10%-15% max and that is if you go top o' the line Intel. Now I don't know about you but 15% boost isn't worth 300% markup in MY book. Oh and before anybody brings up benchmarks? As the guy in the video points out benchmarks have been rigged with Cinebench recently being caught putting "If CPU is AMD, tie boat anchor" code into their benchmark and this of course doesn't even mention the Intel Cripple Compiler which to this very day cripples any program compiled with it. At the shop I have done just like in the video and run real applications and compared, the result? Just as he found, the difference is so small you wouldn't be able to tell without breaking out a stopwatch...but your wallet knows, especially when you can get a hexacore for $105 and an octocore for $130.

      So if you are wanting just a good office style box I'd go with good number crunching something like A8 6600K APU kit for $210 after MIR or if you want a good entry level that you'll add your own GPU the fx4200 quad kit for $190 after MIR is a great price, but personally? I really like the FX6300 hexacore kit for $270 after MIR. Its a great price, the chip has plenty of power and headroom to OC if you are into that, and with turbocore its like getting 2 chips, a 3.5GHz hexa and a 4.1Ghz triple, its just a really solid chip.

      --
      ACs don't waste your time replying, your posts are never seen by me.
    11. Re:What this mean... by Aryden · · Score: 1

      This is not easily done when you look at enterprise issue equipment. Dell pushes intel over anything else, and that's what corps are getting thousands of.

    12. Re:What this mean... by beelsebob · · Score: 1

      Actually, GPUs do maths very inaccurately. They trade non-standard floating point implementations for speed.

    13. Re:What this mean... by Anonymous Coward · · Score: 0

      Or maybe his home computer would benefit most from the latest NEC vector processor. Those are much more energy efficient than before and hold that 1 to 1 relationship between memory bandwidth and floating point operations per second.

    14. Re:What this mean... by K.+S.+Kyosuke · · Score: 1

      Except that there's no "correct" or "incorrect" here, and you have exactly ZERO guarantee that libm on any machine will give you the same results, even if one manufacturer decides to play this silly game.

      --
      Ezekiel 23:20
    15. Re:What this mean... by K.+S.+Kyosuke · · Score: 2

      Wrong, at least the new cores are IEEE-754 compliant. AMD's GCN cores give exact results wherever exact results are guaranteed by the standard. Presumably nVidia is doing the same, otherwise they wouldn't be putting Teslas into supercomputers, now would they?

      --
      Ezekiel 23:20
    16. Re:What this mean... by sexconker · · Score: 4, Informative

      On the consumer side, AMD GPUs rock at double, while nVidia's suck.

    17. Re:What this mean... by lgw · · Score: 1

      How is there no "correct answer" to e.g cos(0.4) to some specified accuracy? It's right or it's not. Sure, there may be some undefined bits if the precision of the result exceeds the required accuracy, but to whatever accuracy was promised, the result is correct or not.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    18. Re:What this mean... by K.+S.+Kyosuke · · Score: 2

      There's no guarantee that calculating the value of a transcendental function to any fixed floating point precision would require any reasonably bounded amount of intermediate result digits. That's why FPUs never do that and instead they try to return a value as close as reasonably possible in a time as short as possible, without having substantial bad cases in either area. Yes, there's is a correct answer for cos(0.4). No, that's not the same statement. Calculating the function accurately for ALL input values instead of just for 0.4 takes an unpredictable amount of time. That's why no real-world hardware implementation is "correct", whereas primitive operations like addition and multiplication can be (and are) required to be correct (as in always giving the closest representable number to the precise result) because they're trivial in comparison.

      --
      Ezekiel 23:20
    19. Re:What this mean... by Anonymous Coward · · Score: 0

      On paper they are IEEE-754 compliant, however both AMD and nVidia GPUs often return incorrect results as they heat up.

      Usually it's caused by a minor defect in the silicon - everything will work right except for values running through the defective shader x% of the time.

      This usually doesn't matter when a vertex or pixel color is off by a bit, but can have huge implications for numerical processing.

    20. Re:What this mean... by K.+S.+Kyosuke · · Score: 1

      This claim of yours sounds extremely dubious to me, considering that the pro market versions of those cards even have ECC memory to ensure data integrity. Why should glitches in GPU executions units designed for HPC be any more acceptable than gliches in CPU execution units? If this problem of yours isn't imaginary, I'm sure you can provide us with citations of some real world cases.

      --
      Ezekiel 23:20
    21. Re:What this mean... by SuricouRaven · · Score: 1

      But generally only single-precision. GPUs are made for speed, not accuracy - gamers want their frame rate high, and don't care if a few pixels are shifted one space to the right.

    22. Re:What this mean... by ais523 · · Score: 4, Interesting

      GPUs used to take mathematical shortcuts all the time. More recently, though, with the scientific community starting to use GPU clusters for computation, the main GPU manufacturers have been adding mathematically precise circuitry (and may well use it by default, on the basis that there's no point in having both an accurate and an inaccurate codepath).

      --
      (1)DOCOMEFROM!2~.2'~#1WHILE:1<-"'?.1$.2'~'"':1/.1$.2'~#0"$#65535'"$"'"'&.1$.2'~'#0$#65535'"$#0'~#32767$#1"
    23. Re:What this mean... by ais523 · · Score: 1

      As a simple example, some games use a log of actions in order to store their save files; they replay the actions in order to reconstruct the state of the game. Even if those actions involve floating-point computations, the saves are still typically reproducible given the same executable (given that these games are normally written to avoid the use of uninitialized memory, and the like). If a processor starts handling floating-point differently, suddenly everyone's save files will be broken.

      --
      (1)DOCOMEFROM!2~.2'~#1WHILE:1<-"'?.1$.2'~'"':1/.1$.2'~#0"$#65535'"$"'"'&.1$.2'~'#0$#65535'"$#0'~#32767$#1"
    24. Re:What this mean... by Frobnicator · · Score: 5, Informative

      You might take a look at the article and at Intel's reply.

      The issue is in sine, cosine, and similar trig functions, with an actual error of 4e-21. That error scales, of course.

      Intel's documentation change basically says you should scale and reduce your numbers first before running the functions.

      Consider what that level of error precision means. If you were measuring with a meter stick, you could be measuring the radius of electron charge radii with several precision bits left over. If you were measuring the distance between the Sun and Proxima Centari, you could do it in millimeters and have accuracy to spare.

      Even though I've run HPC simulations most of my career, we've seldom needed more than around six decimal digits of precision; that's akin to variations of human hair width when working at the meter level. It's only a problem when someone throws some strange scale into the mix; we're running physics on the kg-m-s scale, and suddenly someone complains that their usage of microseconds and nanometers breaks the physics engine We answer simply, "Yes. Yes, it does." If you need to operate in both scales, you need a different library that handles it.

      Finally, even the actual article admits this is mostly about documentation. "The absolute error in the range I was looking at was fairly constant at about 4e-21, which is quite small. For many purposes this will not matter. ... for the domains where that matters the misleading documentation can easily be a problem." He then points out that a bunch of existing math libraries know about it. He mentions that high precision libraries have different solutions and always have. He mentions that most scientists who need it use better, high precision libraries. And he details that is really just the rough approximations done on the FPU that already plays fast-and-loose by switching between 53-bit and 63-bit floating point values that have been documented as being only good for that kind of approximation since the 1980s. Everybody who works professionally with floating point for any amount of time already knows the entire x86 family (including AMD and Intel) dating back to the original coprocessor are all terrible if you need high precision.

      --
      //TODO: Think of witty sig statement
    25. Re:What this mean... by Anonymous Coward · · Score: 0

      GPUs defective for pro market work ok for gamers.

    26. Re:What this mean... by thegarbz · · Score: 1

      The AC's claim is wrong. The inaccurate math in GPUs is nothing to do with defects and everything to do with performance tuning. A simple Google search will tell you why and how, and more importantly what you can expect especially if you're using the GPU for general purpose computing tasks.

      Mathworks published a long paper a while ago on what you can offload to a GPU accurately and what you shouldn't, and there's been many studies on the accuracy of the single precision floating point units in GPUs as well. The key problem is a heritage that involves exact numbers not being important. If a single pixel is slightly the wrong colour no one cares. This has lead to GPUs cutting corners where they can. I haven't looked into it but I'm sure the CUDA guides will tell you what you can and can't do accurately too.

      But don't expect CPU level of accuracy.

    27. Re:What this mean... by lgw · · Score: 1

      But you can declare, in your docs, what accuracy you promise, and then either succeed or fail at that. And that's the issue here, no? Intel fails at their own published accuracy.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    28. Re:What this mean... by ChrisMaple · · Score: 1

      Intel has superior process technology, which results in lower power dissipation. At $0.12/kWh 1 watt difference is $1 a year.

      --
      Contribute to civilization: ari.aynrand.org/donate
    29. Re:What this mean... by hairyfeet · · Score: 2, Interesting

      To steal a line from mel brooks "bullshit bullshit aaaannnnddd bullshit". if you look at the actual figures it would take you 18.9 years to break even when comparing an AMD OCTOcore to an 4770k...now are you REALLY gonna be using that 4770k 19 years from now? Didn't think so.

      Sorry but the actual math shows that is a bunch of bull, you can't even buy a pizza with the amount you'd "save" by going intel, and the amount you'd lose in price difference means you would NEVER break even.

      --
      ACs don't waste your time replying, your posts are never seen by me.
    30. Re:What this mean... by Anonymous Coward · · Score: 0

      Not sure about cheap GPUs, but the ones with the fancy features have double precision and do the math just fine. The problem is you need a lot of data for a GPU to beat a CPU (since a GPU core is much slower than a CPU core, but you have hundreds of GPU cores and only a few CPU cores), and even then it's only useful if your software supports it.

    31. Re:What this mean... by Anonymous Coward · · Score: 0

      Or you're like my cousin, and your datacenter only has 1.5megawatts of input because it's an old building. He told me not only is Intel faster for this mix of database, video compression, and science crunching, but it uses quite a bit less power. Their "low end" servers are about $60k each, and it's a Linux and Solaris shop. Solaris runs ZFS for the several petabytes of storage, and Linux runs the app servers.

      They're a research facility and power is actually free, they don't pay a dime. But they have a limit on how much power they can wire into the building without major work. They literally have racks of donated servers sitting unpowered.

      Last time they wanted to upgrade some servers, they spent $250k on different hardware to test, 2 Intel boxes and 2 AMD boxes. Intel won in every workload benchmark they had, while consuming less power. Once they found the server setup they liked, they ordered a rack full of them.

    32. Re: What this mean... by Anonymous Coward · · Score: 0

      Modern x86 fpu code use sse and avx instructions and never touch the old fpu. Using sse and avx gives you sane behavior like the sparc and power. Note that neither sparc nor power have any sine instructions.

      I am more surprised about the article. It writes about well known behavior and makes a big fuss about it.

    33. Re:What this mean... by Anonymous Coward · · Score: 0

      I bet AMD has the same issue. I think I know what causes this, an estimate function I use on GPUs for this kind of thing produces the same quirks. Can smooth it a bit by expanding the estimation out but then you lose the benefit of even using an estimation. It's a damn good estimation though as long as you watch the cracks.

    34. Re:What this mean... by Luckyo · · Score: 3, Informative

      To be fair, almost no consumers have any use for double. And commercial entities who do usually don't mind the extra zero at the end of GPU's cost, because to them, that's just expenses to be written off on their taxes.

    35. Re:What this mean... by suutar · · Score: 1

      Perhaps, but keep in mind the standard doesn't specify everything. According to TFA, this Intel issue with fsin does not technically violate the IEEE-754 standard on how sin() should be calculated.

    36. Re:What this mean... by Anonymous Coward · · Score: 0

      It's the parallel algorithms. Not all are suitable for GPUs. It's better to use the available libraries with already numerically stable algorithms than try to implement your own as there are lots of gotchas.

    37. Re:What this mean... by Anonymous Coward · · Score: 0

      How is there no "correct answer" to e.g cos(0.4) to some specified accuracy? It's right or it's not. Sure, there may be some undefined bits if the precision of the result exceeds the required accuracy, but to whatever accuracy was promised, the result is correct or not.

      Mathematically yes, but if you read the IEEE standard for floating point arithmetic cosine is outside the scope of the specification. If you read the ISO-C standard for floating point arithmetic cosine is defined but it clearly states that precision is implementation specific so if you write a C program that relies on a specific precision your code is non-portable. If you need it portable your code needs to implement its own cosine function.

      Addition, subtraction, multiplication, division and square root has defined precision. Some of the modulo-style library functions has defined defined precision given by them being defined in relation to basic arithmetic. Apart from that portable code that relies on floating point precision should be considered buggy.

    38. Re:What this mean... by Anonymous Coward · · Score: 0

      Well, the thing is that it doesn't even help to get perfect precision on the sine. In any real world application where it actually matters you will be screwed anyway.
      Its a bit like solving a buffer overrun by just always allocating more memory than you need. It doesn't address the real issue.
      Programming with floating point isn't trivial and if you don't know what you are doing you run into precision issues like this. Getting an extra bit of precision is only a temporary fix. In a real world application he has to re-design his code to make sure that angles that need high precision for arbitrary magnitude is stored differently.

    39. Re:What this mean... by Anonymous Coward · · Score: 0

      it doesn't sound like you know how tax write offs work.

    40. Re:What this mean... by Billly+Gates · · Score: 1

      Disagree.

      I just upgraded from a phenomII 2.6 ghz to an intel i7 4700k and couldn't believe the performance increase! Tomshardware.com and others do not lie when they show a 50% drop in performance. Some levels in Star Wars the Old Republic MMO which gave 20 fps now show 45 fps on the same video card.

      Per core AMD is 50% slower than Intel. The Phenom II still has higher IPC than the newer AMD processes per clock tick. Sad.

      Time to get with the times hairy and keep that AMD for office work. Real pc users intel i5s for most uses and they use a lot less electricity. The current FX should just be renamed PIV 2.0. It pains me to type this as I friended as a pc guy like myself who was a fan of AMD and ATI for years. But for non secretaries I just can not see a reason to use an AMD product these days. AMD screwed up selling their foundries to raise the share price. Intel does have an unfair advantage as a result and can make their chips smaller and more energy efficient.

    41. Re:What this mean... by Billly+Gates · · Score: 2

      In an office environment it adds up fast when you have 100 computers. Also you need a more expensive power supply by going with AMD systems. True the first i7 sucked 200 watts of power but the 4770k is really efficient.

    42. Re:What this mean... by sexconker · · Score: 1

      To be fair, almost no consumers have any use for double. And commercial entities who do usually don't mind the extra zero at the end of GPU's cost, because to them, that's just expenses to be written off on their taxes.

      Protip:
      Make $X in profit, owe some fraction $x in taxes.
      Write off some amount $Y, owe (x/X) * (X-Y) in taxes.
      x - (x/X) * (X-Y) = x - xX/X + xY/X = xY/X savings from writeoffs (assuming X isn't 0 - you had a profit, and assuming the writeoffs don't cross brackets).

      You only get a fraction of a writeoff as a reduction in your taxes. You can't make huge purchases and write them off as if they were free.

    43. Re:What this mean... by tibit · · Score: 1

      Calculating the function accurately for ALL input values instead of just for 0.4 takes an unpredictable amount of time.

      There's no reason to believe that this is true. The set of inputs is fixed - it's either 2^32 or 2^64 values, and not all of those bit patterns represent valid IEEE-754 "floats". So, the amount of time is finite, and the amount of memory is finite - it's a O(1) lookup, with memory cost proportional to the size of the domain. All you need for a completely accurate single precision FSIN is a 4GB table in RAM. An FPU implementation of course doesn't need such tables, but IMHO a table is a very reasonable starting point the everything else is to be compared to. Having implemented a few single precision sines in my time, I can fully attest that they return completely accurate single precision results, and that has been tested by iterating all possible input values. I don't think it'd be any different for a 64 bit FSIN implementation. Heck, if you've got a supercomputer time to borrow, you should be plenty able to quickly iterate those 2^64 inputs to verify that they produce fully accurate double precision outputs.

      --
      A successful API design takes a mixture of software design and pedagogy.
    44. Re:What this mean... by tibit · · Score: 1

      If it's in your house or an office, sure. If it's in a datacenter, you're on a fixed power and thermal budget and 1W of heat that you generate takes roughly another 1W to pull out, and you can't go over the power budget. So, running AMD in a data center that could just about fill its racks with Intel servers, will necessarily give you less processors and some empty, expensive space that you can't use. I can fully agree, though, that for home or office use, AMD is the way to go. I only wish hackintoshes ran AMD :)

      --
      A successful API design takes a mixture of software design and pedagogy.
    45. Re: What this mean... by Anonymous Coward · · Score: 0

      I remember seein this play out in a Seinfeld episode :)

    46. Re:What this mean... by Luckyo · · Score: 1

      I have filed tax write offs on my personal taxes before in relation to "earning related spending" related to a hobby of mine that actually earns me a reasonable sum on the side. You simply write it into the tax return papers, include the receipt and send it to the tax office.

      At least that's how it works here in Finland.

    47. Re:What this mean... by hairyfeet · · Score: 1

      Riiight, because buying 100+ computers at a time is what the average person does...obvious fanboi is obvious.

      --
      ACs don't waste your time replying, your posts are never seen by me.
    48. Re:What this mean... by Anonymous Coward · · Score: 0

      How might this understanding be used in eliptic curve cryptograhy?

        Suppose for a moment you could make an aproximation of the amount or error.

      Is it important that conversions are made from base 2?

  3. Say what? by ArcadeMan · · Score: 0

    Intel processors have had a problem with math in the past, too.

    O RLY?

    1. Re:Say what? by Anonymous Coward · · Score: 1

      This is /. if you're not aware of that, then what the hell are you doing here.

      http://lmgtfy.com/?q=pentium+math+bug

    2. Re:Say what? by ilsaloving · · Score: 2

      http://www.shsmedia.com/pentiu...

      Remember... "Don't Divide, Intel Inside"

    3. Re:Say what? by Anonymous Coward · · Score: 1

      Wait, there are Sacred Texts? Other than the vi man page?? Heresy! Burn him!

    4. Re:Say what? by Anonymous Coward · · Score: 0

      For God's sake, the summary even had a relevant link shit for brains. There is literally no excuse for the person not knowing about the bug that was being referenced.

    5. Re:Say what? by serviscope_minor · · Score: 4, Funny

      We are pentium of borg. Division is futile. You will be approximated.

      From what I remember it was the first revision of the Pentium 1 aka the Pentium 0.999998163849

      --
      SJW n. One who posts facts.
  4. Exact mathematical value isn't the ideal by i+kan+reed · · Score: 4, Insightful

    The main goal for Floating Point coprocessor sine calculations is to get a good enough result in a set number of cycles.

    Given that fully approximating sine takes about as many concrete operations as bits in the value, getting it exactly right isn't usually a trade off people want to make.

    There's a reason the C standard specifies that mathematical trig functions are platform dependent. If you want it precise, do it yourself to the level of precision you need.

    1. Re:Exact mathematical value isn't the ideal by TWX · · Score: 5, Insightful

      From what I gather, the problem is that Intel didn't acknowledge in documentation how poor the instruction was for scientific use though. This is fine for home and probably most general-purpose business use, but becomes a problem when it's more critical. If those that develop software that relies on sine functionality don't know about this then error in the results of their programs will actually matter.

      This won't matter to a gamer playing some first-person shooter.

      --
      Do not look into laser with remaining eye.
    2. Re:Exact mathematical value isn't the ideal by CastrTroy · · Score: 1

      Personally I think that floating point binary has it's advantages as it allows you to do lots of calculations really fast. However, with the number of financial and money processing applications out there, it's amazing that more languages don't have better support for decimal numbers. Even simple numbers like 0.1 can't be properly represented with floating point numbers. .Net has a native data type called decimal that does uses decimal floating point and is accurate to 28 or 29 digits, which makes it a great thing to use when dealing with money. I wish more languages would support something similar. Using binary floating point is a premature optimization that most applications don't need, and many programmers aren't aware of the side effects and the problems it could cause.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    3. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 1

      Hi again.

      I run into you every so often, and you have this habbit of giving a popular answer, that's completely wrong. This seems to be a habit with you, and I'd suggest actually reading the article before you post. Hubris seems to be a problem for you.

      The author of the article mentioned several times that the issue is one of documentation. It was quite well done, and he even mentioned it's not exactly a bug in the CPU since the expected output isn't well defined by another standard, but one of poor documentation.

      So Please mr I can read, read the article BEFORE you post. You seem to have a systemic problem with posting wrong information that looks right to people because you bring up the right answers to the wrong question.

    4. Re:Exact mathematical value isn't the ideal by Beck_Neard · · Score: 5, Informative

      The error is not small. If you read the article, on certain very reasonable inputs (not pathological at all), you can sometimes wind up with only _four_ bits being correct.

      Many scientific applications absolutely depend on fast hardware sine implementation. As you said, getting it exactly right isn't a tradeoff that people usually want to make.

      This has nothing to do with the C standard. Intel's own documentation was incorrect, making 'YMMV' completely moot.

      --
      A fool and his hard drive are soon parted.
    5. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 3, Interesting

      The problem isn't caused by the actual sine calculation, but in the preparatory range reduction, where the input value is mapped to the +-PI/2 interval. It appears that a "hard coded" approximate value of PI is the culprit, because the approximation is only accurate to 66 bits, but for the correct result, it would have to be correct to 128 bits. AMD at one point made processors which used the full precision value of PI and returned correct results for fsin(x). It broke software, so AMD "fixed" it by breaking it in microcode. AMD now uses the same less accurate approximation of PI and returns the exact same wrong values for fsin(x), even though they know it's wrong and already had the correct implementation. Processor cycles don't come into it.

    6. Re:Exact mathematical value isn't the ideal by Cassini2 · · Score: 2

      This is the #1 reason that banks use COBOL, and IBM makes Power processors with high-speed BCD arithmetic instructions.

    7. Re:Exact mathematical value isn't the ideal by Austerity+Empowers · · Score: 2

      Well they would if the shooter was designed to apply, say, the character rotation as a delta versus as an absolute. That operation uses a lot of sin/cos, most games are designed such that the angle is stored, the delta updates the angle, and the rotation reapplied on update. Versus rotating the vertices based on the delta from the update, and saving the result (until the next update). You do the latter too much and eventually your object looks like poo. Mathematically, it's perfectly acceptable, but practically wrong.

    8. Re:Exact mathematical value isn't the ideal by ledow · · Score: 4, Interesting

      Sorry, but anyone relying on this for scientific use where the answer matters should be using software that gives them the accuracy they want and - ultimately - are the only people who will realise whether the result is correct "enough" or not for their process.

      Some idiot researcher who expects Excel or an FPU instruction to be accurate for sin to more than 10 decimal places is going to crop up SO MANY anomalies in their data that they'll stick out like a sore thumb.

      Nobody serious would do this. Any serious calculation requires an error calculation to go with it. There's a reason that there are entire software suites and library for arbitrary precision arithmetic.

      I'm a maths graduate. I'll tell you now that I wouldn't rely on a FPU instruction to be anywhere near accurate. If I was doing anything serious, I'd be plugging into Maple, Matlab, Mathematica and similar who DO NOT rely on hardware instructions. And just because two numbers "add up" on the computer, that's FAR from a formal proof or even a value you could pass to an engineer.

      Nobody's doing that. That's why Intel have managed to "get away" with those instructions being like that for, what? Decades? If you want to rotate an object in 3D space for a game, you used to use the FPU. Now you use the GPU. And NEITHER are reliable except for where it really doesn't matter (i.e. whether you're at a bearing of 0.00001 degrees or 0.00002 degrees).

      Fuck, within a handful of base processor floating point instructions you can lose all accuracy if you're not careful.

    9. Re:Exact mathematical value isn't the ideal by camperdave · · Score: 1

      Pi? No wonder! Pi is wrong. They should be using Tau.

      --
      When our name is on the back of your car, we're behind you all the way!
    10. Re:Exact mathematical value isn't the ideal by K.+S.+Kyosuke · · Score: 1

      Given that fully approximating sine takes about as many concrete operations as bits in the value

      I'm not sure that this is even true - the way I understand it, nobody even knows how many operations it takes in the general case, if by "fully approximating sine" you mean "returning a result no more than half-ulp from the correct value for every valid input".

      --
      Ezekiel 23:20
    11. Re:Exact mathematical value isn't the ideal by Cassini2 · · Score: 1

      I recall working with numerical methods from about 40 years ago, and all of the calculations that required a call to sin were range reduced to the region of +/- pi/4 anyway. The reason is that the taylor series expansions for sine and cos are most accurate in the region of zero, and for values in excess of pi/4, it is more accurate to do a transformation and implement a different call.

      It is likely that the serious numerical code already handle this condition inside the internal algorithms.

    12. Re:Exact mathematical value isn't the ideal by UnknownSoldier · · Score: 1

      > AMD at one point made processors which used the full precision value of PI and returned correct results for fsin(x). It broke software, so AMD "fixed" it by breaking it in microcode.

      Do you have a link for that please? Thanks.

    13. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      and yet (even tho this problem isn't new), NOT ONE G4M3R HAS EVAR COMPLAINED ABOUT IT!

    14. Re:Exact mathematical value isn't the ideal by BringsApples · · Score: 1

      I know nothing of processing, at least at this level. You often post good stuff here. Can you explain why computer processors cannot do the functions in the same way that calculators do? Maybe I'm asking the question in the wrong way, but you know what I mean (I hope).

      --
      Politics; n. : A religion whereby man is god.
    15. Re:Exact mathematical value isn't the ideal by Shinobi · · Score: 1

      "I'll tell you now that I wouldn't rely on a FPU instruction to be anywhere near accurate. If I was doing anything serious, I'd be plugging into Maple, Matlab, Mathematica and similar who DO NOT rely on hardware instructions. And just because two numbers "add up" on the computer, that's FAR from a formal proof or even a value you could pass to an engineer."

      That depends on what kind of FPU you are using. The Power 6/Power 7 Decimal Floating Point unit is sufficiently accurate for engineering use

    16. Re:Exact mathematical value isn't the ideal by adonoman · · Score: 2
      If you are doing any floating point calculations and assuming exact results, you're going to get yourself in trouble. The issue is that FSIN is less accurate than advertised, not that it's not 100% accurate.

      Anyone who deals with floating point math very quickly learns about error accumulation and how to deal with it.

    17. Re:Exact mathematical value isn't the ideal by ericloewe · · Score: 1

      So, manually subtract a more accurate value of pi from the argument and pass that to fsin()? Sounds trivial enough for anyone really concerned about accuracy and speed.

    18. Re:Exact mathematical value isn't the ideal by loufoque · · Score: 1

      IEEE754, however, does require the standard C 'sin' function to be correctly rounded (i.e. as exact as it can be given the limited amount of bits).

    19. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      That's because we're too busy laughing at character models spazzing out.

    20. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      It was mentioned in the Reddit thread on the topic.

    21. Re:Exact mathematical value isn't the ideal by vakuona · · Score: 1

      They can. But they make tradeoffs because computers are expected to do the same calculations much faster (or were in the past, and now have to keep making the same mistakes for compatibility reasons).

    22. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      There are a few ways to store angles of an object:
      - angles around the axis, you would record these at modulo 2*pi. You wouldn't accumulate error this way. But using angles around axis causes gimble locks, eeeeuw.
      - Store angles in a matrix, this causes accumulation of errors like you describe, you can normalise a matrix once in a while to reset the accumulation, but if you don't do this often enough you will get snapping behaviour. Storing angles in a matrix is not very useful though.
      - Quaternion, this stores an angle like a vector, no accumulation of errors, and stored in a useful way (can interpolate between two angles for example).

      Guess which of these three are most often used in games these days.

    23. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      This is flat-out wrong (of course, this being slashdot, it's moderated +5 Informative)

      The FSIN instruction is actually accurate to better (quite a bit better) than one ULP ... for the first quadrant. So they're not actually saving any CPU cycles by this "approximation".

      The problem is that for the other quadrants, the argument is reflected by an insufficiently accurate approximation to pi. Or rather, the problem is that the documentation lies about it.

      Once you're aware of the actual behaviour, it's fairly straightforward to work around: just implement the symmetries in software. And that's exactly what glibc etc have done. But there's a lot of old code out there which uses FSIN directly and which will have been based upon the (bogus) published accuracy figures.

      And the reason why the standards state that transcendental functions are implementation dependent isn't for performance per se, it's because of the "table maker's dilemma".

      In short, there are cases where getting a result which is actually correct to even 1 binary place may require calculating to a million places. E.g. even knowing that a result is between 0.14999....0 and 0.15000...1 (where ... corresponds to a million digits) doesn't tell you whether the correctly-rounded value is 0.1 or 0.2.

    24. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      Decimal numbers are less useful than you think. It is sort useful when you are just adding and subtracting numbers, which a double ledger bookkeeping application does. I think that is where the usefulness stops. In fact in the Netherlands for example we need to round numbers to whole Euros before filling in company tax forms, the amount of inaccuracy is staggering, needing to include a tax rounding error on my profit and loss sheet for this very purpose.

      Even just calculating VAT already involves multiplication and you start rounding from this point on.

      Although trading application will receive market data and send orders in decimal floating point format, internally the trading application will do its calculations in floating point. In fact products traded on USA exchanges are often traded with binary fractions of a dollar (although as I said, oddly represented as decimal floating point).

    25. Re:Exact mathematical value isn't the ideal by K.+S.+Kyosuke · · Score: 1

      Where? There's no such requirement. There's only recommendations.

      --
      Ezekiel 23:20
    26. Re:Exact mathematical value isn't the ideal by SuricouRaven · · Score: 1

      The x86 instruction set has BCD instructions too. I don't think they see much use now - processors are fast enough that you can do decimal math without them. But they were needed at the time.

    27. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      Lolwut?

      Decimal Floating point is a financial thing. It's no wonder IBM has it. Reality isn't decimal, so base-10 rounding errors are just as bad as base-16 rounding errors. And I'm not even going to assume that IBM has implemented quite as much functions in decimal floating point. Bessel? Right.

    28. Re:Exact mathematical value isn't the ideal by duck_rifted · · Score: 1

      Don't be so quick to make assumptions. Researchers know their field, and managers seldom know that. People are rushed to productivity, and mistakes like that are certainly possible. "Why are you writing your own procedure for that? Why reinvent the wheel?" So, it is possible that researchers have been impacted.

      I doubt it's a huge issue anyway. You talk about serious researchers, but anybody serious know there's such a thing as significant digits. Physical calculations have limited precision, and scientists tend to work in units appropriate to scale. So, researchers aren't a worry but for a totally different reason than you cite.

      I'd worry more about lazy professor's assistants grading papers with flawed tools than actual research or designs being impacted by this because there's no telling what whacky precision weirdness people might be asked to do while learning this stuff.

      Case in point, I've seen Physics courses where precision didn't even get discussed in the classroom. It was left for the lab. If an undergrad work study assistant doesn't understand computer science well enough to consider the impact of instruction sets, then it can impact grades, ergo careers. That and the potential for politicians or understandably uninformed CEOs, accountants, and other office staff to make mistakes thanks to this are probably the biggest things we need to worry about.

    29. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      You're falling into a nasty human nature trap of self importance there.

      You claim that anybody without the same math degree as you must be a fool because they do not know everything you know. Here's a hint: they aren't idiots and you don't know everything that they know either. Does that make you a fool to them in their eyes? Or just some arrogant tool?

      Instead of insulting people (let's call them natural sciences grad students) perhaps try to educate them about the nature of floating point calculations by pointing them to documents like this:

      http://docs.oracle.com/cd/E199...

      Calling them idiots indicates that you don't know the difference between ignorance and stupidity. Ignorance can be cured by education and the ignorant person may in fact be much smarter than you are, they just need to be taught about this particular trivia.

      And the best way is to open up an Excel spreadsheet and demonstrate to them a particular calculation with a simple analytical answer where Excel gets it badly wrong. Even if they learn nothing about the underlying FPU and all they come away from it with is "Excel sucks use Matlab instead" it's a win. Show them the sore thumb. Write a blog post about it and you could become famous like the OP.

      Perhaps XKCD already has one.

      I applaud the fine examples and explanation in your post, the manner of delivery could sure use some work though. (there's an oblig. XKCD for that too)

    30. Re:Exact mathematical value isn't the ideal by SuiteSisterMary · · Score: 1

      They should be using Tau.

      It really would be for the greater good.

      --
      Vintage computer games and RPG books available. Email me if you're interested.
    31. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      Any serious calculation requires an error calculation to go with it. There's a reason that there are entire software suites and library for arbitrary precision arithmetic.

      That depends what you mean by serious calculations. Molecular dynamics simulations are being used successfully for things like medical drug discovery. But in molecular dynamics the big challenge is often to be sure that you've sampled enough of the conformational space to get meaningful averages. You need to run as fast/long as possible (arbitrary precision is epic slow) and sometimes you even deliberately add additional randomness to your trajectories - either explicitly or by varying the temperature in weird ways with something like replica exchange. Done right, the results from molecular dynamics simulations are meaningful and useful but you're not like "OK, we've run the simulation for 100 nanoseconds and the coordinates of this atom here are guaranteed accurate to within 3 angstroms." On the other hand, if the floating point errors are accumulating in a way that systematically biases the final averages - well, it would really be nice to know about that.

    32. Re:Exact mathematical value isn't the ideal by ChrisMaple · · Score: 2

      The problem is with sin( near pi ). Range reduction subtracts pi, and the value of pi doesn't have enough bits in the Intel fsin instruction. In gaming, nothing is going to rotate pi radians between updates, so this deficiency won't show up in gaming applications where incremental rotates are used.

      --
      Contribute to civilization: ari.aynrand.org/donate
    33. Re:Exact mathematical value isn't the ideal by Noah+Haders · · Score: 1

      burrrrrnnn

    34. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      You apparently cannot reed.

    35. Re:Exact mathematical value isn't the ideal by gnasher719 · · Score: 2

      I recall working with numerical methods from about 40 years ago, and all of the calculations that required a call to sin were range reduced to the region of +/- pi/4 anyway. The reason is that the taylor series expansions for sine and cos are most accurate in the region of zero, and for values in excess of pi/4, it is more accurate to do a transformation and implement a different call.

      If you read the article, that's what the Intel processor does. Instead of an infinitely precise value of pi, it uses pi rounded to 66 bits (which is 13 bits more than normal double precision arithmetic would use, and 2 bits more than extended precision arithmetic would use). So all these people getting all excited about an error in Intel's FPU most likely wouldn't be capable of implementing the sine function anywhere near as precise as FSIN does.

    36. Re:Exact mathematical value isn't the ideal by EETech1 · · Score: 1

      www.smbc-comics.com/?id=2999

    37. Re:Exact mathematical value isn't the ideal by Bruce+Dawson · · Score: 1

      > Any serious calculation requires an error calculation to go with it.

      Sure. That sounds good. And in order to make that error calculation you need to consult the documentation to know how accurate the instructions you are using are. Let me see -- Intel says that fsin is accurate to one ULP. That's sufficient. Error calculation done.

      That's why the inaccuracies in their documentation matters.

      > I'll tell you now that I wouldn't rely on a FPU instruction to be anywhere near accurate.

      Really. Well that seems foolish. As required by the IEEE standard the x87 FPU supplies correctly rounded results for add, subtract, multiply, divide, and square root. At double and long-double precision you can't do better. Those can be composed into higher-level functions with well defined accuracy if you know what you are doing.

      It's funny that there is one group of people asking when this tiny error could even matter (http://randomascii.wordpress.com/2014/10/09/intel-underestimates-error-bounds-by-1-3-quintillion/#comment-13638) and another group saying that even without this error the precision is insufficient. You guys should talk.

    38. Re:Exact mathematical value isn't the ideal by gnasher719 · · Score: 1

      I'm not sure that this is even true - the way I understand it, nobody even knows how many operations it takes in the general case, if by "fully approximating sine" you mean "returning a result no more than half-ulp from the correct value for every valid input".

      That's actually solved (for double precision). Google for crlibm.

    39. Re:Exact mathematical value isn't the ideal by gnasher719 · · Score: 1

      You apparently cannot reed.

      That makes me wonder if you made a very clever joke, or weather you can't right.

    40. Re:Exact mathematical value isn't the ideal by gnasher719 · · Score: 1

      I know nothing of processing, at least at this level. You often post good stuff here. Can you explain why computer processors cannot do the functions in the same way that calculators do? Maybe I'm asking the question in the wrong way, but you know what I mean (I hope).

      The whole problem is that you may have been reading an article written by a blogger who made some rather idiotic assumptions about the precision of the sine function.

      Here's the reality: If you look at posts on stackoverflow.com you will find to your horror that many "programmers" apparently don't even know the difference between "float" and "double" and do calculations with six digits precision instead of 15, out of stupidity. Intel processors also support "extended precision" which gives you >18 digits precision if you use long double; fact is that during the PowerPC era Macs didn't support this, and nobody complained! The blogger actually complains that the FSIN instruction doesn't use an infinitely precise value of pi, but one that is rounded to 66 bit (2 bits more than extended precision). Fact is that FSIN uses two bits more than you could use if you tried to implement the sine function yourself in extended precision, so 99.99% of all people trying to implement this themselves would end up with an implementation that is worse than FSIN.

    41. Re:Exact mathematical value isn't the ideal by gnasher719 · · Score: 1

      The FSIN instruction is actually accurate to better (quite a bit better) than one ULP ... for the first quadrant. So they're not actually saving any CPU cycles by this "approximation".

      If you calculate y = FSIN (x), then within the first quadrant y is within one ULP from the exact value sin (x). However, for _all_ values x, y will be equal to sin (x') for some number x' that is within one ULP from x.

    42. Re:Exact mathematical value isn't the ideal by Vellmont · · Score: 1

      Hello,

      As a maths grad working with computers, you probably have to rely on documentation for any tool you're using, right? The article is claiming the documentation is inaccurate. If we can't rely on the documentation to be accurate, what can we rely on? Maple, Matlab, and Mathematica ALSO rely on the documentation being accurate. If they told you one precision, and you got another, might you not complain, and want that information widely spread so they're more apt to fix it?

      Also, I've noticed that Math people seem to have a bias for perfect answers. That's rarely, if ever the case in science. Science is often "good enough", not perfect. If the processor gives a "good enough" answer for what you're trying to calculate, then so be it. Not everyone needs the exact answer as you might need in mathematics.

      --
      AccountKiller
    43. Re:Exact mathematical value isn't the ideal by whit3 · · Score: 2

      The error is not small. If you read the article, on certain very reasonable inputs (not pathological at all), you can sometimes wind up with only _four_ bits being correct.

      The issue here, is that any computed sine value outside the first quadrant (input values 0 to pi/2) is computed by reducing the input quantity. The function is periodic, so adding or subtracting any multiple of the period (2 pi) from the input value, is mathematically valid. So, the error is made to be small for each value in that first quadrant, and the Intel documentation correctly quotes the errors there. The 'reducing the input quantity' step, however, doesn't use extended precision arithmetic, so the (add 2pi) step adds roundoff error (and that roundoff error generates output errors).

      Thus, the sin(1.14159) calculation, with a 10-decimal-place accurate representation of that number (1.14159), gives roughly a 10-decimal-place determination of the proper sine value. But, the sin(1.14159 x 10**9) will get LOTS of leading digits truncated when you scale the input, and can only determine a 1-decimal-place scaled input value, thus only a 1-decimal-place sine.

      And, if the hypothetical, perfect, sine value has leading zeroes, it looks terrible as a 'percent error'. Any roundofff error at all, in a sin(3.14159265358979323846264338...) calculation, will get a divide-by-zero boost when you calculate a percent error. The absolute error, though, is just what is to be expected from roundoff error in a step that takes the remainder after dividing by (2pi + roundoff_error(2pi) ).

    44. Re:Exact mathematical value isn't the ideal by itzly · · Score: 1

      BCD makes no sense in the real world. It's much easier to process everything in binary, and only do the decimal/binary conversion at the input and output, which is going to be bandwidth-limited anyway.

    45. Re:Exact mathematical value isn't the ideal by Lisandro · · Score: 1

      Some idiot researcher who expects Excel or an FPU instruction to be accurate for sin to more than 10 decimal places is going to crop up SO MANY anomalies in their data that they'll stick out like a sore thumb.

      Unless the processor's documentation explicitly promises that accuracy.

    46. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      Quote: "The absolute error in the range I was looking at was fairly constant at about 4e-21"

      Sorry, but for most applications this does not matter at all.

    47. Re:Exact mathematical value isn't the ideal by Lisandro · · Score: 1

      Ditto. Not only that, i'm amazed by the number of programmers who don't properly understand floating point arithmetic either.

      A long time ago i had to write a C/C++ fixed-point arithmetic library for a (major) telecom company because their billing processes would routinely output totals with cent errors; over a full year these added up to a significant ammount of money, a-la-Superman III. No one even had a clue of why their processes failed.

    48. Re:Exact mathematical value isn't the ideal by itzly · · Score: 1

      Strange. I would expect standard double precision float to be more than sufficient for any reasonable real-world financial calculation.

    49. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      Most of us lack the time or attention span to fully read every article.

    50. Re: Exact mathematical value isn't the ideal by Lisandro · · Score: 1

      They aren't. When you start adding up a lot of cents you end up, invariably, with rounding errors. FPs are not intended for this task.

      The way they intended to deal with this issue back then was to round down results to x decimals, just to make sure the clients weren't charged extra. And even that wasn't enough.

    51. Re:Exact mathematical value isn't the ideal by NemoinSpace · · Score: 0

      Wow, that was the nicest criticism of someone's comments I've seen in awhile. Still, I have to go with the parent. He's not trying to prove he's smarter than everyone else. Rather, he reasons anyone that comes near FP in their work is expected to at least take it into account. In engineering, like traffic court, ignorance of the law is no excuse.
      The crux of the issue is people claiming expertise in their field where none exists. F@#$%ng moron would be more precise.

    52. Re:Exact mathematical value isn't the ideal by TWX · · Score: 1

      I'm not the person that you replied to, but back when FDIV was discovered in the first-generation Pentiums, it was discovered because astrophysics researchers were getting results that seemed off, and when they re-ran their sims on 486s and other architectures they got different results.

      That means that you have to test your stuff experimentally. Different architectures, different simulation and math programs. That sucks; it takes time to reimplement in a different simulator or math program and it costs money in both software and hardware, but those are the breaks when relying on others.

      --
      Do not look into laser with remaining eye.
    53. Re:Exact mathematical value isn't the ideal by jbengt · · Score: 1

      And TFA notes that some modern compilers do just that.

    54. Re:Exact mathematical value isn't the ideal by jbengt · · Score: 1

      The whole problem is that you may have been reading an article written by a blogger who made some rather idiotic assumptions about the precision of the sine function.

      The only incorrect assumption the blogger made was that Intel's documentation stating the precision of their implementation of the sine function was correct.

    55. Re:Exact mathematical value isn't the ideal by Anonymous Coward · · Score: 0

      Engineering: Trust but verify.

      Measure twice, cut once.

      Etc, etc, etc...

    56. Re:Exact mathematical value isn't the ideal by Bruce+Dawson · · Score: 1

      Can you give an example of when the fsin instruction's accuracy would be insufficient? A few people have asked and a clear answer would be quite helpful.

    57. Re:Exact mathematical value isn't the ideal by Bruce+Dawson · · Score: 1

      But the parent you refer to (this comment's great grandparent?) says "Any serious calculation requires an error calculation to go with it." Sure. I can agree with that.

      And that's the whole point of the article. If somebody does an error calculation based on Intel's documentation then they will have an incorrect error calculation -- in some cases grossly incorrect. So the claim that an error calculation is needed actually *supports* the article (mine, BTW), while arguing against it.

      I think ledow is violently agreeing with my article, perhaps without realizing it.

    58. Re:Exact mathematical value isn't the ideal by david_thornley · · Score: 1

      BCD makes sense for financial calculations. The idea is not necessarily to get the mathematically correct answer, but to get the same answer as other methods (like paper and pencil). For any other sort of calculation, binary is going to be the best.

      For finance, you will be working with numbers that are normally finite numbers of digits in decimal, and mostly not in binary, so you can make exact computations in BCD and not binary floating point. You need to have the same rounding as pencil and paper when you have to round, which means decimal digits.

      If you don't have strict decimals, your best bet is to deal with integral numbers of cents, not dollars with fractional cents, and to watch out for percentages that don't come out even in binary.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    59. Re:Exact mathematical value isn't the ideal by david_thornley · · Score: 1

      Seems to me that finding the sine of 1.14159E9 is futile in the first place, because that's 1,141,59x,xxx where x stands for an insignificant or unknown digit. Since the value can be all over its range for a variation of less than 2, you couldn't really talk about the sine of something where the unit's digit was insignificant.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    60. Re:Exact mathematical value isn't the ideal by strikethree · · Score: 1

      I'm a maths graduate. I'll tell you now that I wouldn't rely on a FPU instruction to be anywhere near accurate. If I was doing anything serious, I'd be plugging into Maple, Matlab, Mathematica and similar who DO NOT rely on hardware instructions.

      I am a terrorist. I am designing the detonator for a bomb with a nuclear yield. I absolutely need those instructions to be in hardware so my calculations can finish before the heat death of the universe. Your software math programs fail at that.

      --
      "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen
    61. Re:Exact mathematical value isn't the ideal by ledow · · Score: 1

      One instruction does not necessarily cause a problem. However, errors build and multiply. Anyone serious about their calculations also calculates the potential error as they go. If an answer doesn't have a "+/- X%" attached to it, then it should have.

      As such, for most uses a tiny few decimal places out right past the decimal point aren't a factor in a single calculation. But the error will build if you're not careful. Might not make much difference to the length of a matchstick in a matchstick factory, but will surely hurt when you're laying the foundations for your skyscraper that ends up weighing 10% more than you thought.

      As such, fsin is fine for games, 3D visualistions, home calculations, etc. But that small error will build with every transform, every manipulation of the data, etc. and if that matters to you, then it's going to hurt. Floating-point, especially, is something to be handled with care. It affects currency formats (believe it or not) and calculations with an inherent error already. Integer calculations? Most of those are perfectly safe. But floating-point errors build up. It might not make much of a difference at first, but with 2 BILLION instructions per second on each chip, you're talking one hell of a mess on anything that needs to be accurate (which is where mistakes tend to matter most).

  5. Unused instruction by AqD · · Score: 1

    It’s hidden on 64-bit Linux (my desktop Linux machine is 64-bit) and with VC++ because they both have a hand-written sin() function that doesn’t use fsin.

    No surprise here since they keep adding new instructions and often nobody bothered to use them except during game/multimedia optimization, where precision is the least concern.

    1. Re:Unused instruction by Anonymous Coward · · Score: 1

      No, FSIN is part of the old 8087 instruction set which is being deprecated in favour of SSE, particularly on 64bits mode. The SSE instruction set (and corresponding registers) don't have any native FSIN instruction. Being double precision (64bits) instead of long double (80bits), SSE calculations can be even less precise than what the old 8087 did more than 30 years ago.

      Intel never claimed that fsin() and other transcendental instructions are exact for all arguments, because, well, PI is a transcendental number, and reducing any IEEE double extended argument to +/-PI requires a lot of calculations for arguably little use.

    2. Re:Unused instruction by Anonymous Coward · · Score: 0

      Intel never claimed that fsin() and other transcendental instructions are exact for all arguments, because, well, PI is a transcendental number, and reducing any IEEE double extended argument to +/-PI requires a lot of calculations for arguably little use.

      What are you talking about? Intel's claims are precisely the problem: they claims that it's accurate up to the last digit. It is not.

  6. Bad intel by Tablizer · · Score: 3, Funny

    We already know it's a sin to eat pi.

    1. Re:Bad intel by wonkey_monkey · · Score: 2

      I ought to tan your hide, cos that was terrible.

      Stop going off on tangents.

      --
      systemd is Roko's Basilisk.
  7. Ok, a quick peek by Anonymous Coward · · Score: 0

    A quick peek at Mr. Dawsons twitter shows a passing attempt at supporting Game Journalists and their corruptions.

    Given that this happens, he's making a mountain out of a mole hill for political reasons.

  8. The 4 year old Intel Developer thread on the FSIN by Anonymous Coward · · Score: 0

    https://software.intel.com/en-us/forums/topic/289702

    Discusses the discrepancy in the FSIN function back in 2010.

    Regards -

  9. A-HA! by Anonymous Coward · · Score: 0

    Now I finally know what the saying "Love the sinner, hate FSIN" means.

  10. First Post! YES!! by Anonymous Coward · · Score: 0

    At least it was first according to my Intel processor.

  11. My workaround by olsmeister · · Score: 1

    Just use SQRT(1-FCOS^2)

    1. Re:My workaround by Anonymous Coward · · Score: 0

      The positive or the negative root?

    2. Re:My workaround by ArcadeMan · · Score: 1

      What do you mean? An African or European SQRT?

    3. Re:My workaround by TeknoHog · · Score: 1

      An African or a European SQRT(-1)? i don't know that!

      --
      Escher was the first MC and Giger invented the HR department.
    4. Re:My workaround by lgw · · Score: 4, Funny

      The positive or the negative root?

      I just use the average of the two, for predictable output.

      --
      Socialism: a lie told by totalitarians and believed by fools.
  12. Read TFA. Not even a close approximation, and docu by raymorris · · Score: 5, Informative

    The documentation says that the result will be correct until the last decimal place. So if the CPU says the answer is:

    0.123 456 789 123 456 789

    You have have a close approximation, accurate to the 17th decimal place, according to the documentation.
    The problem is, the correct answer may be:
    0.123 444 555 666 777 888

    The documentation says it's fairly precise. In truth, it's only good to the fourth decimal place in some cases, whereas Intel documented the function to be accurate to 66 bits or so.

  13. Inaccurate headline by Loki_1929 · · Score: 4, Informative

    The headline is quite inaccurate. The processors are doing what they're designed to do; approximate the results of certain operations to a "good enough" value to achieve an optimal result:work ratio. Sort of like how the NFL measures first-downs with a stick, a chain, and some eyeballs rather than bringing in a research team armed with scanning electron microscopes to tell us how many Planck lengths short of the first down they were.

    This is a documentation failure. They're fixing the documentation. For anyone who would actually care about perfect accuracy in these kinds of operations, there are any number of different solutions to achieve the desired, more accurate result. The headline and the summary make it seem as though there's a problem with the processor which is simply incorrect.

    --
    -- "Government is the great fiction through which everybody endeavors to live at the expense of everybody else."
    1. Re:Inaccurate headline by SpankiMonki · · Score: 1

      For anyone who would actually care about perfect accuracy in these kinds of operations, there are any number of different solutions to achieve the desired, more accurate result.

      ...like using an AMD K5?

      ;-)

    2. Re:Inaccurate headline by fermion · · Score: 1

      The headline is accurate. For instance, if you have a student calculate a value and they give you 10 decimal places, and only four decimal places are correct, then that student has failed at math. The most fundamental error one can make when reporting values in math is reporting more accuracy than is justified by the computational method. The Intel manual says the all digits reported, except for the last, is accurate. Since this is not the case, Intel has failed at math. Even with the change in the manual, if the chip continues to report inaccurate digits, Intel is still failing at math. The only difference now is that Intel admits that it is failing, which is one step forward. To use you analogy, the NFL is not guaranteeing that the actual ten yards have been met. All they are saying is the displacement is sufficient to justify the nominal requirements for a first down. The do not , for instance, say that a play needs 3 yards, 1 foot, 6 inches, and 13 mils to reach a first down. But Intel does pretend it know the down to that level of accuracy.

      --
      "She's a scientist and a lesbian. She's not going to let it slide." Orphan Black
    3. Re:Inaccurate headline by Ichijo · · Score: 1

      Unfortunately, IEEE 754 doesn't provide a way to indicate the level of precision (number of significant figures) of the answer.

      --
      Any sufficiently unpopular but cohesive argument is indistinguishable from trolling.
    4. Re:Inaccurate headline by Anonymous Coward · · Score: 0

      For anyone who would actually care about perfect accuracy in these kinds of operations, there are any number of different solutions to achieve the desired, more accurate result.

      ...like using an AMD K5?

      ;-)

      Nope. Check the abstract words there chum,

      "The algorithms for the transcendental functions use table-driven reductions followed by polynomial approximations. Multiprecision arithmetic operations are used when necessary to maintain sufficient accuracy and to ensure that the transcendental functions have a maximum error of one unit in the last place."

      That's almost exactly what the Intel documentation claims for their processor.

    5. Re:Inaccurate headline by Anonymous Coward · · Score: 0

      > The headline and the summary make it seem as though there's a problem with the processor which is simply incorrect.

      The reason the documentation is defective is because the hardware didn't do what it was designed to do. Now, they can't fix it at this point because people are used to the way it works now, but that doesn't make this originally a documentation problem. This means that the hardware wasn't able to live up to the standards it was designed for.

    6. Re:Inaccurate headline by Anonymous Coward · · Score: 0

      It's Quantum Mechanics, man! The NFL measures first-downs with a stick because electron microscopes change the result by measuring it!

    7. Re:Inaccurate headline by strikethree · · Score: 1

      This is a documentation failure. They're fixing the documentation. For anyone who would actually care about perfect accuracy in these kinds of operations, there are any number of different solutions to achieve the desired, more accurate result.

      http://hardware.slashdot.org/c... argues directly against your dismissive attitude.

      --
      "Someone needs to talk to the tree of liberty about its ghoulish drinking problem." by ohnocitizen
  14. Bah, so what? by Anonymous Coward · · Score: 0

    Google docs is filled with rounding errors leading to fun situations where calculated dollar amounts are changed by a penny depending on where the original was calculated.

    999.99$ can become 1000.00$.

    1. Re:Bah, so what? by Tablizer · · Score: 1

      One of the reasons COBOL remains popular. (You can get proper monetary values from floating point systems if you are careful, but it's not the ideal tool.)

  15. Re:did you even bother looking it up? by Anonymous Coward · · Score: 2, Insightful

    .Net has a native data type called decimal [microsoft.com] that does uses decimal floating point and is accurate to 28 or 29 digits, which makes it a great thing to use when dealing with money. I wish more languages would support something similar.

    They do:
    https://docs.python.org/2/library/decimal.html
    http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic

    Just because your world is limited to .NET it does not mean there aren't other things out there... Did you even bother looking up?

  16. Re:The 4 year old Intel Developer thread on the FS by Anonymous Coward · · Score: 0

    Thanks for posting a link from the summary.

    In the future, you may wish to consider actually reading the summary. Might add a little life to your keyboard and avoid unnecessary use of limited internets. Thanks.

  17. More or less accurate than math textbooks ... by perpenso · · Score: 1

    Are the FSIN results more or less accurate than the trig tables inside the covers of math textbooks?

  18. It's not a bug by ArcadeMan · · Score: 1

    The Intel engineers watched Superman III, and they have a plan.

    1. Re:It's not a bug by jader3rd · · Score: 1

      The Intel engineers watched Superman III, and they have a plan.

      They're going to override the security?

  19. Oh god my pants by ourlovecanlastforeve · · Score: 0

    The only time a mathematician every has an orgasm.

    1. Re:Oh god my pants by Greyfox · · Score: 1

      I can see why he wasn't an English major.

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  20. We are Pentium of Borg. by mmell · · Score: 1

    Division is futile. You will be approximated.

  21. FPUs are **inherently** approximations by perpenso · · Score: 1

    If you want it precise, do it yourself to the level of precision you need.

    People just don't realize that FPUs are **inherently** approximations, anyone's FPU, its not Intel specific. There are inaccuracies converting to and from binary, there are inaccuracies depending on the relative magnitude of operands, the are inaccuracies due to rounding, etc ...

    Do you know one way to tell if a calculator app is implemented using the FPU. Try 0.5 - 0.4 - 0.1, you may not get zero if a FPU is used. That is why handheld calculators often implement calculations using decimal math rather than a FPU. The better apps do so as well. This includes an iOS scientific/stats/business/hex calculator app that I wrote. Decimal math for operations, Taylor series based trig calculations, etc.

    1. Re:FPUs are **inherently** approximations by Anonymous Coward · · Score: 0

      The stack of errata on any current modern CPU is quite large. It is not just math functions...

    2. Re:FPUs are **inherently** approximations by perpenso · · Score: 1

      The stack of errata on any current modern CPU is quite large. It is not just math functions...

      I'm not talking about errata, about bugs, I'm talking about the inherent lack of precision when using a FPU. Its a design compromise inherent into all FPUs, inherent into IEEE single and double precision.

    3. Re:FPUs are **inherently** approximations by Teresita · · Score: 1

      So use hardware floating point operations when it doesn't matter, like for games. But if you're going to calculate the trajectory of a mission to Pluto or something, bring the math out into your software, take the time, do it right.

    4. Re:FPUs are **inherently** approximations by gnasher719 · · Score: 1

      So use hardware floating point operations when it doesn't matter, like for games. But if you're going to calculate the trajectory of a mission to Pluto or something, bring the math out into your software, take the time, do it right.

      Forget it. _You_ can't write an implementation of the sine function that is more precise than FSIN. Apple's implementation on PowerPC was more accurate; Java VMs must have a more precise implementation to pass Sun's compatibility tests. But anyone who knows about "Taylor polynomials" or "Pade approximations" or "CORDIC" will end up with something less precise.

    5. Re:FPUs are **inherently** approximations by Bruce+Dawson · · Score: 1

      There's an alternate test that works on the Windows 7 calculator to show that it is not implemented on the FPU. Calculate square root of four, and then subtract two. You should get zero but you don't.

      That is an error that no FPU would make. The IEEE standard requires a correctly rounded result for square root, and the Windows 7 calculator fails to deliver that on even very simple inputs like four. The Windows 7 calculator does its calculations to more digits of precision than double precision, but it doesn't do its calculations accurately. Oops.

    6. Re:FPUs are **inherently** approximations by Anonymous Coward · · Score: 0

      It isn't that hard to get more accurate than the cpu, considering writing a simple arbitrary precision math library is a high school CS level project, with adding trig or other such functions as a nice bonus part for those that had the calc background already. The difficult part is doing so with any reasonable speed since the most obvious series for producing such functions tend not to converge very fast, and with an arbitrary precision setup, you can end up wasting a lot of extra memory for an inefficient operation to get enough precision in the final result., especially if on top of an inefficient implementation of basic math operations. But it will still get there, and rather quickly by human standards if you just need to take the sine of a single number.

    7. Re:FPUs are **inherently** approximations by tibit · · Score: 1

      This is especially egregious given that all the arguments and results are representable in IEEE-754 with no loss of precision!

      --
      A successful API design takes a mixture of software design and pedagogy.
  22. RNG by Anonymous Coward · · Score: 0

    Isn't fsin used in some (pseudo)random number generators?

  23. Bad intel by Anonymous Coward · · Score: 0

    Sinbad reads Shashdot now? That be crazy.

  24. Re:Read TFA. Not even a close approximation, and d by CrimsonAvenger · · Score: 1

    Well, no.

    From TFA, the absolute error closely approximates 0.000000000000000000004.

    So you'll only see a relative error as large as you're showing (off in the fifth decimal place), if the correct answer is something like 0.000000000000000012345, which might show up as 0.000000000000000012344.

    --

    "I do not agree with what you say, but I will defend to the death your right to say it"
  25. Why would anyone use x87 instructions? by Anonymous Coward · · Score: 0

    As most of the effort for better math is in the newer instruction sets using 8087 instructions makes no sense whatsoever. A non-issue unless the poster, the blogger and his ego all want a stroke today.

    Waste of time, new headline: Idiot uses 8087 code, get shunned by /.

    1. Re:Why would anyone use x87 instructions? by Anonymous Coward · · Score: 0

      He's Bruce Dawson, and he's got a blog! His pretty face is pretty much the only reason anyone reads it.

  26. Not news by loufoque · · Score: 1

    First, it's an x87 instruction. This unit has been deprecated for a decade.
    Second, It was never meant to produce correct rounding for extended precision, and never claimed to. The documentation has always clearly stated 1 ULP of precision.

    Apparently, some newbie doesn't understand what this means, and somehow it's a thing.

    1. Re:Not news by gnasher719 · · Score: 1

      First, it's an x87 instruction. This unit has been deprecated for a decade.

      It's not deprecated at all. It's commonly used by everyone using "long double" instead of "double" in their x86 code. And using "long double" can be very useful. For example, if you want to write a function that calculates sqrt (x^2 + y^2) for double precision x and y, that's very very hard to get right using double precision only, but using long double in the calculation and rounding to double makes it trivial.

      (If you want to know why this would be hard to get right, consider what happens if x, y are around 1e200 or 1e-200. In many implementations, it is possible that x >= x' > 0, y >= y' > 0, but the result for x, y is less than the result for x', y').

    2. Re:Not news by loufoque · · Score: 1

      It's commonly used by everyone using "long double" instead of "double" in their x86 code.

      long double isn't even supported by all compilers that run on x86-64 (most notably MSVC++), and of course it's specific to those processors. With other processors, long double can mean something else entirely.
      Anyone serious about floating point only uses the IEEE754 formats, and for scientific computing the only one used is double precision, though single precision is also popular as a way to get an estimate on which you can apply iterative refinement.

      For example, if you want to write a function that calculates sqrt (x^2 + y^2) for double precision x and y, that's very very hard to get right using double precision only, but using long double in the calculation and rounding to double makes it trivial.

      Just use a library that does it correctly. The function is called 'hypot'.
      Using long double just makes it slow and non-portable.

    3. Re:Not news by dalias · · Score: 1

      If you bothered to read the story, the problem is that the result is not correct to 1 ULP. Even for small inputs it has significant errors and the worst case has only 4 bits correct (so, roughly 2^49 ULP error). As for deprecation, you're right and wrong. It's not officially deprecated, but it's slower than computing sin correctly in software, and between the performance issue and the fact that experts in the field have known about this bug for a long time, nobody with a clue uses the FSIN instruction.

  27. example from TFA. try it by raymorris · · Score: 3, Informative

    Here's an example from TFA:

    tan(1.5707963267948966193)

    actual -39867976298117107068
    x87 fpu -36893488147419103232
    error 743622037674500958.81 ulp

    1. Re:example from TFA. try it by Anonymous Coward · · Score: 0

      Here's an example from TFA:

      tan(1.5707963267948966193)

      actual -39867976298117107068
      x87 fpu -36893488147419103232
      error 743622037674500958.81 ulp

      What did you use to do the calculation? C? Python? Perl? Microsoft Calculator? Excel? That will also make a difference. That's why people who care about such precision use high end mathematical packages like Mathematica, MatLab, Maple, etc. or write their own solvers when it REALLY matters. They also check the solver by hand if they are writing their own to be sure. I know, I've worked supporting researchers in a College of Engineering.

    2. Re:example from TFA. try it by gnasher719 · · Score: 1

      tan(1.5707963267948966193)

      And the example is rubbish.

      That number 1.5707963267948966193 is a decimal number. Before you get anywhere near calculating the tangent of that number, you have to convert it to a binary number. The error in that conversion will be about 2^-64. That means the argument that you pass to the FTAN instruction isn't actually 1.5707963267948966193, but a number that is different from this by up to 2^-64. The error that you get by not passing 1.5707963267948966193 but a slightly different number is about ten times larger than the error in the FTAN function.

    3. Re:example from TFA. try it by Bruce+Dawson · · Score: 1

      How would you like that example number to be given? In hexadecimal for maximum readability? Giving it in decimal is necessary for communicating the issue.

      But the reality is that that number can show up during calculations. Intel promises to calculate it's tangent to a specific precision, but Intel's documentation is incorrect. That is the problem -- hugely misleading documentation.

      The issue of not being able to fully specify a particular real number is actual crucial to the article though, but in a different way. The example is sin(double(pi)), what it should be, what that should allow, and how that fails. You should read the article. I think it's excellent.

    4. Re:example from TFA. try it by Anonymous Coward · · Score: 0

      If you are depending on accurate results for the tan of a number near pi/2, you are going to have bigger problems than that. Even a small error in the parameter with cause huge issues because tan is getting infinitely large near there, and so is the derivative. Small errors of any sort will get hugely magnified, and you would need a lot of care and effort if the exact value is important. 90+% of the time, if you depend on accurate values of some function tending toward infinity, it is better to refactor your problem to avoid that. E.g., there are various versions of special functions that already cancel out large numbers that would result normally in their definition, instead of requiring the library user to generate two large numbers and divide or subtract them out resulting in large error.

    5. Re:example from TFA. try it by geantvert · · Score: 2

      1.5707963267948966193 is rounded as 0x1.921FB54442D18p+0
      Look what would happens with different roundings:

      tan(0x1.921FB54442D17p+0) = + 0x1.9153D9443ED0Bp+51
      tan(0x1.921FB54442D18p+0) = + 0x1.D02967C31CDB5p+53
      tan(0x1.921FB54442D19p+0) = - 0x1.617A15494767Ap+52

      Simply speaking, computing the TAN of 1.5707963267948966193 in double precision does not make sense.
      That's a typical floating point precision.

      Now, if you really want to discuss the precision of TAN, you should use 0x1.921FB54442D18p+0 or any other value with an exact double precision representation.
      But even then, it does not really make sense to discuss the precision near special values such as PI/2 because the precision of your input data will be unrealiable around that number.

    6. Re:example from TFA. try it by jbengt · · Score: 1

      But even then, it does not really make sense to discuss the precision near special values such as PI/2 because the precision of your input data will be unrealiable around that number.

      In the subject case, though, the input was precise because it was a purely mathematical operation to illustrate a technique for converging towards the exact value of Pi. The misleading documentation led the author to believe that the technique should work using a compiler that uses Intel's FSIN(), but doesn't. He also found out that some compilers avoid the issue.

  28. Honest Question by Anonymous Coward · · Score: 0

    I dabble around in computer graphics, and use Cinema 4D's team-render on a number of older computers. They are all different makes, but all have Core i7 processors in them. 2 of the older machines run Mac OS, 1 runs Windows 8. For most computations done by the rendering engine, all machines are in agreement and no visible differences appear in the different image tiles returned by each of the machines. However, some of the Monte-Carlo rendering options (subsurface scattering, light-mapping) return wildly different results from different 'versions' of the same processor... Would this math issue be the root cause of these inconsistencies? Or would like more likely be down to OS differences between the libraries used by the software?

    1. Re:Honest Question by Blaskowicz · · Score: 1

      Are those differences consistent?, are there differences between runs on the same machine?

      Monte-Carlo rendering : from the name, that's using a lot of random numbers (like throwing a million darts at a wall and seeing what they hit.). So the software or even hardware implementation of random number generators may be important. Newer CPUs may have a built-in random generator which uses thermal noise - but the software has to use that ; and I presume it's foremost for security applications.
      I suppose 3D renderes use single precision floating point. Perhaps the math issue has no bearing.

  29. Re:did you even bother looking it up? by Anonymous Coward · · Score: 0

    Even C/C++ has decimals in the main language if you use a gcc (or derivative):
      https://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html

  30. Legacy instructions produce legacy results? by Anonymous Coward · · Score: 0

    TFS basically shows how how the author has essentially zero experience with x86, and indeed programming in general. FCOS is part of the original 387 instruction set that has been deprecated since the Pentium IV. The "article" (read: blog) is about as informative as any statement beginning with "in my day...".

    1. Re:Legacy instructions produce legacy results? by tibit · · Score: 1

      So, WTF should I be using to get a sine or cosine computed in hardware on an x86 these days?

      --
      A successful API design takes a mixture of software design and pedagogy.
  31. I've got 98.999999997 problems by BenSchuarmer · · Score: 1

    and the chip aint one.

  32. Here we go... by gspeare · · Score: 1

    Round off the usual suspects...

  33. should have used Java by Anonymous Coward · · Score: 0

    Java, even when running on Intel, have precisely defined behavior for floating point. You aren't going to run into this cpu specific nonsense there. Obviously there is a performance penalty to pay, and the developers that write JVMs must run compliance tests.

  34. To be expected by jmv · · Score: 2

    There's nothing I find particularly alarming here and the behaviour is in fact pretty much what I would expect for computing sin(x). Sure, maybe the doc needs updating, but nobody would really expect fsin to do much better than what it does. And in fact, if you wanted to maintain good accuracy even for large values (up to the double-precision range), then you would need a 2048-bit subtraction just for the range reduction! As far as I can tell, the accuracy up to pi/2 is pretty good. If you want good accuracy beyond that, you better do the range reduction yourself. In general, I would also argue that if you have accuracy issues with fsin, then your code is probably broken to begin with.

  35. Total rubbish article by gnasher719 · · Score: 4, Informative

    Here's what the complaint is about: The Intel FSIN instruction performs an argument reduction to calculate the values of the sine function, but not with the exact value of pi, but using a 66 bit approximation of pi. If your argument is close to a multiple of pi, then the argument reduction doesn't give the correct result.

    HOWEVER, if your argument is an extended precision number close to pi = 3.14..., then the last bit in the mantissa of that number has a value of 2^-62. So if you calculate an argument close to pi, the unavoidable bounds for the rounding error are 2^-63. This error in the argument is about 10 times larger than the error caused by using an approximation for pi in the argument reduction. If you use double precision, the error in the argument is about 20,000 times larger than the error caused by the argument reduction.

    All this has been known for years; posting it today and claiming there is any problem is just ridiculous.

    1. Re:Total rubbish article by Anonymous Coward · · Score: 0

      The entire problem is a bit silly, because for those values of the argument where it starts to matter the angular precision is about as bad as the error in the result. This means that even if one implements a sine function that compensates for the lack of precision in pi the argument in to the function won't have the necessary precision to practically take advantage of this arbitrarily. The input has to be very tailored for it to matter.
      In those cases it is a problem it is a worse problem that you work with the angle in a floating point format than that the sine function doesn't behave properly for large values.

  36. Re:did you even bother looking it up? by swilly · · Score: 1

    Java also has a decimal type, though without operator overloading it isn't as pleasant to work with.

    http://docs.oracle.com/javase/...

  37. Inaccurate headline by Anonymous Coward · · Score: 0

    I don't know. If the processor was supposed to be designed from the documentation, then I would say the processor is at fault. I don't see how you can say the documentation is wrong if you don't know what the design was supposed to be. I code from documentation, so if my code doesn't match the documentation then my code is wrong. I usually don't got to point the blame on the docs. I might try that next time though. Seems to be working for Intel....

  38. mountain out of a mole hill by Anonymous Coward · · Score: 0

    Wow. Really sensational article with pointless useful content. This is a long known issue. Never been a secret. For example see: http://hal.archives-ouvertes.fr/docs/00/28/14/29/PDF/floating-point-article.pdf

    ok, so intel fixed their documentation now. move along, nothing to see here.

  39. Article is wrong - it is documented by gnasher719 · · Score: 2

    It seems that the blogger didn't actually read the documentation that he claimed to read. The exact behaviour is documented in "Intel® 64 and IA-32 Architectures Software Developerâ(TM)s Manual Volume 1: Basic Architecture" of March 2012 on page 8-31. I don't have an older copy of that manual anymore, but I have written code according to that exact documentation sometime around 2001, so I am quite confident that it was in the 2001 version of the document.

    This is what the documentation says: "The internal value of Ï that the x87 FPU uses for argument reduction and other computations is as follows: Ï = 0.f â-- 2^2 where: f = C90FDAA2 2168C234 C". A more precise approximation according to Wikipedia would have been f = C90FDAA2 2168C234 C4C6 4...; the difference between pi and the approximation used by Intel is about 0.0764 * 2^-64.

    If you let x = pi, then people would ordinarily expect that sin (x) = 0. That, however, would be wrong. Storing pi into a floating-point number produces a rounding error. Rounded to extended precision (64 bit mantissa) instead of the usual double precision (53 bit mantissa) produces a result of 4 * 0.C90FDAA2 2168C235 instead of 4 x C90FDAA2 2168C234 C4C6 4...; this is too large by 4 * (1 - 0.C4C64...) * 2^-64. The sine of that number would also be 4 * (1 - 0.C4C64...) * 2^-64.

    But FSIN doesn't subtract pi from that number x, instead it subtracts 4 * 0.C90FDAA2 2168C234 C. So we get a result of 4 * (1 - 0.C) * 2^-64 instead of 4 * (1 - 0.C4C64...) * 2^-64. That's what he complains about. The reality is that the correct result would have been zero, but we couldn't get that because trying to assign pi even to an extended precision number gives some rounding error.

    Now in practice, if you calculate an argument for the sine function, and that argument is close to pi, even if you manage to get a correctly rounded extended precision result, you must expect a rounding error up to 2^-63, and therefore an error in the result up to 2^-63, even if the calculation of the result is perfect. FSIN gives a result that is about 0.0764 * 2^-64 away from that, so the inevitable error caused by rounding the argument is increased by a massive 3.82 percent. Doing the calculation in double precision, as almost everyone does, makes the rounding error 2048 times larger and FSIN is now 0.00185 percent worse than optimal.

    1. Re:Article is wrong - it is documented by Anonymous Coward · · Score: 0

      You confuse the function implementation with the function contract. The contract was that "the worst case error on transcendental functions is less than 1 ulp when rounding to the nearest (even)", and that was wrong and stays wrong no matter how many pages of implementation details you care to bring to the table.

    2. Re:Article is wrong - it is documented by Bruce+Dawson · · Score: 1

      As the other reply said, the function contract and an explanation of the implementation are different beasts. The Intel manual said that fsin is accurate across a huge range of values. Elsewhere the Manual hinted at Intel's range reduction algorithm such that a numerical analyst could suspect that there was a problem. So, to a numerical analyst the documentation was contradictory. To anybody else it was clear -- guaranteed one ulps precision. The documentation was therefore at best misleading, but for most people it was just wrong. Linus Torvalds was fooled, for example.

      > If you let x = pi, then people would ordinarily expect that sin (x) = 0.

      Many people would expect that, although the article (my article) most certainly did not expect that.

      The calculation being done in the article takes into account the fact that double(pi) is not the same as the mathematical constant pi and it uses that and the properties of sine to measure the error in double(pi). This is an unusual but perfectly reasonable calculation to make. It failed because of the limitations of fsin. Those limitations are contradictory to the documentation. Hence the article.

      > A more precise approximation according to Wikipedia would have been...

      You don't need to go to Wikipedia, you just have to RTA. It lists a 192-bit hexadecimal approximation of pi.

      > The reality is that the correct result would have been zero

      No. Zero is the correct answer if doing symbolic or infinite precision math, but I did not make that assumption because I was doing double-precision math.

  40. Single... by Anonymous Coward · · Score: 0

    for anything implemented in an APU, last I checked.

    Double precision for the most part only pops up in 200 dollar plus last gen, and 300+ current gen cards. It's one of my big gripes with the collusion in the industry. Nvidia stopped including DP in their cheap parts and wow, next stepping so did AMD!

  41. That's not equivalent clock speed... by Anonymous Coward · · Score: 0

    Take the fp numbers, divide by cores and mhz, compare between chips/archs.

    A number of other cpus get better clock for clock FPU ratings than Intel, but Intel has been dramatically better on the speed since the early '00s, and nowadays better on the IPC numbers. That often does not result in better FPU numbers however due to both the number of registers and the processing capacity of the FPUs in non-x86 arches.

    1. Re:That's not equivalent clock speed... by itzly · · Score: 1

      Nobody cares about clock speed. People care about dollars, watts, and how quickly/accurately they get their result.

  42. never miss an opportunity by lkernan · · Score: 1

    Coming soon: Intel Core i7 School Dropout Edition

  43. /fp:strict by danknight48 · · Score: 1

    /fp:strict
    Failing that, use a pen and paper.

  44. Dawson found a bug in gcc 4.3 as well by munch117 · · Score: 2

    Dawson points to an 'optimisation' in gcc 4.3: constant folding is done using the higher-precision MPFR library. At least the gcc developers seem to think it's an optimisation, but unless it's disabled by default, it is actually a bug. In the absence of undefined behaviour, optimisations must not change observable behaviour. And, as Dawson demonstrates, this one does.

    If you need MPFR precision, you should use MPFR explicitly.

  45. Hah. With a GPU... by Anonymous Coward · · Score: 0

    you get numbers that *look* right, as opposed to numbers that *are* right.
    I have an old war story about a customer that tried to squeeze an IP over ISDN bridge through a (lossy) voice compression. I tried to explain to him that the IP packets at the other end *sounded* right -- ah, old times.

  46. Do you really need this precision? by Polizei · · Score: 2

    Come on, guys, you'll ever only use FPU instructions when you need speed, not precision.
    Anyone remember 0x5f375a86?
    The precision used in Quake's source code wasn't even nearly comparable to the FPU, but was fast enough.

    In other words, you'll never calculate shopping cart totals minus discounts and other stuff this way (or, at least, you shouldn't!)
    There's BigDecimal in Ruby/Java, decimal.Decimal in Python, GMP in C/C++, etc...

  47. Fixed Point by emh203 · · Score: 1

    Nice to know my integers aren't affected. :-

  48. What does Xcode do... by gnasher719 · · Score: 1

    Xcode using a recent version of Clang with the standard library supplied by Clang does the following:

    1. The long double function sinl uses the FSIN instruction, except it checks when the argument is too large (> 2^63) and does an argument reduction using a 64 bit approximation of pi.

    2. The double function sin uses SSE register and floating point arithmetic, using argument reduction with a value > 100 bits for pi.

  49. Real Programmers use 64-bits by Anonymous Coward · · Score: 0

    If you are using FSIN, it means you are doing 32-bit compiles, and are a true luddite - go back to using your Pentium 1 on Windows 95. 64-bit systems have been generally available since 1992 (Alpha). No, I'm not an Intel FanBoi - I worked for AMD at one point.

  50. Practically irrelevant by Anonymous Coward · · Score: 0

    This is why you should not take the sine of a large number in the first place:
    In abstract terms, the sine function has a large relative condition number (infinity for multiples of pi) for large input arguments.

    More specifically, double numbers are normally rounded to the equivalent of about 16 decimal places; so pi is represented as 3.141592653589793. (Real machines work in base-2, of course, but I will assume base-10 because it's more readable and the problem is the same.) As the sine of any multiple of pi should be zero, let's take sin(pi*1e15), which the machine represents as sin(3141592653589793). Obviously, 3141592653589793 is not a multiple of pi, so the result of this computation is not 0 but -0.2362.

    The "bug" only matters if the intended argument of the sine is a number that can be represented without any round-off error, which is unlikely in any real-world application. Otherwise, the error of the computation is dominated by the inaccurate representation of the argument, and you cannot blame the implementation of the sine function for that.

  51. Re:To tal rubbish article by Anonymous Coward · · Score: 0

    All this has been known for years; posting it today and claiming there is any problem is just ridiculous.

    So; Mr Guru; given that you "knew" about this years ago I guess you contacted Intel to update the docs. Oh no; you just "knew seekrehtl". Well then I guess there is a story here because the guy with the article actually bothered to pubish and get the docs updated. You might have got the publicitly if you really had known and did something about it. Give up on the sour grapes.

  52. Basic maths required. by RockDoctor · · Score: 1
    Surely everyone knowns that, for small values of theta (the situation that is being discussed), then sin(theta) ~= theta (in radians). It's a basic trigonometry result, used all over the place where you're looking at small angles. It's probably at the root of the original articles interest in using the sin() calculation to expose the (in-)accuracy of the system's value for pi.

    So, if your angle gets to low values (choose where that is for yourself) , then you switch to using that approximation and cut out a large chink of calculation. Saves a lot of hassle. It's as basic as checking for "divide by zero" situations.

    --
    Birds are not dinosaur descendants;birds are dinosaurs, for all useful meanings of "birds", "are" and "dinosaurs"
    1. Re:Basic maths required. by Bruce+Dawson · · Score: 1

      It is of course well known that, for double precision, sin(x) == x if x 1.49e-8. They teach that in kindergarten these days.

      However the article is about sin(double(pi)), and pi is actually greater than 1.49e-8. Therefore range reduction needs to be done, and that is where things go awry.

      Yes, the caller could do the range reduction, but this is not trivial to do correctly and it really should be done by the sin() function. With glibc 2.19 it is.