CS 230 Introduction to Computers and Computer Systems ...

38
CS 230 - Spring 2020 3-1 CS 230 Introduction to Computers and Computer Systems Lecture 14 Performance Measures

Transcript of CS 230 Introduction to Computers and Computer Systems ...

Page 1: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-1

CS 230 – Introduction to Computers and Computer Systems

Lecture 14 – Performance Measures

Page 2: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-2

CPU Clocking

Clock period

also called cycle time

duration of a clock cycle in units of time

SI units of time in seconds per clock cycle

ps = 10-12s

ns = 10-9s

μs = 10-6s

ms = 10-3s

example

250ps = 0.25ns = 250*10-12s

Page 3: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-3

CPU Clocking

Clock frequency

inverse of clock period

measured in cycles per second: Hertz (Hz)

SI units of Hz:

THz = 1012Hz

GHz = 109Hz

MHz = 106Hz

KHz = 103Hz

example

processor with a clock period of 250ps = 250*10-12s

Inverse(250*10-12s) = 0.004*1012Hz = 0.004THz = 4GHz

Page 4: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-4

Instruction Count and CPI

Cycles per instruction

abbreviated CPI

determined by instruction set architecture (ISA)

different CPUs/programs might have different CPI

different instruction types can take different numbers of cycles

not all ISAs use the 5-stage pipeline

Instruction count

total number of instructions run in a program

Page 5: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-5

Instruction Count and CPI

CPU Time

time spent executing instructions in a program

only the instructions that actually run

does not include waiting for input or other devices

Performance equation:

CPU Time = Instruction count CPI Clock period

Page 6: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA?

Example

Instruction Type Branch Memory Everything Else

Cycles 5 13 3

CS 230 - Spring 2020 3-6

addi $3, $0, 14

addi $30, $30, -8

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

Page 7: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA?

Example

Instruction Type Branch Memory Everything Else

Cycles 5 13 3

CS 230 - Spring 2020 3-7

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

Page 8: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA?

Example

Instruction Type Branch Memory Everything Else

Cycles 5 13 3

CS 230 - Spring 2020 3-8

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

Page 9: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA?

Example

Instruction Type Branch Memory Everything Else

Cycles 5 13 3

CS 230 - Spring 2020 3-9

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x 5

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

Page 10: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA?

Example

Instruction Type Branch Memory Everything Else

Cycles 5 13 3

CS 230 - Spring 2020 3-10

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x 5

sw $2, 4($30)

x: lw $2, 0($30) 13

addi $30, $30, 8

jr $31

Page 11: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA?

Example

Instruction Type Branch Memory Everything Else

Cycles 5 13 3

CS 230 - Spring 2020 3-11

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x 5

sw $2, 4($30)

x: lw $2, 0($30) 13

addi $30, $30, 8 3

jr $31 3

Page 12: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA?

Example

Instruction Type Branch Memory Everything Else

Cycles 5 13 3

CS 230 - Spring 2020 3-12

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x 5

sw $2, 4($30)

x: lw $2, 0($30) 13

addi $30, $30, 8 3

jr $31 + 3

43 cycles

Page 13: CS 230 Introduction to Computers and Computer Systems ...

What is the CPI for the processor on that program?

Example

CS 230 - Spring 2020 3-13

addi $3, $0, 14

addi $30, $30, -8

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

Page 14: CS 230 Introduction to Computers and Computer Systems ...

What is the CPI for the processor on that program?

Example

CS 230 - Spring 2020 3-14

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x 5

sw $2, 4($30)

x: lw $2, 0($30) 13

addi $30, $30, 8 3

jr $31 + 3

43 cycles

Page 15: CS 230 Introduction to Computers and Computer Systems ...

What is the CPI for the processor on that program?

Example

CS 230 - Spring 2020 3-15

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x 5

sw $2, 4($30)

x: lw $2, 0($30) 13

addi $30, $30, 8 3

jr $31 + 3

43 cycles

7 instructions

Page 16: CS 230 Introduction to Computers and Computer Systems ...

What is the CPI for the processor running that program?

Example

CS 230 - Spring 2020 3-16

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x 5

sw $2, 4($30)

x: lw $2, 0($30) 13

addi $30, $30, 8 3

jr $31 + 3

43 cycles

7 instructions

43 cycles

7 instructions

Page 17: CS 230 Introduction to Computers and Computer Systems ...

What is the CPI for the processor running that program?

Example

CS 230 - Spring 2020 3-17

addi $3, $0, 14 3

addi $30, $30, -8 3

sw $3, 0($30) 13

bne $3, $0, x 5

sw $2, 4($30)

x: lw $2, 0($30) 13

addi $30, $30, 8 3

jr $31 + 3

43 cycles

7 instructions

43 cycles

7 instructions

= 6.14 CPI

Page 18: CS 230 Introduction to Computers and Computer Systems ...

How long would this program take to execute if the processor was running at a clock frequency of 5GHz?

Example

CS 230 - Spring 2020 3-18

addi $3, $0, 14

addi $30, $30, -8

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

Page 19: CS 230 Introduction to Computers and Computer Systems ...

How long would this program take to execute if the processor was running at a clock frequency of 5GHz?

Example

CS 230 - Spring 2020 3-19

addi $3, $0, 14

addi $30, $30, -8

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

7 instructions

6.14 CPI

Page 20: CS 230 Introduction to Computers and Computer Systems ...

How long would this program take to execute if the processor was running at a clock frequency of 5GHz?

Example

CS 230 - Spring 2020 3-20

addi $3, $0, 14

addi $30, $30, -8

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

7 instructions

6.14 CPI

1

5GHz

Page 21: CS 230 Introduction to Computers and Computer Systems ...

How long would this program take to execute if the processor was running at a clock frequency of 5GHz?

Example

CS 230 - Spring 2020 3-21

addi $3, $0, 14

addi $30, $30, -8

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

7 instructions

6.14 CPI

1

5GHz

= 0.2 ns/cycle

Page 22: CS 230 Introduction to Computers and Computer Systems ...

How long would this program take to execute if the processor was running at a clock frequency of 5GHz?

Example

CS 230 - Spring 2020 3-22

addi $3, $0, 14

addi $30, $30, -8

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

7 instructions

6.14 CPI

1

5GHz

7 instr. 6.14 CPI 0.2ns/cycle

= 0.2 ns/cycle

Page 23: CS 230 Introduction to Computers and Computer Systems ...

How long would this program take to execute if the processor was running at a clock frequency of 5GHz?

Example

CS 230 - Spring 2020 3-23

addi $3, $0, 14

addi $30, $30, -8

sw $3, 0($30)

bne $3, $0, x

sw $2, 4($30)

x: lw $2, 0($30)

addi $30, $30, 8

jr $31

7 instructions

6.14 CPI

1

5GHz

7 instr. 6.14 CPI 0.2ns/cycle = 8.6ns

= 0.2 ns/cycle

Page 24: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA? If that processor ran at 100MHz, how long would it take? What is the CPI?

Try it Yourself

Instruction Type Branch Memory Mult/Div Everything Else

Cycles 6 9 4 2

CS 230 - Spring 2020 3-24

addi $1, $0, 15

addi $2, $1, 3

mult $1, $2

mflo $3

bne $3, $1, x

sw $2, 4($8)

x: jr $31

Page 25: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA? If that processor ran at 100MHz, how long would it take? What is the CPI?

Try it Yourself

Instruction Type Branch Memory Mult/Div Everything Else

Cycles 6 9 4 2

CS 230 - Spring 2020 3-25

addi $1, $0, 15 2

addi $2, $1, 3 2

mult $1, $2 4

mflo $3 2

bne $3, $1, x 6

sw $2, 4($8)

x: jr $31 2

Page 26: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA? If that processor ran at 100MHz, how long would it take? What is the CPI?

Try it Yourself

Instruction Type Branch Memory Mult/Div Everything Else

Cycles 6 9 4 2

CS 230 - Spring 2020 3-26

addi $1, $0, 15 2

addi $2, $1, 3 2

mult $1, $2 4

mflo $3 2

bne $3, $1, x 6

sw $2, 4($8)

x: jr $31 + 2

18 cycles

Page 27: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA? If that processor ran at 100MHz, how long would it take? What is the CPI?

Try it Yourself

Instruction Type Branch Memory Mult/Div Everything Else

Cycles 6 9 4 2

CS 230 - Spring 2020 3-27

addi $1, $0, 15 2 1

addi $2, $1, 3 2 100MHz

mult $1, $2 4

mflo $3 2

bne $3, $1, x 6

sw $2, 4($8)

x: jr $31 + 2

18 cycles

= 0.01 μs/cycle

Page 28: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA? If that processor ran at 100MHz, how long would it take? What is the CPI?

Try it Yourself

Instruction Type Branch Memory Mult/Div Everything Else

Cycles 6 9 4 2

CS 230 - Spring 2020 3-28

addi $1, $0, 15 2 1

addi $2, $1, 3 2 100MHz

mult $1, $2 4

mflo $3 2 0.01μs/cycle 18cycles = 0.18μs

bne $3, $1, x 6

sw $2, 4($8)

x: jr $31 + 2

18 cycles

= 0.01 μs/cycle

Page 29: CS 230 Introduction to Computers and Computer Systems ...

Consider the following cycle time table for some ISA:

How many cycles does the below program take to execute on a processor built with that ISA? If that processor ran at 100MHz, how long would it take? What is the CPI?

Try it Yourself

Instruction Type Branch Memory Mult/Div Everything Else

Cycles 6 9 4 2

CS 230 - Spring 2020 3-29

addi $1, $0, 15 2 1

addi $2, $1, 3 2 100MHz

mult $1, $2 4

mflo $3 2 0.01μs/cycle 18cycles = 0.18μs

bne $3, $1, x 6

sw $2, 4($8) 18 cycles

x: jr $31 + 2 6 instr.

18 cycles

= 0.01 μs/cycle

= 3 CPI

Page 30: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-30

Speedup

How many times faster is some processor than another processor?

depends on the program

Multiplicative comparison of execution time

Example:

processor A takes 10ns to run program X

processor B takes 2ns to run program X

processor B is = 5 times faster than processor A for program X.

10 ns

2 ns

Page 31: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-31

Try it Yourself

Consider two processors, both running the same program. Which is faster on that program? How much faster? Processor A: cycle time 250ps, CPI = 2.0 Processor B: cycle time 500ps, CPI = 1.2

Page 32: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-32

Try it Yourself

Consider two processors, both running the same program. Which is faster on that program? How much faster? Processor A: cycle time 250ps, CPI = 2.0 Processor B: cycle time 500ps, CPI = 1.2

1.2500psI

600psI

ATime CPU

BTime CPU

600psI500ps1.2I

BTime Cycle

BCPICount nInstructio

BTime CPU

500psI250ps2.0I

ATime Cycle

ACPICount nInstructio

ATime CPU

Page 33: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-33

Try it Yourself

Consider two processors, both running the same program. Which is faster on that program? How much faster? Processor A: cycle time 250ps, CPI = 2.0 Processor B: cycle time 500ps, CPI = 1.2

1.2500psI

600psI

ATime CPU

BTime CPU

600psI500ps1.2I

BTime Cycle

BCPICount nInstructio

BTime CPU

500psI250ps2.0I

ATime Cycle

ACPICount nInstructio

ATime CPU

Page 34: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-34

Try it Yourself

Consider two processors, both running the same program. Which is faster on that program? How much faster? Processor A: cycle time 250ps, CPI = 2.0 Processor B: cycle time 500ps, CPI = 1.2

1.2500psI

600psI

ATime CPU

BTime CPU

600psI500ps1.2I

BTime Cycle

BCPICount nInstructio

BTime CPU

500psI250ps2.0I

ATime Cycle

ACPICount nInstructio

ATime CPU

Page 35: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-35

Try it Yourself

Consider two processors, both running the same program. Which is faster on that program? How much faster? Processor A: cycle time 250ps, CPI = 2.0 Processor B: cycle time 500ps, CPI = 1.2

1.2500psI

600psI

ATime CPU

BTime CPU

600psI500ps1.2I

BTime Cycle

BCPICount nInstructio

BTime CPU

500psI250ps2.0I

ATime Cycle

ACPICount nInstructio

ATime CPU

Page 36: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-36

Try it Yourself

Consider two processors, both running the same program. Which is faster on that program? How much faster? Processor A: cycle time 250ps, CPI = 2.0 Processor B: cycle time 500ps, CPI = 1.2

1.2500psI

600psI

ATime CPU

BTime CPU

600psI500ps1.2I

BTime Cycle

BCPICount nInstructio

BTime CPU

500psI250ps2.0I

ATime Cycle

ACPICount nInstructio

ATime CPU

Page 37: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-37

Try it Yourself

Consider two processors, both running the same program. Which is faster on that program? How much faster? Processor A: cycle time 250ps, CPI = 2.0 Processor B: cycle time 500ps, CPI = 1.2

1.2500psI

600psI

ATime CPU

BTime CPU

600psI500ps1.2I

BTime Cycle

BCPICount nInstructio

BTime CPU

500psI250ps2.0I

ATime Cycle

ACPICount nInstructio

ATime CPU

A is faster…

…by this much

Page 38: CS 230 Introduction to Computers and Computer Systems ...

CS 230 - Spring 2020 3-38

Performance Summary

Performance depends on

algorithm: affects instruction count, possibly CPI

programming language: affects instruction count, CPI

compiler: affects instruction count, CPI

instruction set architecture: affects instruction count, CPI

hardware: affects clock cycle