Test 2 review Lectures 5-10.

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

Pipeline Exceptions & ControlCSCE430/830 Pipelining in MIPS MIPS architecture was designed to be pipelined –Simple instruction format (makes IF, ID easy)
Pipeline Example: cycle 1 lw R10,9(R1) sub R11,R2, R3 and R12,R4, R5 or R13,R6, R7.
1 A few words about the quiz Closed book, but you may bring in a page of handwritten notes. –You need to know what the “core” MIPS instructions do. –I.
MIPS Pipelined Datapath
Pipelined Processor II (cont’d) CPSC 321
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Pipelined Processor.
Review: MIPS Pipeline Data and Control Paths
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 18 - Pipelined.
©UCB CS 162 Computer Architecture Lecture 3: Pipelining Contd. Instructor: L.N. Bhuyan
Chapter Six Enhancing Performance with Pipelining
1 Stalling  The easiest solution is to stall the pipeline  We could delay the AND instruction by introducing a one-cycle delay into the pipeline, sometimes.
 The actual result $1 - $3 is computed in clock cycle 3, before it’s needed in cycles 4 and 5  We forward that value to later instructions, to prevent.
1 Stalls and flushes  So far, we have discussed data hazards that can occur in pipelined CPUs if some instructions depend upon others that are still executing.
Supplementary notes for pipelining LW ____,____ SUB ____,____,____ BEQ ____,____,____ ; assume that, condition for branch is not satisfied OR ____,____,____.
Pipeline Data Hazards: Detection and Circumvention Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly.
Pipelined Datapath and Control
CPE432 Chapter 4B.1Dr. W. Abu-Sufah, UJ Chapter 4B: The Processor, Part B-2 Read Section 4.7 Adapted from Slides by Prof. Mary Jane Irwin, Penn State University.
11/13/2015 8:57 AM 1 of 86 Pipelining Chapter 6. 11/13/2015 8:57 AM 2 of 86 Overview of Pipelining Pipelining is an implementation technique in which.
CMPE 421 Parallel Computer Architecture Part 2: Hardware Solution: Forwarding.
CSE431 L07 Overcoming Data Hazards.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 07: Overcoming Data Hazards Mary Jane Irwin (
1/24/ :00 PM 1 of 86 Pipelining Chapter 6. 1/24/ :00 PM 2 of 86 Overview of Pipelining Pipelining is an implementation technique in which.
CSIE30300 Computer Architecture Unit 05: Overcoming Data Hazards Hsin-Chou Chi [Adapted from material by and
CDA 3101 Summer 2003 Introduction to Computer Organization Pipeline Control And Pipeline Hazards 17 July 2003.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 13: Branch prediction (Chapter 4/6)
PROCESSOR PIPELINING YASSER MOHAMMAD. SINGLE DATAPATH DESIGN.
LECTURE 9 Pipeline Hazards. PIPELINED DATAPATH AND CONTROL In the previous lecture, we finalized the pipelined datapath for instruction sequences which.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CSE 340 Computer Architecture Spring 2016 Overcoming Data Hazards.
Interstage Buffers 1 Computer Organization II © McQuain Pipeline Timing Issues Consider executing: add $t2, $t1, $t0 sub $t3, $t1, $t0 or.
Lecture 9 Pipeline Hazards.
Pipeline Timing Issues
Stalling delays the entire pipeline
Note how everything goes left to right, except …
CDA 3101 Spring 2016 Introduction to Computer Organization
Pipelining Chapter 6.
Single Clock Datapath With Control
Appendix C Pipeline implementation
ECS 154B Computer Architecture II Spring 2009
ECS 154B Computer Architecture II Spring 2009
Test 2 review Lectures 5-10.
Forwarding Now, we’ll introduce some problems that data hazards can cause for our pipelined processor, and show how to handle them with forwarding.
Chapter 4 The Processor Part 3
Review: MIPS Pipeline Data and Control Paths
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers The Processor
Pipelining review.
Single-cycle datapath, slightly rearranged
ELEC / Computer Architecture and Design Spring Pipelining (Chapter 6)
Pipelining Chapter 6.
Current Design.
A pipeline diagram Clock cycle lw $t0, 4($sp) IF ID
Pipelining in more detail
Systems Architecture II
Data Hazards Data Hazard
The Processor Lecture 3.6: Control Hazards
Control unit extension for data hazards
Pipelining (II).
Control unit extension for data hazards
Introduction to Computer Organization and Architecture
Pipelining Chapter 6.
Control unit extension for data hazards
Pipelining - 1.
Stalls and flushes Last time, we discussed data hazards that can occur in pipelined CPUs if some instructions depend upon others that are still executing.
MIPS Pipelined Datapath
Problem ??: (?? marks) Consider executing the following code on the MIPS pipelined datapath: add $t5, $t6, $t8 add $t9, $t5, $t4 lw $t3, 100($t9) sub $t2,
©2003 Craig Zilles (derived from slides by Howard Huang)
Pipelined datapath and control
ELEC / Computer Architecture and Design Spring 2015 Pipeline Control and Performance (Chapter 6) Vishwani D. Agrawal James J. Danaher.
Presentation transcript:

Test 2 review Lectures 5-10

Review Test 2 will cover lectures 5-10. There are approx. 8-10 questions in total with the last being a bonus question. The questions take the form of short answers (where you are expected to write briefly on a topic), homework-like problems, and exercises similar to those done in lectures.

Pipeline Exercise Perhaps the most important skill for you to have developed in this unit is the ability to understand and specify the state of a pipeline executing a given set of instructions. This skill indicates that you understand not only how basic pipelining works, but also how hazards are handled in a processor. We will do one of these exercises together.

Pipeline exercise Imagine we have the following instructions being executed. 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5?

Pipeline exercise What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5? 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 IF/ID Field Value PC+4 Instruction

Pipeline exercise What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5? 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 IF/ID Field Value PC+4 44 Instruction add $14, $8, $9 We’ll use a ‘?’ to indicate that a value cannot be known with the information we have. An ‘X’ indicates a “don’t care” for data that we can calculate, but don’t need.

Pipeline exercise 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5? ID/EX Field Value PC+4 RegWrite Instruction MemtoReg branchTarget MemRead Read Data 1 MemWrite Read Data 2 ALUSrc Immediate ALUOp RegisterRs RegDst RegisterRt RegisterRd

Pipeline exercise 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5? ID/EX Field Value PC+4 40 RegWrite 1 Instruction or $13,$6,$7 MemtoReg branchTarget X MemRead Read Data 1 ? MemWrite Read Data 2 ALUSrc Immediate ALUOp 10 RegisterRs 6 RegDst RegisterRt 7 RegisterRd 13

Pipeline exercise 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5? EX/MEM Field Value PC+4 Instruction RegWrite MemtoReg MemRead MemWrite ALUResult writeData writeRegister

Pipeline exercise 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5? EX/MEM Field Value PC+4 36 Instruction and $12,$4,$5 RegWrite 1 MemtoReg MemRead MemWrite ALUResult ? writeData writeRegister 12

Pipeline exercise 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5? MEM/WB Field Value PC+4 Instruction RegWrite MemtoReg writeDataMem writeDataALU writeRegister

Pipeline exercise 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 What are the contents of IF/ID, ID/EX, EX/MEM, and MEM/WB at the end of cycle 5? MEM/WB Field Value PC+4 32 Instruction sub $11,$2,$3 RegWrite 1 MemtoReg writeDataMem ? writeDataALU writeRegister 11

Pipeline exercise 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 MEM/WB Field Value PC+4 Instruction RegWrite MemtoReg writeDataMem writeDataALU writeRegister What is the contents of the MEM/WB register at the end of cycle 4?

Pipeline exercise 24 lw $10, 20($1) 28 sub $11, $2, $3 32 and $12, $4, $5 36 or $13, $6, $7 40 add $14, $8, $9 MEM/WB Field Value PC+4 ? Instruction lw $10,20($1) RegWrite 1 MemtoReg writeDataMem writeDataALU writeRegister 10 What is the contents of the MEM/WB register at the end of cycle 4?

Forwarding exercise Consider the following sequence of instructions. add $1,$5,$3 sw $1,0($2) lw $1,4($2) add $5,$5,$1 sw $1,0($2) Assume we have no forwarding or other hazard detection. Insert NOOPs into the instruction sequence to ensure correct execution.

Forwarding exercise Consider the following sequence of instructions. add $1,$5,$3 noop noop sw $1,0($2) lw $1,4($2) noop noop add $5,$5,$1 sw $1,0($2) Now assume we have forwarding and can stall as necessary. Construct the pipeline diagram for the original instruction sequence, indicating where forwards are made if necessary.

Forwarding exercise Consider the following sequence of instructions. Now assume we have forwarding and can stall as necessary. Construct the pipeline diagram for the instruction sequence, indicating where forwards are made if necessary. add $1,$5,$3 sw $1,0($2) lw $1,4($2) add $5,$5,$1 sw $1,0($2) cycle 1 2 3 4 5 6 7 8 9 10 add IF ID EX MEM WB sw lw STALL

Branch prediction exercise Consider the following sequence of instructions (with their 8-bit addresses indicated on the left). Before this snippet executes, the value of $s0 is always 5, $s1 is always 0, and $s2 is always 1. Imagine that this code snippet is executed twice in a processor which uses a 1-bit branch prediction buffer initialized to not taken. Let’s find out how many mis- predictions will we make over the two executions. 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2

Branch prediction exercise First of all, let’s construct our initial 1-bit BPB. How many indexing bits does this particular code segment need to uniquely identify the instructions? 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2

Branch prediction exercise First of all, let’s construct our initial 1-bit BPB. How many indexing bits does this particular code segment need to uniquely identify the instructions? 2 bits! We’ll begin by predicting not taken for every instruction. 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2 Lower Portion of Address Prediction 0000 0100 1000 1100

Branch prediction exercise Action Prediction Taken 1 Not Taken Over the course of two executions of the code snippet, the branch instruction is taken 8 times and not taken twice. The action and predictions, according to the 1-bit branch prediction buffer, are shown to the right. Our mis-prediction rate is 4/10. What is the mis-prediction rate for a 2-bit branch prediction buffer that is initialized to weakly not taken?

Branch prediction exercise Action Prediction Taken 01 10 11 Not Taken What is the misprediction rate for a 2-bit branch prediction buffer that is initialized to weakly not taken? Our prediction is not as sensitive now – we require multiple wrong decisions to change the prediction. The mis-prediction rate is now 3/10.

Branch prediction exercise Let’s say we have a two-bit branch prediction buffer where every entry is initially weakly not taken. What would the contents of the initially empty branch target buffer look like after a single execution of the code snippet above? 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2 Lower Portion of Address Prediction 0000 01 0100 1000 1100

Branch prediction exercise Let’s say we have a two-bit branch prediction buffer where every entry is initially weakly not taken. What would the contents of the initially empty branch target buffer look like after a single execution of the code snippet above? Lower Portion of Address Prediction 0000 01 0100 10 1000 1100 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2 Lower Portion of Address Tag Target 0000 0100 1101 L1 1000 1100

Branch prediction exercise 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2 Lower Portion of Address Prediction 0000 01 0100 1000 1100 Lower Portion of Address Tag Target 0000 0100 1000 1100 Given the instructions above, and the initially empty BTB and weakly not-taken BPB, draw the pipeline diagram for a single execution of the code snippet, assuming branch prediction happens in the IF stage.

Branch prediction exercise 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2 cycle 1 2 3 4 5 6 7 8 9 10 11 12 13 sub IF ID EX MEM WB bne add …

Branch prediction exercise 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2 cycle 7 8 9 10 11 12 13 14 15 16 17 18 19 sub IF ID EX MEM WB bne

Branch prediction exercise 1101 0000 L1: sub $s0, $s0, $s2 1101 0100 bne $s0, $s1, L1 1101 1000 add $s2, $s2, $s2 cycle 12 13 14 15 16 17 18 19 20 21 22 23 24 bne IF ID EX MEM WB sub add