1 Lecture: Pipelining Extensions Topics: control hazards, multi-cycle instructions, pipelining equations.

Slides:



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

1 Pipelining Part 2 CS Data Hazards Data hazards occur when the pipeline changes the order of read/write accesses to operands that differs from.
1 Lecture 5: Static ILP Basics Topics: loop unrolling, VLIW (Sections 2.1 – 2.2)
1 Lecture: Out-of-order Processors Topics: out-of-order implementations with issue queue, register renaming, and reorder buffer, timing, LSQ.
1 Lecture: Static ILP Topics: compiler scheduling, loop unrolling, software pipelining (Sections C.5, 3.2)
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
1 Lecture 10: Static ILP Basics Topics: loop unrolling, static branch prediction, VLIW (Sections 4.1 – 4.4)
Lecture: Pipelining Basics
Instruction-Level Parallelism (ILP)
Chapter 8. Pipelining. Instruction Hazards Overview Whenever the stream of instructions supplied by the instruction fetch unit is interrupted, the pipeline.
1 Lecture: Pipelining Extensions Topics: control hazards, multi-cycle instructions, pipelining equations.
COMP381 by M. Hamdi 1 Pipeline Hazards. COMP381 by M. Hamdi 2 Pipeline Hazards Hazards are situations in pipelining where one instruction cannot immediately.
1 Lecture: Pipeline Wrap-Up and Static ILP Topics: multi-cycle instructions, precise exceptions, deep pipelines, compiler scheduling, loop unrolling, software.
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 3: Pipelining Basics Biggest contributors to performance: clock speed, parallelism Today: basic pipelining implementation (Sections A.1-A.3)
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 5: Pipeline Wrap-up, Static ILP Basics Topics: loop unrolling, VLIW (Sections 2.1 – 2.2) Assignment 1 due at the start of class on Thursday.
1 Lecture 18: Pipelining Today’s topics:  Hazards and instruction scheduling  Branch prediction  Out-of-order execution Reminder:  Assignment 7 will.
1 Lecture 10: ILP Innovations Today: handling memory dependences with the LSQ and innovations for each pipeline stage (Section 3.5)
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 9: Dynamic ILP Topics: out-of-order processors (Sections )
7/2/ _23 1 Pipelining ECE-445 Computer Organization Dr. Ron Hayne Electrical and Computer Engineering.
1 Lecture 7: Branch prediction Topics: bimodal, global, local branch prediction (Sections )
ENGS 116 Lecture 51 Pipelining and Hazards Vincent H. Berk September 30, 2005 Reading for today: Chapter A.1 – A.3, article: Patterson&Ditzel Reading for.
1 Lecture 7: Static ILP and branch prediction Topics: static speculation and branch prediction (Appendix G, Section 2.3)
1 Appendix A Pipeline implementation Pipeline hazards, detection and forwarding Multiple-cycle operations MIPS R4000 CDA5155 Spring, 2007, Peir / University.
Comp Sci pipelining 1 Ch. 13 Pipelining. Comp Sci pipelining 2 Pipelining.
CMPE 421 Parallel Computer Architecture
Lecture 16: Basic Pipelining
1 Lecture 3: Pipelining Basics Today: chapter 1 wrap-up, basic pipelining implementation (Sections C.1 - C.4) Reminders:  Sign up for the class mailing.
1 Lecture: Pipeline Wrap-Up and Static ILP Topics: multi-cycle instructions, precise exceptions, deep pipelines, compiler scheduling, loop unrolling, software.
Lecture 16: Basic Pipelining
Lecture: Pipelining Basics
Lecture 17: Pipelining Today’s topics: 5-stage pipeline Hazards
Lecture: Pipelining Extensions
Lecture: Out-of-order Processors
Pipeline Implementation (4.6)
Appendix C Pipeline implementation
Lecture 6: Advanced Pipelines
Pipelining review.
Lecture 16: Basic Pipelining
Lecture 19: Branches, OOO Today’s topics: Instruction scheduling
Lecture: Pipelining Hazards
Lecture 18: Pipelining Today’s topics:
Lecture: Static ILP Topics: compiler scheduling, loop unrolling, software pipelining (Sections C.5, 3.2)
Lecture: Pipelining Hazards
Lecture 5: Pipelining Basics
Lecture 18: Pipelining Today’s topics:
Pipelining in more detail
Lecture: Pipelining Hazards
Lecture: Out-of-order Processors
Lecture 8: Dynamic ILP Topics: out-of-order processors
Lecture: Static ILP Topics: loop unrolling, software pipelines (Sections C.5, 3.2) HW3 posted, due in a week.
Lecture 19: Branches, OOO Today’s topics: Instruction scheduling
How to improve (decrease) CPI
Lecture: Pipelining Extensions
Lecture 20: OOO, Memory Hierarchy
Lecture: Pipelining Extensions
Lecture 18: Pipelining Today’s topics:
Lecture 4: Advanced Pipelines
Reducing pipeline hazards – three techniques
Dynamic Hardware Prediction
Lecture: Pipelining Hazards
Lecture 10: ILP Innovations
Lecture 9: ILP Innovations
Lecture 5: Pipeline Wrap-up, Static ILP
Lecture 9: Dynamic ILP Topics: out-of-order processors
Lecture: Pipelining Basics
Presentation transcript:

1 Lecture: Pipelining Extensions Topics: control hazards, multi-cycle instructions, pipelining equations

2 Summary For the 5-stage pipeline, bypassing can eliminate delays between the following example pairs of instructions: add/sub R1, R2, R3 add/sub/lw/sw R4, R1, R5 lw R1, 8(R2) sw R1, 4(R3) The following pairs of instructions will have intermediate stalls: lw R1, 8(R2) add/sub/lw R3, R1, R4 or sw R3, 8(R1) fmul F1, F2, F3 fadd F5, F1, F4

3 Problem 8 Consider this 8-stage pipeline (RR and RW take a full cycle) For the following pairs of instructions, how many stalls will the 2 nd instruction experience (with and without bypassing)?  ADD R3  R1+R2 ADD R5  R3+R4  LD R2  [R1] ADD R4  R2+R3  LD R2  [R1] SD R3  [R2]  LD R2  [R1] SD R2  [R3] IFDERRALDM RWAL

4 Problem 8 Consider this 8-stage pipeline (RR and RW take a full cycle) For the following pairs of instructions, how many stalls will the 2 nd instruction experience (with and without bypassing)?  ADD R3  R1+R2 ADD R5  R3+R4 without: 5 with: 1  LD R2  [R1] ADD R4  R2+R3 without: 5 with: 3  LD R2  [R1] SD R3  [R2] without: 5 with: 3  LD R2  [R1] SD R2  [R3] without: 5 with: 1 IFDERRALDM RWAL

5 Control Hazards Simple techniques to handle control hazard stalls:  for every branch, introduce a stall cycle (note: every 6 th instruction is a branch on average!)  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 instructions  predict the next PC and fetch that instr – if the prediction is wrong, cancel the effect of the wrong-path instructions  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

6 Branch Delay Slots

7 Problem 1 Consider a branch that is taken 80% of the time. On average, how many stalls are introduced for this branch for each approach below:  Stall fetch until branch outcome is known  Assume not-taken and squash if the branch is taken  Assume a branch delay slot o You can’t find anything to put in the delay slot o An instr before the branch is put in the delay slot o An instr from the taken side is put in the delay slot o An instr from the not-taken side is put in the slot

8 Problem 1 Consider a branch that is taken 80% of the time. On average, how many stalls are introduced for this branch for each approach below:  Stall fetch until branch outcome is known – 1  Assume not-taken and squash if the branch is taken – 0.8  Assume a branch delay slot o You can’t find anything to put in the delay slot – 1 o An instr before the branch is put in the delay slot – 0 o An instr from the taken side is put in the slot – 0.2 o An instr from the not-taken side is put in the slot – 0.8

9 Multicycle Instructions

10 Effects of Multicycle Instructions Potentially multiple writes to the register file in a cycle Frequent RAW hazards WAW hazards (WAR hazards not possible) Imprecise exceptions because of o-o-o instr completion Note: Can also increase the “width” of the processor: handle multiple instructions at the same time: for example, fetch two instructions, read registers for both, execute both, etc.

11 Precise Exceptions On an exception:  must save PC of instruction where program must resume  all instructions after that PC that might be in the pipeline must be converted to NOPs (other instructions continue to execute and may raise exceptions of their own)  temporary program state not in memory (in other words, registers) has to be stored in memory  potential problems if a later instruction has already modified memory or registers A processor that fulfils all the above conditions is said to provide precise exceptions (useful for debugging and of course, correctness)

12 Dealing with these Effects Multiple writes to the register file: increase the number of ports, stall one of the writers during ID, stall one of the writers during WB (the stall will propagate) WAW hazards: detect the hazard during ID and stall the later instruction Imprecise exceptions: buffer the results if they complete early or save more pipeline state so that you can return to exactly the same state that you left at

13 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 Slowdown because of stalls = 1/ (1 + stall cycles per instr)

14 Pipelining Limits ABC ABC ABCDEF ABCDEF Assume that there is a dependence where the final result of the first instruction is required before starting the second instruction Gap between indep instrs: T + T ovh Gap between dep instrs: T + T ovh Gap between indep instrs: T/3 + T ovh Gap between dep instrs: T + 3T ovh Gap between indep instrs: T/6 + T ovh Gap between dep instrs: T + 6T ovh

15 Problem 2 Assume an unpipelined processor where it takes 5ns to go through the circuits and 0.1ns for the latch overhead. What is the throughput for 20-stage and 40-stage pipelines? Assume that the P.O.P and P.O.C in the unpipelined processor are separated by 2ns. Assume that half the instructions do not introduce a data hazard and half the instructions depend on their preceding instruction.

16 Problem 2 Assume an unpipelined processor where it takes 5ns to go through the circuits and 0.1ns for the latch overhead. What is the throughput for 1-stage, 20-stage and 50-stage pipelines? Assume that the P.O.P and P.O.C in the unpipelined processor are separated by 2ns. Assume that half the instructions do not introduce a data hazard and half the instructions depend on their preceding instruction. 1-stage: 1 instr every 5.1ns 20-stage: first instr takes 0.35ns, the second takes 2.8ns 50-stage: first instr takes 0.2ns, the second takes 4ns Throughputs: 0.20 BIPS, 0.63 BIPS, and 0.48 BIPS

17 ILP Instruction-level parallelism: overlap among instructions: pipelining or multiple instruction execution What determines the degree of ILP?  dependences: property of the program  hazards: property of the pipeline

18 Static vs Dynamic Scheduling Arguments against dynamic scheduling:  requires complex structures to identify independent instructions (scoreboards, issue queue)  high power consumption  low clock speed  high design and verification effort  the compiler can “easily” compute instruction latencies and dependences – complex software is always preferred to complex hardware (?)

19 Title Bullet