1 / 24

CSC 4250 Computer Architectures

CSC 4250 Computer Architectures. September 12, 2006 Appendix H. Computer Arithmetic. Five Real Stories on Computer Arithmetic. Insufficient Accuracy Truncation Errors Numerical Overflow Divide by Zero Wrong Units of Measurement. 1. Insufficient Accuracy. First Iraq War

becka
Download Presentation

CSC 4250 Computer Architectures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 4250Computer Architectures September 12, 2006Appendix H. Computer Arithmetic

  2. Five Real Stories on Computer Arithmetic • Insufficient Accuracy • Truncation Errors • Numerical Overflow • Divide by Zero • Wrong Units of Measurement

  3. 1. Insufficient Accuracy • First Iraq War • Feb 25, 1991; Dhahran, Saudi Arabia • Iraqi Scud Missile • American Patriot Missile failed to intercept • 28 American soldiers died in the attack: • 20% of the 148 total deaths

  4. Fixed Point Data • Patriot system contains an internal clock, a counter that is incremented every 0.1 seconds • Time in seconds is determined by multiplying the counter value by 0.1 (24 bit approximation)

  5. Approximation Base 10 Base 2 0.1 = 0.000110011001100[1100]… ≈ 0.00011001100110011001100 ← 23 bits → • Let x = 0.00011001100110011001100 • Then 0.1 − x = 0.110011001100[1100]…× 2–23 = 0.00011001100[1001]…× 2–20 • Thus, (0.1 − x)/0.1 = 2–20 ← relative error

  6. Patriot System • Mobile system • Designed to avoid detection • Should run for only a few hours at each site • Ran for 100 hours in Dhahran: 100 hrs = 360,000 sec = 3.6×105 sec • Accumulated error equals (3.6×105) × 2–20 = 0.3433 seconds > Clock step size

  7. Software System Upgrade • Software (assembly language) written in 1970s • Modified to cope with high speed of missiles → Clock time more accurately converted • Not all function calls replaced by new code • Patriot likely confused by different clock times • Patriot did not track the Scud → No Patriot missile was fired

  8. 2. Truncation Errors • Dow Jones Industrial Average equals a multiple of the total prices of the 30 underlying stocks • Present multiple is about 8.00 • If IBM ($79.40, closing price on 9/7) goes up $1, then DJI average goes up 8.00 points • If Microsoft ($25.43, closing price on 9/7) goes up $1, then DJI average goes up 8.00 points • If GE ($34.04, closing price on 9/7) goes up $1, then DJIA goes up 8.00 points • Is DJIA a good measure of the market? • What happens to DJIA when IBM goes up 10%? MSFT? • Faster to update index than to compute it from definition

  9. Market Cap

  10. Effect on DJIA • If the market cap of IBM goes up $12.196B, the DJIA will go up ?? points • If the market cap of MSFT goes up $25.553B, the DJIA will go up ?? points • If the market cap of GE goes up $35.017B, the DJIA will go up ?? points • The S&P 500 index is generally regarded as a better measure of the market because it takes market cap into account (it is float weighted)

  11. Truncation Errors (2) • Vancouver Stock Exchange introduced new stock index in 1982 • Updated and truncated (three decimal digits) after each transaction • After 22 months, index fell from 1000 to 525 ─ 524.881, to be precise • Correct value is 1098.811 ─ based on underlying stocks

  12. Truncation Error (3) • Assume 2500 transactions a day • Average error per transaction is 0.0005 • Average error per day is 1.25 • Assume 21 trade days a month • Total estimated error is 22×21×1.25 = 577.5 • Correct value is 1098.811 → Estimated wrong value = 521.311 • Observed index value = 528.881

  13. 3. Numerical Overflow • European Space Agency • Ariane 5 rocket; June 4, 1996 • $500 million communication satellites on board • Off course and exploded 37 seconds after liftoff • Overflow when 64-bit floating-point number converted to 16-bit signed integer • Value measured horizontal velocity of rocket • 16 bit integer sufficient for Ariane 4 • Part of Ariane 4 software reused in Ariane 5

  14. Divide by Zero • US Navy missile cruiser USS Yorktown • September 1997; off coast of Virginia • A zero was entered by mistake into data field of Remote Database Manager Program • A divide by zero → Database overflow → Propulsion system shut down • Ship dead in water for 2 hours 45 minutes

  15. 5. Wrong Units of Measurement • Mars Climate Orbiter; $125 million • September 23, 1999 • Lockheed Martin built & operated the orbiter • LM engineers gave navigation commands for the Orbiter’s thruster in English units • NASA use metric units • Navigation information did not transfer to JPL • Orbiter got to within 60km of Mars, 100 km closer than planned • Orbiter’s propulsion system overheated and became disabled

  16. Four Rounding Rules • Round to even: 1.25 → 1.2; 1.35 → 1.4; −1.35 → −1.4 • Round toward zero (= truncate): 1.25 → 1.2; 1.35 → 1.3; −1.35 → −1.3 • Round toward plus infinity: 1.25 → 1.3; 1.35 → 1.4; −1.35 → −1.3 • Round toward minus infinity: 1.25 → 1.2; 1.35 → 1.3; −1.35 → −1.4

  17. Important Rule on Accuracy (p. H-35) • If x and y have p-bit significands, and x+y is computed exactly and then rounded to q places, a second rounding to p places will not change the answer if q ≥ 2p+2. This is true not only for addition, but also for multiplication, division, and square root.

  18. IEEE Arithmetic • Double precision, q = 53 • Single precision, p = 24 • So, q ≥ 2p+2 • Accurate single precision can be implemented by computing in double precision, and then rounded to single precision

  19. Double Rounding (p. H-34) • Want to compute 1.9 × 0.66 • Exact result is 1.254 • Say extended precision is 3 digits • Rounded to extended precision, the result is 1.25 • Further rounded to single precision, the result is 1.2 • Correctly rounded result is 1.3, obtainable by directly rounding once • What went wrong? • We have: q = 3; p = 2; q < 2p+2.

  20. Objective • Computed result should be accurate to last bit (as if calculated in exact arithmetic, and then rounded correctly).

  21. Cray-1 • Computation not accurate • Cray division: a/b = a × (1/b) • Take b = 10 (Recall Patriot System). • Last three bits could be wrong on Cray divides • Read p. H-64 and p. H-65

  22. Floating Point Operations Not Associative • We have ( 3.14 + 1010 ) −1010 = 0 • But 3.14 + (1010 −1010 ) = 3.14 • Also, (1020 × 1020 ) ×10−20 = Overflow 1020 × ( 1020 ×10−20 ) = 1020

  23. Euclidean Length of Vector • √[ v02 + v12 + v22 + … + vn2 ] • May overflow or underflow with vi2, even though final result is a normal number. • Try vi = 1040, or vi = 10−40

  24. Better Way to Compute Euclidean Length • Let vmax = max │vi│ • Then compute vmax√[ (v0/ vmax )2 + … + (vn/ vmax )2 ] • Replace vmax by an easier-to-handle quantity?

More Related