1 Chapter Six - 2nd Half Pipelined Processor Forwarding, Hazards, Branching EE3055 Web: www.csc.gatech.edu/copeland/3055.

Slides:



Advertisements
Similar presentations
Lecture Objectives: 1)Define branch prediction. 2)Draw a state machine for a 2 bit branch prediction scheme 3)Explain the impact on the compiler of branch.
Advertisements

Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
Chapter 4 The Processor CprE 381 Computer Organization and Assembly Level Programming, Fall 2013 Zhao Zhang Iowa State University Revised from original.
Pipeline Hazards Pipeline hazards These are situations that inhibit that the next instruction can be processed in the next stage of the pipeline. This.
Pipelined Processor II (cont’d) CPSC 321
11/1/2005Comp 120 Fall November Exam Postmortem 11 Classes to go! Read Sections 7.1 and 7.2 You read 6.1 for this time. Right? Pipelining then.
Pipeline Hazards CS365 Lecture 10. D. Barbara Pipeline Hazards CS465 2 Review  Pipelined CPU  Overlapped execution of multiple instructions  Each on.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
1  1998 Morgan Kaufmann Publishers Chapter Six Enhancing Performance with Pipelining.
Chapter 12 Pipelining Strategies Performance Hazards.
Pipelining III Andreas Klappenecker CPSC321 Computer Architecture.
1  2004 Morgan Kaufmann Publishers Chapter Six. 2  2004 Morgan Kaufmann Publishers Pipelining The laundry analogy.
1 Stalling  The easiest solution is to stall the pipeline  We could delay the AND instruction by introducing a one-cycle delay into the pipeline, sometimes.
L18 – Pipeline Issues 1 Comp 411 – Spring /03/08 CPU Pipelining Issues Finishing up Chapter 6 This pipe stuff makes my head hurt! What have you.
L17 – Pipeline Issues 1 Comp 411 – Fall /1308 CPU Pipelining Issues Finishing up Chapter 6 This pipe stuff makes my head hurt! What have you been.
EENG449b/Savvides Lec 4.1 1/22/04 January 22, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG Computer.
1 CSE SUNY New Paltz Chapter Six Enhancing Performance with Pipelining.
7/2/ _23 1 Pipelining ECE-445 Computer Organization Dr. Ron Hayne Electrical and Computer Engineering.
Pipelined Datapath and Control (Lecture #15) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer.
1  1998 Morgan Kaufmann Publishers Chapter Six Enhancing Performance with Pipelining.
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve performance by increasing instruction throughput.
Pipelining. Overview Pipelining is widely used in modern processors. Pipelining improves system performance in terms of throughput. Pipelined organization.
1 Pipelining Reconsider the data path we just did Each instruction takes from 3 to 5 clock cycles However, there are parts of hardware that are idle many.
Automobile Manufacturing 1. Build frame. 60 min. 2. Add engine. 50 min. 3. Build body. 80 min. 4. Paint. 40 min. 5. Finish.45 min. 275 min. Latency: Time.
Comp Sci pipelining 1 Ch. 13 Pipelining. Comp Sci pipelining 2 Pipelining.
CMPE 421 Parallel Computer Architecture
CS 1104 Help Session IV Five Issues in Pipelining Colin Tan, S
Chapter 6 Pipelined CPU Design. Spring 2005 ELEC 5200/6200 From Patterson/Hennessey Slides Pipelined operation – laundry analogy Text Fig. 6.1.
Chap 6.1 Computer Architecture Chapter 6 Enhancing Performance with Pipelining.
Chapter 6: Pipelining Instructor: Mozafar Bag Mohammadi University of Ilam.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
Computing Systems Pipelining: enhancing performance.
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
Branch Hazards and Static Branch Prediction Techniques
Pipelining Example Laundry Example: Three Stages
Instructor: Senior Lecturer SOE Dan Garcia CS 61C: Great Ideas in Computer Architecture Pipelining Hazards 1.
Introduction to Computer Organization Pipelining.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
Csci 136 Computer Architecture II – Superscalar and Dynamic Pipelining Xiuzhen Cheng
L17 – Pipeline Issues 1 Comp 411 – Fall /23/09 CPU Pipelining Issues Read Chapter This pipe stuff makes my head hurt! What have you been.
CSCE 212 Chapter 6 Enhancing Performance with Pipelining Instructor: Jason D. Bakos.
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.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
Chapter Six.
CS 352H: Computer Systems Architecture
Exceptions Another form of control hazard Could be caused by…
Computer Organization CS224
Instructor: Justin Hsia
Single Clock Datapath With Control
Pipeline Implementation (4.6)
Morgan Kaufmann Publishers The Processor
Pipelining: Advanced ILP
Chapter 4 The Processor Part 3
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers The Processor
Pipelining review.
The processor: Pipelining and Branching
Lecture 9. MIPS Processor Design – Pipelined Processor Design #2
Pipelining in more detail
Computer Architecture
Chapter Six.
Chapter Six.
Control unit extension for data hazards
November 5 No exam results today. 9 Classes to go!
CS203 – Advanced Computer Architecture
Control unit extension for data hazards
CSC3050 – Computer Architecture
Control unit extension for data hazards
Systems Architecture II
Spring 2010 Ilam University
Presentation transcript:

1 Chapter Six - 2nd Half Pipelined Processor Forwarding, Hazards, Branching EE3055 Web:

2 Use temporary results, don’t wait for them to be written –register file forwarding to handle read/write to same register –ALU forwarding Forwarding what if this $2 was $13?

3 Forwarding Forwa- rding Unit Control A B Register Set

4 Load word can still cause a hazard: (structual hazard) –an instruction tries to read a register following a load instruction that writes to the same register. Thus, we need a hazard detection unit to “stall” the load instruction Can't always forward

5 Stalling We can stall the pipeline by keeping an instruction in the same stage This stall may sometimes be avoided by reordering instructions,

6 Hazard Detection Unit Stall by letting an instruction that won’t write anything go forward Forward- ing Unit Hazard Detection Unit

7 When we decide to branch, other instructions are in the pipeline! We are predicting “branch not taken” –need to add hardware for flushing instructions if we are wrong Branch Hazards Special ALU (=) makes branch decision in Instr. Decode stage M Reg If Branch Taken

8 Flushing Instructions Forward- ing Unit Hazard Detection Unit Instruction Flush Control New mini-ALU to detect, or = so branch condition can be determined without going through the normal ALU ALU

9 loop:mul $t4, $t3, $t2 move $t3, $t4 sgt $s6, $t2,1 addi $t2, $t2, -1 bne $s6, $0, loop mul $t4, $t3, $t2 la $a0, newline li $v0, 4 syscall Compiler or CPU hardware must copy first instruction of loop and insert it after “bne”. The actual branch can then take place one instruction later when decision has been made. $t4 must not be written if branch is not taken. Branch Strategies - Assume branch at end of loop will be taken most of the time.

10 loop:mul $t4, $t3, $t2 move $t3, $t4 sgt $s6, $t2,1 addi $t2, $t2, -1 bne $s6, $0, loop mul $t4, $t3, $t2 la $a0, newline li $v0, 4 syscall CPU hardware must contain a table of branch addresses with a bit to show whether branch was taken last time. This bit determines the present assumption about whether the branch will be taken or not. When the prediction is wrong, there must be a “flush” which wastes a clock cycle. Branch Strategies - Dynamic Branch Prediction.

11 Improving Performance Try and avoid stalls! E.g., reorder these instructions: lw $t0, 0($t1) lw $t2, 4($t1) sw $t2, 0($t1) sw $t0, 4($t1) Add a “branch delay slot” –the next instruction after a branch is always executed –rely on compiler to “fill” the slot with something useful Superscalar: start more than one instruction in the same cycle Even with forwarding, $t2 will not be ready until one more clock cycle has passed

12 Dynamic Scheduling The hardware performs the “scheduling” –hardware tries to find instructions to execute –out of order execution is possible –speculative execution and dynamic branch prediction All modern processors are very complicated –DEC Alpha 21264: 9 stage pipeline, 6 instruction issue –PowerPC and Pentium: branch history table –Compiler technology important “Superscalar” CPU - two or more instructions in parallel –speed increased, but not n-fold –more cases of data dependency and hazards.

13 Exception Handling in a Pipelined Computer The hardware must determine which instruction threw the exception –Illegal instruction -> instruction in ID (instr. decode) stage –ALU overflow -> instruction in Execute stage. –Executing instructions turned into NOP’s (flushed). I/O interrupts and hardware malfunctions not due to instruction –Some flexibility to finish some instructions, flush later ones. Method of flushing various stages –Next Instruction set to Interrupt Handler - hex –Instruction Decode - logic turns instruction to all zeroes (NOP) –Execute - Ex.Flush signal causes control lines to go to zero when overflow detected in this stage. Operating system will kill the program and send an error message for: –Illegal instruction, arithmetic overflow, or hardware malfunction. Operating system will save the program, store state, and restart for: –I/O Interrupt or Operating System Service Call.