+ All Categories
Home > Documents > Lecture 03 - computer organization and architecture

Lecture 03 - computer organization and architecture

Date post: 03-Jun-2018
Category:
Upload: matthew-galbraith
View: 223 times
Download: 0 times
Share this document with a friend

of 35

Transcript
  • 8/12/2019 Lecture 03 - computer organization and architecture

    1/35

    Lecture 3

    CMPT215.3

  • 8/12/2019 Lecture 03 - computer organization and architecture

    2/35

    Performance

  • 8/12/2019 Lecture 03 - computer organization and architecture

    3/35

    Chapter 1 Computer Abstractions and Technology 4

    Understanding Performance

    Algorithm Determines number of oerations e!ecuted

    Programming language" comiler" architecture Determine number of machine instructions e!ecuted er

    oeration

    Processor and memor# s#stem Determine ho$ fast instructions are e!ecuted

    %&' s#stem (including ')*

    Determines ho$ fast %&' oerations are e!ecuted

  • 8/12/2019 Lecture 03 - computer organization and architecture

    4/35Chapter 1 Computer Abstractions and Technology 5

    +esonse Time and Throughut

    +esonse time ,o$ long it ta-es to do a tas-

    Throughut Total $or- done er unit time

    e.g." tas-s&transactions& er hour

    ,o$ are resonse time and throughut affected b# +elacing the rocessor $ith a faster /ersion0

    Adding more rocessors0

    ell focus on resonse time for no$

  • 8/12/2019 Lecture 03 - computer organization and architecture

    5/35Chapter 1 Computer Abstractions and Technology 6

    +elati/e Performance

    Define Performance 1&4!ecution Time

    6 is ntime faster than 78

    n== 67

    76

    time4!ecutiontime4!ecution

    ePerformancePerformanc

    4!amle9 time ta-en to run a rogram 1:s on A" 15s on ;

    4!ecution Time;& 4!ecution TimeA 15s & 1:s 1.5

    )o A is 1.5 times faster than ;

  • 8/12/2019 Lecture 03 - computer organization and architecture

    6/35

    Chapter 1 Computer Abstractions and Technology 7

    Measuring 4!ecution Time

    4lased time Total resonse time" including all asects

    Processing" %&'" ') o/erhead" idle time

    Determines s#stem erformance

    CPU time Time sent rocessing a gi/en

  • 8/12/2019 Lecture 03 - computer organization and architecture

    7/35

    Chapter 1 Computer Abstractions and Technology 8

    CPU Time

    Performance imro/ed b# +educing number of cloc- c#cles

    %ncreasing cloc- rate

    ,ard$are designer must often trade off cloc- rateagainst c#cle count

    +ateCloc-

    C#clesCloc-CPU

    TimeC#cleCloc-C#clesCloc-CPUTimeCPU

    =

    =

  • 8/12/2019 Lecture 03 - computer organization and architecture

    8/35

    Chapter 1 Computer Abstractions and Technology 9

    CPU Cloc-ing

    'eration of digital hard$are go/erned b# a

    constant=rate cloc-

    Cloc- (c#cles*

    Data transfer

    and comutation

    Udate state

    Cloc- eriod

    Cloc- eriod9 duration of a cloc- c#cle e.g." 25:s :.25ns 25:>1:?12s

    Cloc- fre@uenc# (rate*9 c#cles er second e.g." .:B, :::M, .:>1:,

  • 8/12/2019 Lecture 03 - computer organization and architecture

    9/35

    Chapter 1 Computer Abstractions and Technology 10

    CPU Time 4!amle

    Comuter A9 2B, cloc-" 1:s CPU time

    Designing Comuter ; Aim for Es CPU time

    Can do faster cloc-" but causes 1.2 > cloc- c#cles

    ,o$ fast must Comuter ; cloc- be0

    B,Es

    1:2

    Es

    1:2:1.2+ateCloc-

    1:2:2B,1:s

    +ateCloc-TimeCPUC#clesCloc-

    Es

    C#clesCloc-1.2

    TimeCPU

    C#clesCloc-+ateCloc-

    DD

    ;

    D

    AAA

    A

    ;

    ;;

    =

    =

    =

    ==

    =

    ==

  • 8/12/2019 Lecture 03 - computer organization and architecture

    10/35

    Chapter 1 Computer Abstractions and Technology 11

    %nstruction Count and CP%

    %nstruction Count for a rogram Determined b# rogram" %)A and comiler

    A/erage c#cles er instruction Determined b# CPU hard$are

    %f different instructions ha/e different CP% A/erage CP% affected b# instruction mi!

    +ateCloc-

    CP%Countn%nstructio

    TimeC#cleCloc-CP%Countn%nstructioTimeCPUn%nstructioerC#clesCountn%nstructioC#clesCloc-

    =

    ==

  • 8/12/2019 Lecture 03 - computer organization and architecture

    11/35

    Chapter 1 Computer Abstractions and Technology 1

    CP% 4!amle

    Comuter A9 C#cle Time 25:s" CP% 2.: Comuter ;9 C#cle Time 5::s" CP% 1.2 )ame %)A hich is faster" and b# ho$ much0

    1.25::s%

    E::s%

    ATimeCPU

    ;TimeCPU

    E::s%5::s1.2%

    ;TimeC#cle

    ;CP%Countn%nstructio

    ;TimeCPU

    5::s%25:s2.:%

    ATimeC#cleACP%Countn%nstructioATimeCPU

    =

    =

    ==

    =

    ==

    =

    A is faster

    b# this much

  • 8/12/2019 Lecture 03 - computer organization and architecture

    12/35

    Chapter 1 Computer Abstractions and Technology 1!

    CP% in More Detail

    %f different instruction classes ta-e different

    numbers of c#cles

    =

    =n

    1i

    ii *Countn%nstructio(CP%C#clesCloc-

    eighted a/erage CP%

    =

    ==

    n

    1i

    i

    i Countn%nstructio

    Countn%nstructio

    CP%Countn%nstructio

    C#clesCloc-

    CP%

    +elati/e fre@uenc#

  • 8/12/2019 Lecture 03 - computer organization and architecture

    13/35

    Chapter 1 Computer Abstractions and Technology 14

    CP% 4!amle

    Alternati/e comiled code se@uences using

    instructions in classes A" ;" C

    Class A ; C

    CP% for class 1 2 3

    %C in se@uence 1 2 1 2

    %C in se@uence 2 1 1

    )e@uence 19 %C 5

    Cloc- C#cles 2>1 F 1>2 F 2>3

    1:

    A/g. CP% 1:&5 2.:

    )e@uence 29 %C E

    Cloc- C#cles >1 F 1>2 F 1>3

    A/g. CP% &E 1.5

  • 8/12/2019 Lecture 03 - computer organization and architecture

    14/35

    Chapter 1 Computer Abstractions and Technology 15

    Performance )ummar#

    Performance deends on Algorithm9 affects %C" ossibl# CP%

    Programming language9 affects %C" CP%

    Comiler9 affects %C" CP%

    %nstruction set architecture9 affects %C" CP%" Tc

    The BIG Picture

    c#cleCloc-

    )econds

    n%nstructio

    c#clesCloc-

    Program

    ns%nstructioTimeCPU =

    G1

  • 8/12/2019 Lecture 03 - computer organization and architecture

    15/35

    Chapter 1 Computer Abstractions and Technology 16

    Pitfall9 Amdahls La$

    %mro/ing an asect of a comuter and e!ecting a

    roortional imro/ement in o/erall erformance

    1.HIallacies

    a

    ndPitfalls

    2:H:

    2: +=n

    Cant be doneJ

    unaffectedaffected

    imro/ed T

    factortimro/emen

    TT +=

    4!amle9 multil# accounts for H:s&1::s ,o$ much imro/ement in multil# erformance to get 5>

    o/erall0

    Corollar#9 ma-e the common case fast

  • 8/12/2019 Lecture 03 - computer organization and architecture

    16/35

    Chapter 1 Computer Abstractions and Technology 17

    )P4C CPU ;enchmar- Programs used to measure erformance

    )uosedl# t#ical of actual $or-load )tandard Performance 4/aluation Cor ()P4C*

    De/elos benchmar-s for CPU" %&'" eb"

    )P4C CPU2::E

    4lased time to e!ecute a selection of rograms Kegligible %&'" so focuses on CPU erformance

    Kormalie relati/e to reference machine )ummarie as geometric mean of erformance ratios

    C%KT2::E (integer* and CIP2::E (floating=oint*

    n

    n

    1i

    iratiotime4!ecution=

  • 8/12/2019 Lecture 03 - computer organization and architecture

    17/35

    Chapter 1 Computer Abstractions and Technology 19

    Iallac#9 Lo$ Po$er at %dle

    Loo- bac- at 6 o$er benchmar- At 1:: load9 25

    At 5: load9 2E (H3*

    At 1: load9 1H: (E1*

    Boogle data center Mostl# oerates at 1: ? 5: load

    At 1:: load less than 1 of the time

    Consider designing rocessors to ma-e o$erroortional to load

  • 8/12/2019 Lecture 03 - computer organization and architecture

    18/35

    Chapter 1 Computer Abstractions and Technology 0

    Pitfall9 M%P) as a Performance Metric

    M%P)9 Millions of %nstructions Per )econd Doesnt account for

    Differences in %)As bet$een comuters

    Differences in comle!it# bet$een instructions

    EE

    E

    1:CP%

    rateCloc-

    1:rateCloc-

    CP%countn%nstructio

    countn%nstructio

    1:time4!ecution

    countn%nstructioM%P)

    =

    =

    =

    CP% /aries bet$een rograms on a gi/en CPU

  • 8/12/2019 Lecture 03 - computer organization and architecture

    19/35

    Definitions ilob#te ? 21:or 1":2 b#tes

    Megab#te? 22:or 1":H"5NE b#tes sometimes rounded8 to 1:Eor 1":::"::: b#tes

    Bigab#te ? 23:or 1":N3"N1"H2 b#tes

    sometimes rounded to 1:Dor 1":::":::"::: b#tes

    Terab#te ? 2A:

    or 1":"511"E2N"NNE b#tes sometimes rounded to 1:12or 1":::":::":::"::: b#tes

    Petab#te ? 25:or 1:2 terab#tes

    sometimes rounded to 1:15or 1":::":::":::":::"::: b#tes

    4!ab#te ? 2E:or 1:2 etab#tes

    )ometimes rounded to 1:1Hor 1":::":::":::":::":::"::: b#tes

    Chapter 1 Computer Abstractions and Technology

  • 8/12/2019 Lecture 03 - computer organization and architecture

    20/35

    Arithmetic

    G3.

  • 8/12/2019 Lecture 03 - computer organization and architecture

    21/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 24

    Arithmetic for Comuters

    'erations on integers Addition and subtraction

    Multilication and di/ision

    Dealing $ith o/erflo$

    Iloating=oint real numbers +eresentation and oerations

    .1%ntroductio

    n

    G3.

  • 8/12/2019 Lecture 03 - computer organization and architecture

    22/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 25

    %nteger Addition

    4!amle9 N F E

    2Additiona

    n

    d)ubtraction

    '/erflo$ if result out of range Adding F/e and ?/e oerands" no o/erflo$

    Adding t$o F/e oerands '/erflo$ if result sign is 1

    Adding t$o ?/e oerands '/erflo$ if result sign is :

  • 8/12/2019 Lecture 03 - computer organization and architecture

    23/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 26

    %nteger )ubtraction

    Add negation of second oerand

    4!amle9 N ? E N F (?E*

    FN9 :::: :::: :::: :111

    ?E9 1111 1111 1111 1:1:

    F19 :::: :::: :::: :::1

    '/erflo$ if result out of range )ubtracting t$o F/e or t$o ?/e oerands" no o/erflo$

    )ubtracting F/e from ?/e oerand '/erflo$ if result sign is :

    )ubtracting ?/e from F/e oerand '/erflo$ if result sign is 1

  • 8/12/2019 Lecture 03 - computer organization and architecture

    24/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 27

    1=bit adder

    li i h fl

  • 8/12/2019 Lecture 03 - computer organization and architecture

    25/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 28

    Dealing $ith '/erflo$

    )ome languages (e.g." C* ignore o/erflo$ Use M%P) addu" addui" subuinstructions

    'ther languages (e.g." Ada" Iortran* re@uireraising an e!cetion

    Use M%P)add

    "addi

    "sub

    instructions 'n o/erflo$" in/o-e e!cetion handler )a/e PC in e!cetion rogram counter (4PC* register Oum to redefined handler address mfc0(mo/e from corocessor reg* instruction can

    retrie/e 4PC /alue" to return after correcti/e action

    A i h i f M l i di

  • 8/12/2019 Lecture 03 - computer organization and architecture

    26/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 29

    Arithmetic for Multimedia

    Brahics and media rocessing oerates on

    /ectors of H=bit and 1E=bit data Use E=bit adder" $ith artitioned carr# chain

    'erate on H>H=bit" >1E=bit" or 2>32=bit /ectors

    )%MD (single=instruction" multile=data* )aturating oerations

    'n o/erflo$" result is largest reresentable /alue c.f. 2s=comlement modulo arithmetic

    4.g." cliing in audio" saturation in /ideo

    M l i li i

    G3.3

  • 8/12/2019 Lecture 03 - computer organization and architecture

    27/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 30

    Multilication

    )tart $ith long=multilication aroach

    1000

    1001

    1000

    00000000

    1000

    1001000

    Length of roduct isthe sum of oerand

    lengths

    multilicand

    multilier

    roduct

    3Multilicat io

    n

    M lti li ti , d

  • 8/12/2019 Lecture 03 - computer organization and architecture

    28/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 31

    Multilication ,ard$are

    Initially 0

    ' ti i d M lti li

  • 8/12/2019 Lecture 03 - computer organization and architecture

    29/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 32

    'timied Multilier

    Perform stes in arallel9 add&shift

    'ne c#cle er artial=roduct addition Thats o-" if fre@uenc# of multilications is lo$

    I t M lti li

  • 8/12/2019 Lecture 03 - computer organization and architecture

    30/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 33

    Iaster Multilier

    Uses multile adders Cost&erformance tradeoff

    Can be ielined )e/eral multilication erformed in arallel

    M%P) Multilication

  • 8/12/2019 Lecture 03 - computer organization and architecture

    31/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 34

    M%P) Multilication

    T$o 32=bit registers for roduct ,%9 most=significant 32 bits

    L'9 least=significant 32=bits

    %nstructions mult rs, rt / multu rs, rt

    E=bit roduct in ,%&L'

    mfhi rd / mflo rd Mo/e from ,%&L' to rd

    Can test ,% /alue to see if roduct o/erflo$s 32 bits

    mul rd, rs, rt Least=significant 32 bits of roduct ? rd

    Di/ision

    G3.

  • 8/12/2019 Lecture 03 - computer organization and architecture

    32/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 35

    Di/ision Chec- for : di/isor

    Long di/ision aroach %f di/isor Q di/idend bits

    1 bit in @uotient" subtract

    'ther$ise : bit in @uotient" bring do$n ne!t di/idend

    bit

    +estoring di/ision Do the subtract" and if remainder goes R

    :" add di/isor bac-

    )igned di/ision Di/ide using absolute /alues

    Ad

  • 8/12/2019 Lecture 03 - computer organization and architecture

    33/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 36

    Di/ision ,ard$are

    %nitiall# di/idend

    %nitiall# di/isor inleft half

    M%P) Di/ision

  • 8/12/2019 Lecture 03 - computer organization and architecture

    34/35

    July 16, 2014 Chapter 3 Arithmetic for Computers 37

    M%P) Di/ision

    Use ,%&L' registers for result ,%9 32=bit remainder

    L'9 32=bit @uotient

    %nstructions

    div rs, rt / divu rs, rt Ko o/erflo$ or di/ide=b#=: chec-ing

    )oft$are must erform chec-s if re@uired

    Use mfhi" mfloto access result

  • 8/12/2019 Lecture 03 - computer organization and architecture

    35/35

    +eferences

    Patterson and ,enness# ? Comuter 'rganiation and DesignThe ,ard$are&)oft$are interface (fourth edition*


Recommended