CIS429.S00: Lec12- 1 Miscellaneous pipelining topics Why pipelining is so hard: exception handling Advanced pipelining techniques: loop unrolling.

Slides:



Advertisements
Similar presentations
CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
Advertisements

FTC.W99 1 Advanced Pipelining and Instruction Level Parallelism (ILP) ILP: Overlap execution of unrelated instructions gcc 17% control transfer –5 instructions.
Rung-Bin Lin Chapter 4: Exploiting Instruction-Level Parallelism with Software Approaches4-1 Chapter 4 Exploiting Instruction-Level Parallelism with Software.
COMP 4211 Seminar Presentation Based On: Computer Architecture A Quantitative Approach by Hennessey and Patterson Presenter : Feri Danes.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2013 Zhao Zhang Iowa State University Revised from original.
CMSC 611: Advanced Computer Architecture Instruction Level Parallelism Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides.
CSCI 4717/5717 Computer Architecture
1 Lecture: Pipeline Wrap-Up and Static ILP Topics: multi-cycle instructions, precise exceptions, deep pipelines, compiler scheduling, loop unrolling, software.
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.
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;
Caltech CS184b Winter DeHon 1 CS184b: Computer Architecture [Single Threaded Architecture: abstractions, quantification, and optimizations] Day6:
EECC551 - Shaaban #1 Lec # 2 Winter Instruction Pipelining Review:Instruction Pipelining Review: –MIPS In-Order Single-Issue Integer Pipeline.
EECC551 - Shaaban #1 Fall 2005 lec# Pipelining and Instruction-Level Parallelism. Definition of basic instruction block Increasing Instruction-Level.
1 Chapter Six - 2nd Half Pipelined Processor Forwarding, Hazards, Branching EE3055 Web:
Instruction Pipelining Review
Pipeline Exceptions & ControlCSCE430/830 Pipeline: Exceptions & Control CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
EECC551 - Shaaban #1 Fall 2002 lec# Floating Point/Multicycle Pipelining in MIPS Completion of MIPS EX stage floating point arithmetic operations.
EENG449b/Savvides Lec 4.1 1/22/04 January 22, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG Computer.
ENGS 116 Lecture 61 Pipelining Difficulties and MIPS R4000 Vincent H. Berk October 6, 2008 Reading for today: A.3 – A.4, article: Yeager Reading for Wednesday:
EECC551 - Shaaban #1 Lec # 2 Winter Instruction Pipelining Review Instruction pipelining is CPU implementation technique where multiple.
Control Hazards.1 Review: Datapath with Data Hazard Control Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register.
Instruction Pipelining Review:
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.
Instruction Pipelining Review:
EECC551 - Shaaban #1 Lec # 2 Winter DLX Instruction Format 16 bits6 bits5 bits Immediate rdrs1Opcode 6 bits5 bits 11 bits Opcoders1rs2rdfunc.
Computer Architecture
EECC551 - Shaaban #1 Fall 2001 lec# Floating Point/Multicycle Pipelining in DLX Completion of DLX EX stage floating point arithmetic operations.
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.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Pipelining. 10/19/ Outline 5 stage pipelining Structural and Data Hazards Forwarding Branch Schemes Exceptions and Interrupts Conclusion.
Lecture 5: Pipelining Implementation Kai Bu
Implementing Precise Interrupts in Pipelined Processors James E. Smith Andrew R.Pleszkun Presented By: Ravikumar Source:
5/13/99 Ashish Sabharwal1 Pipelining and Hazards n Hazards occur because –Don’t have enough resources (ALU’s, memory,…) Structural Hazard –Need a value.
F00: 1 CS/EE 5810 CS/EE 6810 Exceptions. F00: 2 CS/EE 5810 CS/EE 6810 Exceptions Just when you thought pipelines were not that hard… Pipeline benefit.
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.
CSIE30300 Computer Architecture Unit 06: Containing Control Hazards
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.
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.
Compiler Techniques for ILP
CMSC 611: Advanced Computer Architecture
Instruction-Level Parallelism
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
Pipelining Wrapup Brief overview of the rest of chapter 3
Exceptions & Multi-cycle Operations
Pipelining: Advanced ILP
The processor: Exceptions and Interrupts
The processor: Pipelining and Branching
Instruction Pipelining Review:
Computer Architecture
Architectural Support for OS
Project Instruction Scheduler Assembler for DLX
Overview What are pipeline hazards? Types of hazards
ECE 445 – Computer Organization
Control Hazards Branches (conditional, unconditional, call-return)
Architectural Support for OS
CMSC 611: Advanced Computer Architecture
Lecture 06: Pipelining Implementation
Interrupts and exceptions
CMSC 611: Advanced Computer Architecture
Presentation transcript:

CIS429.S00: Lec12- 1 Miscellaneous pipelining topics Why pipelining is so hard: exception handling Advanced pipelining techniques: loop unrolling

CIS429.S00: Lec12- 2 Exceptions * interrupts * traps * faults Unusual conditions that change the normal execution sequence of the instructions Most common types: –I/O interrupt –timer interrupt –request for OS services –arithmetic overflow or underflow –page fault –misaligned memory reference –memory protection violation –undefined instruction –hardware malfunction, power failure

CIS429.S00: Lec12- 3 Exceptions * interrupts * traps * faults Taxonomy: –synchronous vs. asynchronous –user requested vs. coerced –user maskable vs. non-maskable –within vs. between instructions –resume vs. terminate

CIS429.S00: Lec12- 4 Exception handling without pipelining instruction i interrupt PC --> instruction i+1 instruction i+2... HW: saves PC and other CPU state causes a branch to exception handler code OS: handles the exception calls the OS scheduler which (re)starts process

CIS429.S00: Lec12- 5 Exceptions with pipelining iIFIDEXMEM WB i+1 IFIDEX MEM WB i+2 IFID EX MEMWB etc. interrupt Egads!! exception affects all instructions in the pipeline Sacre Bleu!! there can be more than one exception in a single cycle Ai yah!! in what order should they be handled?? Yikes!! How to shut down the pipeline and restart it correctly??

CIS429.S00: Lec12- 6 Exceptions with pipelining (cont) iIFIDEXMEM WB i+1 IFIDEX MEM i+2 IFID EX etc. interrupt these should complete normally Force a TRAP instruction into the pipeline on the next IF. Turn off all writes for the faulting instruction and all that follow it in the pipeline (zero out the pipeline latches). TRAP will cause state to be saved and branch to OS exception handler.

CIS429.S00: Lec12- 7 Multiple exceptions with pipelining iIFIDEXMEM WB i+1 IFIDEX MEM i+2 IFID EX etc. exceptions these should complete normally Multiple exceptions can occur in an order that is different from instruction order! One instruction can cause multiple exceptions! HW posts all exceptions for a given instruction in an exception status vector associated with that instruction. When an instruction enters WB, its vector is checked and exceptions are handled in the order they would have occurred on unpipelined machine. i-1 i-2

CIS429.S00: Lec12- 8 Restart under pipelining Each posted exception is handled by the appropriate exception handler If pipeline can be stopped and restarted correctly, the pipelines has what are called precise exceptions. This is just a small look at the complications of pipelining. There are many more issues that must be addressed.

CIS429.S00: Lec12- 9 DLX Exceptions Fig. 3.41

CIS429.S00: Lec Advanced pipelining techniques figure 4.1

CIS429.S00: Lec Loop Unrolling A compiler technique whose goal is to increase parallelism. Loop unrolling can decrease penalties due to control hazards Loop unrolling can reduce the number of instructions executed (but decrease the number of instructions in memory) –ILP (instruction level parallelism) - unrolling loops on machine instructions –Higher level parallelism - unrolling loops on high level code (C and Fortran)

CIS429.S00: Lec Example: C code: for {i=100; i >=1; i --} x[i] = x[i] + 23; Machine code: assume R1 has addr of X[100] R2 has the value 23. R3 has the value 100. LOOPLWR4,0(R1) ADD R4,R4,R2 SW 0(R1),R4 SUBIR1,R1,#4 decr ptr to array elmt SUBI R3,R3,#1 decr loop counter BNEZ R3,LOOP

CIS429.S00: Lec Example (cont): hazards Machine code: assume R1 has addr of X[100] R2 has the value 23. R3 has the value 100. LOOPLWR4,0(R1) stall ADD R4,R4,R2 SW 0(R1),R4 SUBIR1,R1,#4 decr ptr to array elmt SUBI R3,R3,#1 decr loop counter stall BNEZ R3,LOOP stall

CIS429.S00: Lec Example (cont): get rid of RAW Machine code: assume R1 has addr of X[100] R2 has the value 23. R3 has the value 100. LOOPLWR4,0(R1) SUBI R3,R3,#1 decr loop counter ADD R4,R4,R2 SW 0(R1),R4 SUBIR1,R1,#4 decr ptr to array elmt BNEZ R3,LOOP stall

CIS429.S00: Lec Example (cont): Unroll the loop using replication LOOPLW R4,0(R1) SUBI R3,R3,#1 ADD R4,R4,R2 SW 0(R1),R4 LW R4,-4(R1) SUBI R3,R3,#1 ADD R4,R4,R2 SW -4(R1),R4 LW R4,-8(R1) SUBI R3,R3,#1 ADD R4,R4,R2 SW -8(R1),R4 LW R4,0-12(R1) SUBI R3,R3,#1 ADD R4,R4,R2 SW -12(R1),R4 SUBI R1,R1,#16 decr ptr to array elmt BNEZ R3,LOOP stall< stalls instead of 100 each replication saves two branch control instructions

CIS429.S00: Lec Example (cont): fill the branch delay slot LOOPLW R4,0(R1) SUBI R3,R3,#1 ADD R4,R4,R2 SW 0(R1),R4 LW R4,-4(R1) SUBI R3,R3,#1 ADD R4,R4,R2 SW -4(R1),R4 LW R4,-8(R1) SUBI R3,R3,#1 ADD R4,R4,R2 SW -8(R1),R4 LW R4,0-12(R1) SUBI R3,R3,#1 ADD R4,R4,R2 SW -12(R1),R4 SUBI R1,R1,#16 decr ptr to array elmt BNEZ R3,LOOP SW 4(R1),R4 adjust the last SW each replication saves two branch control instructions