# EECS 370 Discussion 1 Calvin and Hobbes by Bill Watterson.

## Presentation on theme: "EECS 370 Discussion 1 Calvin and Hobbes by Bill Watterson."— Presentation transcript:

EECS 370 Discussion 1 Calvin and Hobbes by Bill Watterson

EECS 370 Discussion Exam 7:00 – 8:30 Tuesday (Tomorrow!) Bring: Pencil Calculator Notes Sheet – letter-sized, double sided, 1 sheet 2

EECS 370 Discussion Exam Review Multi-cycle Datapath Pipeline Datapath Hazards! Caches 3

EECS 370 Discussion Multi-Cycle Datapath 4

EECS 370 Discussion Multi-Cycle Datapath 5

EECS 370 Discussion Multi-Cycle Datapath Frequency as compared to single-cycle? Do all instructions take the same amount of time? What is the CPI for a multi-cycle machine? 6

EECS 370 Discussion Multi-Cycle Datapath Frequency as compared to single-cycle? Higher Do all instructions take the same amount of time? No! (ADD, NAND, SW, BEQ: 4 cycles, LW: 5 cycles) What is the CPI for a multi-cycle machine? Depends on the instructions you run through it 7

EECS 370 Discussion Multi-Cycle Datapath Why doesn’t multi-cycle have data hazards or control hazards? What does the red Control circle on the diagram do? 8

EECS 370 Discussion Multi-Cycle Datapath Why doesn’t multi-cycle have data hazards or control hazards? Only one instruction is running at a time What does the red Control circle on the diagram do? Sets the control signals for muxes, ALU, Memory, and Reg 9

EECS 370 Discussion Multi-Cycle Datapath Let’s run an instruction through the datapath 10

EECS 370 Discussion Pipeline Datapath 11

EECS 370 Discussion Pipeline Datapath Frequency as compared to single-cycle? Do all instructions take the same amount of time? What is the CPI for a pipelined processor? 12

EECS 370 Discussion Pipeline Datapath Frequency as compared to single-cycle? Higher Do all instructions take the same amount of time? Yes What is the CPI for a pipelined processor? 1 (over many instructions) 13

EECS 370 Discussion Pipeline Datapath Timing Example 1000 Instructions: What is the total execution time? (No Hazards) 14 25% lw 5% sw 50% add/nand 20% beq 6 ns – Register Read/Write 2 ns – ALU Operations 10 ns – Memory Access

EECS 370 Discussion Pipeline Datapath Timing Example 1000 Instructions: What is the total execution time? (No Hazards) 10 * (4+1000) = 10040 ns 15 25% lw 5% sw 50% add/nand 20% beq 6 ns – Register Read/Write 2 ns – ALU Operations 10 ns – Memory Access

EECS 370 Discussion Data Hazards Avoidance Detect and Stall Detect and Forward 16

EECS 370 Discussion Pipeline Datapath Timing Example 1000 Instructions: 37% of ADD/NAND instructions followed by dependent instruction Detect and forward What is the total execution time? 17 25% lw 5% sw 50% add/nand 20% beq 6 ns – Register Read/Write 2 ns – ALU Operations 10 ns – Memory Access

EECS 370 Discussion Pipeline Datapath Timing Example 1000 Instructions: 37% of ADD/NAND instructions followed by dependent instruction Detect and forward What is the total execution time? 10 * (4+1000) = 10040 ns 18 25% lw 5% sw 50% add/nand 20% beq 6 ns – Register Read/Write 2 ns – ALU Operations 10 ns – Memory Access

EECS 370 Discussion Control Hazards No Branches Avoid Detect-and-stall Speculate-and-squash 19

EECS 370 Discussion Control Hazards In a 27 stage pipeline, if Branches are resolved in Stage 14: Which stages must be squashed? 20

EECS 370 Discussion Control Hazards In a 27 stage pipeline, if Branches are resolved in Stage 14: Which stages must be squashed? Stages 1 through 13 21

EECS 370 Discussion Pipeline Datapath Timing Example 1000 Instructions: 10% of BEQ instructions are mispredicted Speculate-and-squash What is the total execution time? 22 25% lw 5% sw 50% add/nand 20% beq 6 ns – Register Read/Write 2 ns – ALU Operations 10 ns – Memory Access

EECS 370 Discussion Pipeline Datapath Timing Example 1000 Instructions: 10% of BEQ instructions are mispredicted Speculate-and-squash What is the total execution time? 10 * (4+1000 + 1000*0.2*0.1*3) = 10640 ns 23 25% lw 5% sw 50% add/nand 20% beq 6 ns – Register Read/Write 2 ns – ALU Operations 10 ns – Memory Access

EECS 370 Discussion Branch Predictors Pattern is: N N N T(Starting at Strongly Taken) What is the mispredict rate? 24 Weakly Taken Strongly Taken Taken Not Taken Strongly Not Taken Weakly Not Taken Taken Not Taken Taken Not Taken

EECS 370 Discussion Branch Predictors Pattern is: N N N T(Starting at Strongly Taken) What is the mispredict rate?25% 25 Weakly Taken Strongly Taken Taken Not Taken Strongly Not Taken Weakly Not Taken Taken Not Taken Taken Not Taken

EECS 370 Discussion Caches What are the types of Locality? What’s the calculation for Block Index bits? What’s the calculation for Set Index bits? 26

EECS 370 Discussion Caches What are the types of Locality? Spatial & Temporal What’s the calculation for Block Index bits? log 2 (block size) What’s the calculation for Set Index bits? log 2 (number of sets) 27

EECS 370 Discussion Types of Caches Fully Associative Blocks map to any cache line 28 Cache TagData Memory 0x100010 0x100420 0x100830 0x100C40 0x101050 0x101460 0x101870 0x101C80 0x102090 0x1024100 0x1028110

EECS 370 Discussion Types of Caches Direct Mapped Blocks map to one cache line 29 Cache TagData Memory 0x100010 0x100420 0x100830 0x100C40 0x101050 0x101460 0x101870 0x101C80 0x102090 0x1024100 0x1028110

EECS 370 Discussion Types of Caches Set Associative Blocks map to any line in a set 30 Cache TagData Memory 0x100010 0x100420 0x100830 0x100C40 0x101050 0x101460 0x101870 0x101C80 0x102090 0x1024100 0x1028110

EECS 370 Discussion Caches What are the Three C’s and how do we determine them? 31

EECS 370 Discussion Caches What are the Three C’s and how do we determine them? Compulsory – if we have never loaded it Capacity – misses in same size fully associative cache Conflict – any additional misses in actual cache 32

EECS 370 Discussion Caches What’s the difference between Write Allocate and No Write Allocate? What’s the difference between Write Through and Write Back? 33

EECS 370 Discussion Caches What’s the difference between Write Allocate and No Write Allocate? Write Allocate – add to cache on write miss No Write Allocate – don’t add to cache What’s the difference between Write Through and Write Back? Write Through – always write to memory Write Back – just write to cache 34

EECS 370 Discussion Caches Timing Example 1000 Instructions: 10% of BEQ instructions are mispredicted, Speculate-and-squash 20% of all memory accesses miss caches. Misses take 20 cycles What is the total execution time? 35 25% lw 5% sw 50% add/nand 20% beq 6 ns – Register Read/Write 2 ns – ALU Operations 10 ns – Memory Access

EECS 370 Discussion Caches Timing Example 1000 Instructions: 10% of BEQ instructions are mispredicted, Speculate-and-squash 20% of all memory accesses miss caches. Misses take 20 cycles What is the total execution time? 10 * (4+1000 + 1000*0.2*0.1*3) + 10 * (1000*.2*20 + 1000*.25*.2*20 +1000*.05*.2*20) = 62640 ns 36 25% lw 5% sw 50% add/nand 20% beq 6 ns – Register Read/Write 2 ns – ALU Operations 10 ns – Memory Access

Download ppt "EECS 370 Discussion 1 Calvin and Hobbes by Bill Watterson."

Similar presentations