Data Hazards Dependent instructions add %g1, %g2, %g3 sub %l1, %g3, %o0 Forwarding helps, but not all hazards can be avoided.

Slides:



Advertisements
Similar presentations
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.
Advertisements

CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Pipelining and Control Hazards Oct
COMP 4211 Seminar Presentation Based On: Computer Architecture A Quantitative Approach by Hennessey and Patterson Presenter : Feri Danes.
Instruction Set Issues MIPS easy –Instructions are only committed at MEM  WB transition Other architectures are more difficult –Instructions may update.
1 Lecture: Pipelining Extensions Topics: control hazards, multi-cycle instructions, pipelining equations.
CIS429/529 Winter 2007 Pipelining II- 1 Additional pipelining topics Why pipelining is so hard: exception handling ILP techniques: loop unrolling.
CIS429/529 Winter 2007 Pipelining-1 1 Pipeling RISC/MIPS64 five stage pipeline Basic pipeline performance Pipeline hazards Branch hazards More pipeline.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Sep 24, 2003 Topic: Pipelining -- Intermediate Concepts (Multicycle Operations;
CIS429.S00: Lec10- 1 Control Hazards Created by branch statements BEQZLOC ADDR1,R2,R3. LOCSUBR1,R2,R3 PC needs to be computed but it happens too late in.
Pipeline Exceptions & ControlCSCE430/830 Pipeline: Exceptions & Control CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
EENG449b/Savvides Lec 4.1 1/22/04 January 22, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG Computer.
COMP381 by M. Hamdi 1 (Recap) Control Hazards. COMP381 by M. Hamdi 2 Control (Branch) Hazard A: beqz r2, label B: label: P: Problem: The outcome.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed, Sep 21, 2005 Topic: Pipelining -- Intermediate Concepts (Control Hazards)
CIS429.S00: Lec12- 1 Miscellaneous pipelining topics Why pipelining is so hard: exception handling Advanced pipelining techniques: loop unrolling.
EECC551 - Shaaban #1 Lec # 4 winter Data Hazards Requiring Stall Cycles In some code sequence cases, potential data hazards cannot be handled.
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.
Computer Architecture
1 Manchester Mark I, This was the second (the first was a small- scale prototype) machine built at Cambridge. A production version of this computer.
Pipeline Hazard CT101 – Computing Systems. Content Introduction to pipeline hazard Structural Hazard Data Hazard Control Hazard.
Lecture 5: Pipelining Implementation Kai Bu
Chapter 2 Summary Classification of architectures Features that are relatively independent of instruction sets “Different” Processors –DSP and media processors.
1 Appendix A Pipeline implementation Pipeline hazards, detection and forwarding Multiple-cycle operations MIPS R4000 CDA5155 Spring, 2007, Peir / University.
CMPE 421 Parallel Computer Architecture
Branch Hazards and Static Branch Prediction Techniques
Appendix A. Pipelining: Basic and Intermediate Concept
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline.
Introduction to Computer Organization Pipelining.
LECTURE 10 Pipelining: Advanced ILP. EXCEPTIONS An exception, or interrupt, is an event other than regular transfers of control (branches, jumps, calls,
CSC 4250 Computer Architectures September 22, 2006 Appendix A. Pipelining.
ECE/CS 552: Pipeline Hazards © Prof. Mikko Lipasti Lecture notes based in part on slides created by Mark Hill, David Wood, Guri Sohi, John Shen and Jim.
CS203 – Advanced Computer Architecture Pipelining Review.
Instruction-Level Parallelism
Exceptions Another form of control hazard Could be caused by…
Computer Organization CS224
Stalling delays the entire pipeline
Lecture 15: Pipelining: Branching & Complications
CDA3101 Recitation Section 8
Pipelining Chapter 6.
CSCI206 - Computer Organization & Programming
Lecture: Pipelining Extensions
Pipelining Wrapup Brief overview of the rest of chapter 3
Single Clock Datapath With Control
Pipeline Implementation (4.6)
Appendix C Pipeline implementation
CDA 3101 Spring 2016 Introduction to Computer Organization
Exceptions & Multi-cycle Operations
Appendix A - Pipelining
Pipelining: Advanced ILP
Lecture 6: Advanced Pipelines
Pipelining review.
Pipelining Chapter 6.
The processor: Pipelining and Branching
Pipelining in more detail
CSC 4250 Computer Architectures
CSCI206 - Computer Organization & Programming
The Processor Lecture 3.6: Control Hazards
Lecture: Pipelining Extensions
Lecture: Pipelining Extensions
Project Instruction Scheduler Assembler for DLX
Overview What are pipeline hazards? Types of hazards
CS203 – Advanced Computer Architecture
Lecture 4: Advanced Pipelines
Pipeline Control unit (highly abstracted)
Control Hazards Branches (conditional, unconditional, call-return)
Prof. Sirer CS 316 Cornell University
Interrupts and exceptions
CMSC 611: Advanced Computer Architecture
Pipelining Hazards.
Presentation transcript:

Data Hazards Dependent instructions add %g1, %g2, %g3 sub %l1, %g3, %o0 Forwarding helps, but not all hazards can be avoided

Data Hazard Classification Three types of hazard: –RAW (Read After Write) MIPS register access –WAW (Write After Write) Writes in more than one stage –WAR (Write After Read) Early writes and late reads –RAR (Read After Read) not a hazard

Control Hazards Branches cause a one cycle stall!  –Performance impact of 10%–30%

Reducing Branch Penalty Four simple static schemes: –Freeze pipeline (simple) –Assume not-taken Cannot allow state changes until outcome is known –Assume taken Only useful if destination address is known early –Delayed branch Introduce branch-delay slot(s)

Filling the Delay Slots Compiler must try to find useful work for the delay slot from: –Before the branch Always useful –From target May increase code size –From fall-through Must be very careful

Filling Delay Slots Usually also have a cancelling or nullifying branch –SPARC: annulled branch –Allows more freedom in filling slot

A.3. Implementation of Pipelining Details the implementation of MIPS pipeline

Implementing Control Moving an instruction from ID to EX is called instruction issue MIPS can detect all data hazards in ID and stall before issue Hardware (comparators) detects hazard and inserts a no-op Similarly for forwarding

Minimising Control Hazards Need to test registers and calculate address early MIPS: can do both in ID –Requires Zero test/compare hardware Adder to calculate destination address –One cycle stall Plus one-cycle data hazard stall if register is set by preceding instruction Other architectures: even worse (4-7 cycles)

Problems! Some further complications… –Exceptions (or interrupts, faults, traps, etc.) –Instruction set issues

Dealing with Exceptions Any instruction in the pipeline may cause an exception Different types of exception –Synchronous/asynchronous –User requested/coerced –User maskable/nonmaskable –Within/between instructions –Resumable/terminating Difficult case is synchronous, coerced, resumable exceptions within instructions

Handling Exceptions Pipeline must be shut down and state saved for restart –Force trap into pipeline on next IF –Turn off all writes by current and subsequent instructions –Save PC of exception-generating instruction (plus further PCs for delay slots)

Handling Exceptions Precise Exceptions –Instructions before interrupting instruction are completed –Instructions after the interrupting instruction can be restarted from scratch Difficult for FP Necessary for VM!

MIPS Exception Handling May occur in almost all stages: –IF: page fault, alignment, memory protection –ID: undefined or illegal instruction –EX: arithmetic –MEM: page fault, alignment, protection –WB: none Exceptions may occur simultaneously, or even “out of order”

MIPS Exception Handling To handle in order: –Exception is noted and carried along with instruction through the pipeline –All writes/state-changes are turned off –Exceptions resolved at MEM  WB transition

Instruction Set Issues MIPS easy –Instructions are only committed at MEM  WB transition Other architectures are more difficult –Instructions may update state early –FP more difficult –Memory updating ops (e.g. string moves)