Control Hazards Branches (conditional, unconditional, call-return)

Slides:



Advertisements
Similar presentations
COMP 4211 Seminar Presentation Based On: Computer Architecture A Quantitative Approach by Hennessey and Patterson Presenter : Feri Danes.
Advertisements

Computer Organization and Architecture
CIS429/529 Winter 2007 Pipelining II- 1 Additional pipelining topics Why pipelining is so hard: exception handling ILP techniques: loop unrolling.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Sep 24, 2003 Topic: Pipelining -- Intermediate Concepts (Multicycle Operations;
Review CSE 4711 Computer Design and Organization Architecture = Design + Organization + Performance Topics in this class: –Central processing unit: deeply.
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.
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.
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.
CSE378 Pipelining1 Pipelining Basic concept of assembly line –Split a job A into n sequential subjobs (A 1,A 2,…,A n ) with each A i taking approximately.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Introduction to Embedded Systems
Chapter 10 The Stack Stack: An Abstract Data Type An important abstraction that you will encounter in many applications. We will describe two uses:
Lecture 5: Pipelining Implementation Kai Bu
1 Appendix A Pipeline implementation Pipeline hazards, detection and forwarding Multiple-cycle operations MIPS R4000 CDA5155 Spring, 2007, Peir / University.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Microprogramming and Exceptions Spring 2005 Ilam University.
Spring 2003CSE P5481 Precise Interrupts Precise interrupts preserve the model that instructions execute in program-generated order, one at a time If an.
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.
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.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
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.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Exceptions and Interrupts “Unexpected” events requiring change in flow of control – Different ISAs use the terms differently Exception – Arises within.
Data Hazards Dependent instructions add %g1, %g2, %g3 sub %l1, %g3, %o0 Forwarding helps, but not all hazards can be avoided.
Instruction-Level Parallelism
Interrupts and exceptions
Computer Organization
Exceptions Another form of control hazard Could be caused by…
Computer Organization CS224
Handling Exceptions In MIPS, exceptions managed by a System Control Coprocessor (CP0) Save PC of offending (or interrupted) instruction In MIPS: Exception.
Lecture 15: Pipelining: Branching & Complications
Exceptional Control Flow
Basic Processor Structure/design
Pipelining Wrapup Brief overview of the rest of chapter 3
Morgan Kaufmann Publishers The Processor
Exceptions & Multi-cycle Operations
Computer Design and Organization
Chapter 10 The Stack.
Pipelining: Advanced ILP
The processor: Exceptions and Interrupts
The processor: Pipelining and Branching
Pipelining Basic concept of assembly line
Control unit extension for data hazards
Architectural Support for OS
Chapter 10 And, Finally... The Stack
Instruction Execution Cycle
Project Instruction Scheduler Assembler for DLX
Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Instruction Set Principles
Pipeline Control unit (highly abstracted)
ECE 445 – Computer Organization
Pipelining Basic concept of assembly line
Control unit extension for data hazards
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Pipelining Basic concept of assembly line
Architectural Support for OS
ECE/CS 552: Pipelining and Exceptions
Control unit extension for data hazards
Lecture 06: Pipelining Implementation
Interrupts and exceptions
CMSC 611: Advanced Computer Architecture
Presentation transcript:

Control Hazards Branches (conditional, unconditional, call-return) Interrupts: asynchronous event (e.g., I/O) Occurrence of an interrupt checked at every cycle If an interrupt has been raised, don’t fetch next instruction, flush the pipe, handle the interrupt (see later in the quarter) Exceptions (e.g., arithmetic overflow, page fault etc.) Program and data dependent (repeatable), hence “synchronous” 4/13/2019 CSE378 Exceptions

Exceptions Handling exceptions Occur “within” an instruction, for example: During IF: page fault (see later) During ID: illegal opcode During EX: division by 0 During MEM: page fault; protection violation Handling exceptions A pipeline is restartable if the exception can be handled and the program restarted w/o affecting execution CSE378 Exceptions

Precise exceptions If exception at instruction i then Instructions i-1, i-2 etc complete normally (flush the pipe) Instructions i+1, i+2 etc. already in the pipeline will be “no-oped” and will be restarted from scratch after the exception has been handled Handling precise exceptions: Basic idea Force a trap instruction on the next IF (i.e., transfer of control to a known location in the O.S.) Turn off writes for all instructions i and following When the target of the trap instruction receives control, it saves the PC of the instruction having the exception After the exception has been handled, an instruction “return from trap” will restore the PC. 4/13/2019 CSE378 Exceptions

Exception Handling When an exception occurs Address (PC) of offending instruction saved in Exception Program Counter (a register not visible to ISA). In MIPS should save PC – 4. Transfer control to OS OS handling of the exception. Two methods Register the cause of the exception in a status register which is part of the state of the process. Transfer to a specific routine tailored for the cause of the exception; this is called vectored interrupts CSE378 Exceptions

Exception Handling (ct’d) OS saves the state of the process (registers etc.) OS “clears” the exception Can decide to abort the program Can “correct” the exception Can perform useful functions (e.g., I/O interrupt, syscall etc.) Return to the running process Restores state Restores PC CSE378 Exceptions

Precise exceptions (cont’d) Relatively simple for integer pipeline All current machines have precise exceptions for integer and load-store operations Can lead to loss of performance for pipes with multiple cycles execution stage (f-p see later) 4/13/2019 CSE378 Exceptions

Integer pipeline (RISC) precise exceptions Recall that exceptions can occur in all stages but WB Exceptions must be treated in instruction order Instruction i starts at time t Exception in MEM stage at time t + 3 (treat it first) Instruction i + 1 starts at time t +1 Exception in IF stage at time t + 1 (occurs earlier but treat in 2nd) 4/13/2019 CSE378 Exceptions

Treating exceptions in order Use pipeline registers Status vector of possible exceptions carried on with the instruction. Once an exception is posted, no writing (no change of state; easy in integer pipeline -- just prevent store in memory) When an instruction leaves MEM stage, check for exception. 4/13/2019 CSE378 Exceptions

Difficulties in less RISCy environments Due to instruction set (“long” instructions”) String instructions (but use of general registers to keep state) Instructions that change state before last stage (e.g., autoincrement mode in Vax and update addressing in Power PC) and these changes are needed to complete inst. (require ability to back up) Condition codes (another way to handle branches) Must remember when last changed 4/13/2019 CSE378 Exceptions