Lecture 18: Pipelining Today’s topics:

Slides:



Advertisements
Similar presentations
1 Lecture: Pipelining Hazards Topics: Basic pipelining implementation, hazards, bypassing HW2 posted, due Wednesday.
Advertisements

1 ECE369 ECE369 Pipelining. 2 ECE369 addm (rs), rt # Memory[R[rs]] = R[rt] + Memory[R[rs]]; Assume that we can read and write the memory in the same cycle.
1 Lecture: Pipelining Extensions Topics: control hazards, multi-cycle instructions, pipelining equations.
1 Lecture: Branch Prediction Topics: branch prediction, bimodal/global/local/tournament predictors, branch target buffer (Section 3.3, notes on class webpage)
1 Lecture 7: Static ILP, Branch prediction Topics: static ILP wrap-up, bimodal, global, local branch prediction (Sections )
1 Lecture 17: Basic Pipelining Today’s topics:  5-stage pipeline  Hazards and instruction scheduling Mid-term exam stats:  Highest: 90, Mean: 58.
1 Lecture 4: Advanced Pipelines Data hazards, control hazards, multi-cycle in-order pipelines (Appendix A.4-A.10)
1 Lecture 7: Out-of-Order Processors Today: out-of-order pipeline, memory disambiguation, basic branch prediction (Sections 3.4, 3.5, 3.7)
1 Lecture 8: Branch Prediction, Dynamic ILP Topics: branch prediction, out-of-order processors (Sections )
1 Lecture 8: Branch Prediction, Dynamic ILP Topics: branch prediction, out-of-order processors (Sections )
Pipelining Andreas Klappenecker CPSC321 Computer Architecture.
1 Lecture 8: Instruction Fetch, ILP Limits Today: advanced branch prediction, limits of ILP (Sections , )
1 Lecture 18: Pipelining Today’s topics:  Hazards and instruction scheduling  Branch prediction  Out-of-order execution Reminder:  Assignment 7 will.
1 Lecture 8: Branch Prediction, Dynamic ILP Topics: static speculation and branch prediction (Sections )
1 Lecture 4: Advanced Pipelines Data hazards, control hazards, multi-cycle in-order pipelines (Appendix A.4-A.10)
1 Lecture 4: Advanced Pipelines Control hazards, multi-cycle in-order pipelines, static ILP (Appendix A.4-A.10, Sections )
1 Lecture 7: Branch prediction Topics: bimodal, global, local branch prediction (Sections )
1 Lecture 7: Static ILP and branch prediction Topics: static speculation and branch prediction (Appendix G, Section 2.3)
Pipeline Hazards. CS5513 Fall Pipeline Hazards Situations that prevent the next instructions in the instruction stream from executing during its.
Winter 2002CSE Topic Branch Hazards in the Pipelined Processor.
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
Lecture 16: Basic Pipelining
Branch Hazards and Static Branch Prediction Techniques
Oct. 18, 2000Machine Organization1 Machine Organization (CS 570) Lecture 4: Pipelining * Jeremy R. Johnson Wed. Oct. 18, 2000 *This lecture was derived.
Branch Prediction CS 3220 Fall 2014 Hadi Esmaeilzadeh Georgia Institute of Technology Some slides adopted from Prof. Milos Prvulovic.
CBP 2005Comp 3070 Computer Architecture1 Last Time … All instructions the same length We learned to program MIPS And a bit about Intel’s x86 Instructions.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 13: Branch prediction (Chapter 4/6)
1 Lecture: Pipelining Extensions Topics: control hazards, multi-cycle instructions, pipelining equations.
Lecture: Out-of-order Processors
Chapter Six.
Lecture: Branch Prediction
Lecture 15: Basic CPU Design
Lecture 16: Basic Pipelining
Lecture: Pipelining Basics
Lecture: Branch Prediction
ELEN 468 Advanced Logic Design
Lecture 17: Pipelining Today’s topics: 5-stage pipeline Hazards
Lecture: Pipelining Extensions
Single Clock Datapath With Control
ECS 154B Computer Architecture II Spring 2009
Lecture: Pipelining Basics
Lecture 6: Advanced Pipelines
Pipelining review.
Lecture 16: Basic Pipelining
Lecture 19: Branches, OOO Today’s topics: Instruction scheduling
Lecture: Pipelining Hazards
Lecture 6: Static ILP, Branch prediction
Lecture 18: Pipelining Today’s topics:
Lecture: Static ILP, Branch Prediction
Lecture: Pipelining Hazards
Lecture 5: Pipelining Basics
Lecture 18: Pipelining Today’s topics:
Pipelining in more detail
Lecture: Branch Prediction
Lecture: Pipelining Hazards
Lecture: Out-of-order Processors
Lecture 17: Pipelining Today’s topics: 5-stage pipeline Hazards.
Lecture 19: Branches, OOO Today’s topics: Instruction scheduling
Chapter Six.
Chapter Six.
Lecture: Pipelining Extensions
Lecture 20: OOO, Memory Hierarchy
Lecture: Pipelining Extensions
Lecture 20: OOO, Memory Hierarchy
Lecture 17: Pipelining Today’s topics: 5-stage pipeline Hazards.
Lecture 4: Advanced Pipelines
Lecture: Pipelining Hazards
Lecture: Pipelining Basics
Lecture 7: Branch Prediction, Dynamic ILP
Pipelining Hazards.
Presentation transcript:

Lecture 18: Pipelining Today’s topics: Hazards and instruction scheduling Branch prediction Out-of-order execution

Example 2 – Bypassing IF IF IF IF IF IF IF IF D/R D/R D/R D/R D/R D/R Show the instruction occupying each stage in each cycle (with bypassing) if I1 is R1+R2R3 and I2 is R3+R4R5 and I3 is R3+R8R9. Identify the input latch for each input operand. CYC-1 CYC-2 CYC-3 CYC-4 CYC-5 CYC-6 CYC-7 CYC-8 IF IF IF IF IF IF IF IF D/R D/R D/R D/R D/R D/R D/R D/R ALU ALU ALU ALU ALU ALU ALU ALU DM DM DM DM DM DM DM DM RW RW RW RW RW RW RW RW

Example 2 – Bypassing IF I1 IF I2 IF I3 IF I4 IF I5 IF IF IF D/R D/R Show the instruction occupying each stage in each cycle (with bypassing) if I1 is R1+R2R3 and I2 is R3+R4R5 and I3 is R3+R8R9. Identify the input latch for each input operand. CYC-1 CYC-2 CYC-3 CYC-4 CYC-5 CYC-6 CYC-7 CYC-8 IF I1 IF I2 IF I3 IF I4 IF I5 IF IF IF D/R D/R I1 D/R I2 D/R I3 D/R I4 D/R D/R D/R L3 L3 L4 L3 L5 L3 ALU ALU ALU I1 ALU I2 ALU I3 ALU ALU ALU DM DM DM DM I1 DM I2 DM I3 DM DM RW RW RW RW RW I1 RW I2 RW I3 RW

Problem 1 IF D/R ALU DM RW IF D/R ALU DM RW IF D/R ALU DM RW add $1, $2, $3 lw $4, 8($1) IF D/R ALU DM RW

Problem 2 IF D/R ALU DM RW IF D/R ALU DM RW IF D/R lw $1, 8($2)

Problem 3 IF D/R ALU DM RW IF D/R ALU DM RW IF D/R ALU DM RW lw $1, 8($2) sw $1, 8($3) IF D/R ALU DM RW

Problem 4 A 7 or 9 stage pipeline IF IF Dec Dec RR ALU RW ALU DM DM RW lw $1, 8($2) add $4, $1, $3

Problem 4 Without bypassing: 4 stalls IF:IF:DE:DE:RR:AL:DM:DM:RW IF: IF :DE:DE:DE:DE:DE :DE:RR:AL:RW With bypassing: 2 stalls IF: IF :DE:DE:DE:DE:RR :AL:RW lw $1, 8($2) add $4, $1, $3 IF IF Dec Dec RR ALU RW ALU DM DM RW

Control Hazards Simple techniques to handle control hazard stalls: for every branch, introduce a stall cycle (note: every 6th instruction is a branch!) assume the branch is not taken and start fetching the next instruction – if the branch is taken, need hardware to cancel the effect of the wrong-path instruction fetch the next instruction (branch delay slot) and execute it anyway – if the instruction turns out to be on the correct path, useful work was done – if the instruction turns out to be on the wrong path, hopefully program state is not lost make a smarter guess and fetch instructions from the expected target

Branch Delay Slots Source: H&P textbook

Pipeline without Branch Predictor PC IF (br) Reg Read Compare Br-target PC + 4

Pipeline with Branch Predictor PC IF (br) Reg Read Compare Br-target Branch Predictor

2-Bit Prediction For each branch, maintain a 2-bit saturating counter: if the branch is taken: counter = min(3,counter+1) if the branch is not taken: counter = max(0,counter-1) … sound familiar? If (counter >= 2), predict taken, else predict not taken The counter attempts to capture the common case for each branch

Bimodal Predictor Branch PC Table of 16K entries 14 bits of 2-bit saturating counters 14 bits Branch PC

Slowdowns from Stalls Perfect pipelining with no hazards  an instruction completes every cycle (total cycles ~ num instructions)  speedup = increase in clock speed = num pipeline stages With hazards and stalls, some cycles (= stall time) go by during which no instruction completes, and then the stalled instruction completes Total cycles = number of instructions + stall cycles