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.

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers The Processor
Advertisements

ILP: IntroductionCSCE430/830 Instruction-level parallelism: Introduction CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
COMP381 by M. Hamdi 1 (Recap) Pipeline Hazards. COMP381 by M. Hamdi 2 I n s t r. O r d e r add r1,r2,r3 sub r4,r1,r3 and r6,r1,r7 or r8,r1,r9 xor r10,r1,r11.
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.
CMSC 611: Advanced Computer Architecture Pipelining Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
Advanced Pipelining Optimally Scheduling Code Optimally Programming Code Scheduling for Superscalars (6.9) Exceptions (5.6, 6.8)
1 Advanced Computer Architecture Limits to ILP Lecture 3.
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
Intro to Computer Org. Pipelining, Part 2 – Data hazards + Stalls.
Lecture Objectives: 1)Define pipelining 2)Calculate the speedup achieved by pipelining for a given number of instructions. 3)Define how pipelining improves.
Instruction-Level Parallelism (ILP)
1 A few words about the quiz Closed book, but you may bring in a page of handwritten notes. –You need to know what the “core” MIPS instructions do. –I.
1 IF IDEX MEM L.D F4,0(R2) MUL.D F0, F4, F6 ADD.D F2, F0, F8 L.D F2, 0(R2) WB IF IDM1 MEM WBM2M3M4M5M6M7 stall.
Chapter 12 Pipelining Strategies Performance Hazards.
1  2004 Morgan Kaufmann Publishers Chapter Six. 2  2004 Morgan Kaufmann Publishers Pipelining The laundry analogy.
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 Chapter Six - 2nd Half Pipelined Processor Forwarding, Hazards, Branching EE3055 Web:
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.
CSCE 212 Quiz 9 – 3/30/11 1.What is the clock cycle time based on for single-cycle and for pipelining? 2.What two actions can be done to resolve data hazards?
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
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.
Pipeline Hazard CT101 – Computing Systems. Content Introduction to pipeline hazard Structural Hazard Data Hazard Control Hazard.
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.
Memory/Storage Architecture Lab Computer Architecture Pipelining Basics.
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.
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.
Pipeline Hazards. CS5513 Fall Pipeline Hazards Situations that prevent the next instructions in the instruction stream from executing during its.
CSE 340 Computer Architecture Summer 2014 Basic MIPS Pipelining Review.
CMPE 421 Parallel Computer Architecture
CS 1104 Help Session IV Five Issues in Pipelining Colin Tan, S
2/15/02CSE Data Hazzards Data Hazards in the Pipelined Implementation.
Instructor: Senior Lecturer SOE Dan Garcia CS 61C: Great Ideas in Computer Architecture Pipelining Hazards 1.
LECTURE 7 Pipelining. DATAPATH AND CONTROL We started with the single-cycle implementation, in which a single instruction is executed over a single cycle.
10/11: Lecture Topics Execution cycle Introduction to pipelining
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.
CSCE 212 Chapter 6 Enhancing Performance with Pipelining Instructor: Jason D. Bakos.
1 Pipelining CDA 3101 Discussion Section Question 1 – 6.1 Suppose that time for an ALU operation can be shortened by 25% in the following figure.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
Computer Organization CS224
Stalling delays the entire pipeline
Pipelining Chapter 6.
CSCI206 - Computer Organization & Programming
Single Clock Datapath With Control
Pipeline Implementation (4.6)
CDA 3101 Spring 2016 Introduction to Computer Organization
Appendix A - Pipelining
Morgan Kaufmann Publishers The Processor
Pipelining review.
Pipelining Chapter 6.
The processor: Pipelining and Branching
Current Design.
Pipelining in more detail
CSCI206 - Computer Organization & Programming
Computer Architecture
CSCI206 - Computer Organization & Programming
Pipeline control unit (highly abstracted)
The Processor Lecture 3.6: Control Hazards
Control unit extension for data hazards
Instruction Execution Cycle
Pipeline control unit (highly abstracted)
CS203 – Advanced Computer Architecture
Pipeline Control unit (highly abstracted)
Pipelining.
Control unit extension for data hazards
Appendix C Practice Problem Set 1
Control unit extension for data hazards
Lecture 5: Pipeline Wrap-up, Static ILP
Pipelining Hazards.
Presentation transcript:

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 that is not yet there Data Hazard Why would this happen? - Program specifies instructions in the correct order - We compute things in the correct order - But we write to memory/registers in a later cycle than when values are read for computation –Can’t compute address of the next instruction correctly Control Hazard n In essence, all three problems arise because of the way our pipeline is designed and the order in which instructions are presented. n Can therefore get rid of (or reduce the penalty of) some of the hazards by –restructuring our pipeline Hardware solutions –presenting instructions to the hardware in a better manner Compiler Solutions

5/13/99 Ashish Sabharwal2 Hazards vs. dependencies n Dependencies are a property of the code –Instructions do need to use values computed by previous instructions! –Compiler can sometimes help give us a better code, but we may still have dependencies n Hazards are a property of code + implementation –No hazards on single cycle / multi cycle implementations n Three kinds of dependencies –Read after write (RAW) - don’t want to read a value that has not been written yet - the one we have been looking at - the most natural dependency –Write after read (WAR) - don’t want to overwrite a value that had to be read by some intermediate instruction - required for correctness - Why doesn’t this cause trouble in our pipeline ? –Write after write (WAW) - if a register/memory location is being written twice, I want to preserve the order in which they are written - required for correctness - why doesn’t this cause trouble in our pipeline ? n What about Read after Read ?

5/13/99 Ashish Sabharwal3 The assignment - 1 n 6.9. “… determine as much as you can about the five instructions in the five pipelining stages”, given values of control signals and some of the instruction fields. –Easy –Just look carefully at each field/control value –Difficult part: Need to determine something about all 5 instructions given a snapshot at some cycle. n Given a piece of assembly code, “explain what the forwarding unit is doing during the fifth cycle of execution.” Mention any comparisons that are being made. –Fill the pipeline with 5 instructions –You know all register specifiers at this stage and also know what registers need to be compared Given a sequence of 100 lw instructions, each dependent on the previous, how long will it take to execute them? –Every instruction is dependent on the previous one –Compute the number of cycles you need to stall between every two instructions –Remember the time needed to fill the pipeline

5/13/99 Ashish Sabharwal4 The assignment (2) Situation 1: add $2, _, _ add _, $2, _ Situation 2: sw _, _($2) lw _, _($2) How do these situations differ in terms of hazards on our pipeline? –(We already talked about hazards given dependencies) Memory to memory copy: lw $2, 100($5) sw $2, 200($6) What additional forwarding hardware can be used to improve performance for such a sequence? –We already have a mechanism for better performance for load followed by its use in an ALU op –Do something similar for load followed by store. –Easy!

5/13/99 Ashish Sabharwal5 The assignment (3) Is there a code sequence for which, at some cycle, we generate signals to flush a pipeline as well as to stall? beq $1, $2, TARGET # assume “taken” lw $3, 40($4) add $3, $3, $3 sw $3, 40($4) TARGET: or $10, $11, $12 Do some of the resulting actions cooperate? Do some of the resulting actions conflict? If yes, how can you modify the pipeline to take care of this? n Loop unrolling Given a loop, unroll it to make 3 copies for each iteration. (Note: number of iterations may not be a multiple of 3 !) Now reschedule the code to avoid hazards as far as possible. How much faster is the new code (include stalls)?

5/13/99 Ashish Sabharwal6 The assignment (4) –Loop unrolling: Original - Loop:lw $t0, 0($s1) addu $t0, $t0, $s2 sw $t0, 0($s1) addi $s1, $s1, -4 bne $s1, $zero, Loop Unrolled once to make 2 copies - Loop:lw $t0, 0($s1) addu $t0, $t0, $s2 sw $t0, 0($s1) lw $t0, -4($s1) addu $t0, $t0, $s2 sw $t0, -4($s1) addi $s1, $s1, -8 bgt $s1, 4, Loop beq$s1, $zero, Done Done: –Code scheduling: Try to “space-out” producer and consumer by adding independent instructions in-between.

5/13/99 Ashish Sabharwal7 The assignment (5) n What happens if we change the pipeline to have the following stages ? IF1 IF2 ID EX MEM1 MEM2 WB What hazards are possible? What needs to be forwarded to which stage to avoid these hazards? –Instruction fetch takes 2 cycles instead of 1 –Memory access takes 2 cycles instead of 1