CSC%204250%20Computer%20Architectures - PowerPoint PPT Presentation

About This Presentation
Title:

CSC%204250%20Computer%20Architectures

Description:

CSC 4250 Computer Architectures – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 25
Provided by: stude6
Learn more at: http://www.cs.rpi.edu
Category:

less

Transcript and Presenter's Notes

Title: CSC%204250%20Computer%20Architectures


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

2
Five Real Stories on Computer Arithmetic
  1. Insufficient Accuracy
  2. Truncation Errors
  3. Numerical Overflow
  4. Divide by Zero
  5. 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.0001100110011001100
  • 0.00011001100110011001100
  • ? 23 bits ?
  • Let x 0.00011001100110011001100
  • Then
  • 0.1 - x 0.1100110011001100 223
  • 0.000110011001001 220
  • Thus,
  • (0.1 - x)/0.1 220 ? 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.6105 sec
  • Accumulated error equals
  • (3.6105) 220 0.3433 seconds
  • gt 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
Company Price Market Cap
IBM 79.40 121.96B
MSFT 25.43 255.53B
GE 34.04 350.17B
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 SP 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 22211.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
    Orbiters 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
  • Orbiters 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 xy is
    computed exactly and then rounded to q places, a
    second rounding to p places will not change the
    answer if q 2p2. 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 2p2
  • 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 lt 2p2.

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
  • v 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
  • vmaxv (v0/ vmax )2 (vn/ vmax )2
  • Replace vmax by an easier-to-handle quantity?
Write a Comment
User Comments (0)
About PowerShow.com