CSCE430/830 Computer Architecture

Slides:



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

Scoreboarding & Tomasulos Approach Bazat pe slide-urile lui Vincent H. Berk.
Hardware-Based Speculation. Exploiting More ILP Branch prediction reduces stalls but may not be sufficient to generate the desired amount of ILP One way.
Instruction-level Parallelism Compiler Perspectives on Code Movement dependencies are a property of code, whether or not it is a HW hazard depends on.
ILP: IntroductionCSCE430/830 Instruction-level parallelism: Introduction CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
A scheme to overcome data hazards
Dynamic ILP: Scoreboard Professor Alvin R. Lebeck Computer Science 220 / ECE 252 Fall 2008.
Lecture 6: ILP HW Case Study— CDC 6600 Scoreboard & Tomasulo’s Algorithm Professor Alvin R. Lebeck Computer Science 220 Fall 2001.
COMP25212 Advanced Pipelining Out of Order Processors.
Oct. 18, 2000Machine Organization1 Machine Organization (CS 570) Lecture 7: Dynamic Scheduling and Branch Prediction * Jeremy R. Johnson Wed. Nov. 8, 2000.
CMSC 611: Advanced Computer Architecture Scoreboard Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted.
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.
Data Hazards RAW Hazard ADD.D F3, F1, F2 SUB.D F5, F6, F3 No Solution, normal property of programs WAW Hazard DIV.D F3, F1, F2 SUB.D F3, F6, F5 This instruction.
1 IBM System 360. Common architecture for a set of machines. Robert Tomasulo worked on a high-end machine, the Model 91 (1967), on which they implemented.
COMP381 by M. Hamdi 1 Pipelining (Dynamic Scheduling Through Hardware Schemes)
1 Recap (Scoreboarding). 2 Dynamic Scheduling Dynamic Scheduling by Hardware – – Allow Out-of-order execution, Out-of-order completion – – Even though.
ENGS 116 Lecture 71 Scoreboarding Vincent H. Berk October 8, 2008 Reading for today: A.5 – A.6, article: Smith&Pleszkun FRIDAY: NO CLASS Reading for Monday:
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed, Oct 5, 2005 Topic: Instruction-Level Parallelism (Dynamic Scheduling: Scoreboarding)
EENG449b/Savvides Lec 5.1 1/27/04 January 27, 2004 Prof. Andreas Savvides Spring EENG 449bG/CPSC 439bG Computer.
Nov. 9, Lecture 6: Dynamic Scheduling with Scoreboarding and Tomasulo Algorithm (Section 2.4)
Out-of-order execution: Scoreboarding and Tomasulo Week 2
Instruction-Level Parallelism Dynamic Scheduling
1 Lecture 6 Tomasulo Algorithm CprE 581 Computer Systems Architecture, Fall 2009 Zhao Zhang Reading:Textbook 2.4, 2.5.
CET 520/ Gannod1 Section A.8 Dynamic Scheduling using a Scoreboard.
Professor Nigel Topham Director, Institute for Computing Systems Architecture School of Informatics Edinburgh University Informatics 3 Computer Architecture.
1 Images from Patterson-Hennessy Book Machines that introduced pipelining and instruction-level parallelism. Clockwise from top: IBM Stretch, IBM 360/91,
CSC 4250 Computer Architectures September 29, 2006 Appendix A. Pipelining.
04/03/2016 slide 1 Dynamic instruction scheduling Key idea: allow subsequent independent instructions to proceed DIVDF0,F2,F4; takes long time ADDDF10,F0,F8;
CIS 662 – Computer Architecture – Fall Class 11 – 10/12/04 1 Scoreboarding  The following four steps replace ID, EX and WB steps  ID: Issue –
COMP25212 Advanced Pipelining Out of Order Processors.
Instruction-Level Parallelism and Its Dynamic Exploitation
IBM System 360. Common architecture for a set of machines
Images from Patterson-Hennessy Book
/ Computer Architecture and Design
Out of Order Processors
Step by step for Tomasulo Scheme
CS203 – Advanced Computer Architecture
Lecture 6 Score Board And Tomasulo’s Algorithm
9/18/2018 CPE 631 Lecture 09: Instruction Level Parallelism and Its Dynamic Exploitation Aleksandar Milenković, Electrical and Computer.
Lecture 3: Introduction to Advanced Pipelining
Advantages of Dynamic Scheduling
High-level view Out-of-order pipeline
11/14/2018 CPE 631 Lecture 10: Instruction Level Parallelism and Its Dynamic Exploitation Aleksandar Milenković, Electrical and Computer.
CMSC 611: Advanced Computer Architecture
A Dynamic Algorithm: Tomasulo’s
COMP s1 Seminar 3: Dynamic Scheduling
Out of Order Processors
Last Week Talks Any feedback from the talks? What did you like?
CS252 Graduate Computer Architecture Lecture 6 Scoreboard, Tomasulo, Register Renaming February 7th, 2011 John Kubiatowicz Electrical Engineering and.
September 15, 2000 Prof. John Kubiatowicz
John Kubiatowicz (http.cs.berkeley.edu/~kubitron)
John Kubiatowicz (http.cs.berkeley.edu/~kubitron)
CS 704 Advanced Computer Architecture
Checking for issue/dispatch
Lecture 7: Dynamic Scheduling with Tomasulo Algorithm (Section 2.4)
Static vs. dynamic scheduling
Static vs. dynamic scheduling
September 20, 2000 Prof. John Kubiatowicz
1/2/2019 CPE 631 Lecture 10: Instruction Level Parallelism and Its Dynamic Exploitation Aleksandar Milenković, Electrical and Computer.
Tomasulo Organization
Reduction of Data Hazards Stalls with Dynamic Scheduling
Lecture 5 Scoreboarding: Enforce Register Data Dependence
CS152 Computer Architecture and Engineering Lecture 16 Compiler Optimizations (Cont) Dynamic Scheduling with Scoreboards.
Scoreboarding ENGS 116 Lecture 7 Vincent H. Berk October 5, 2005
/ Computer Architecture and Design
John Kubiatowicz (http.cs.berkeley.edu/~kubitron)
September 20, 2000 Prof. John Kubiatowicz
CS252 Graduate Computer Architecture Lecture 6 Introduction to Advanced Pipelining: Out-Of-Order Execution John Kubiatowicz Electrical Engineering and.
High-level view Out-of-order pipeline
Lecture 7 Dynamic Scheduling
Presentation transcript:

CSCE430/830 Computer Architecture Instruction-level parallelism: Scoreboard Lecturer: Prof. Hong Jiang Courtesy of Yifeng Zhu (U. Maine) Fall, 2006 Portions of these slides are derived from: Dave Patterson © UCB

HW Scheme: Dynamic Scheduling Static Scheduling Compiler techniques for scheduling » separate dependent instructions » minimize the number of hazard and stalls e.g.: static branch prediction Dynamic Scheduling 1. Uses hardware to rearrange instructions to reduce stalls 2. Works when real dependence is not known at compile time 3. Compiler simpler 4. Code for one pipeline runs well on another pipeline

The Key idea of Dynamic Scheduling Key Idea: Allow instructions behind stall to proceed. => Instructions executing in parallel. There are multiple execution units, so use them. DIVD F0, F2, F4 ADDD F10, F0, F8 SUBD F12, F8, F14 Enables out-of-order execution => out-of-order completion Even though ADDD stalls, the SUBD has no dependencies and can run. Dynamic pipeline scheduling overcomes the limitations of in-order pipelined execution by allowing out-of-order instruction execution.

Dynamic Scheduling With A Scoreboard The scoreboard is a centralized hardware mechanism In order to execute an instruction as soon as its operands are available and no hazard conditions that prevent it. It dynamically constructs the dependency graph by hardware for a window of instructions as they are issued in program order. A scoreboard is a “data structure” that provides the information necessary for all pieces of the processor to work together. (In Appendix A.8) CDC6600 (1963)

The Key idea of Scoreboards Out-of-order execution divides ID stage: 1. Issue—decode instructions, check for structural hazards 2. Read operands—wait until no data hazards, then read operands Scoreboards allow instruction to execute whenever 1 & 2 hold, not waiting for prior instructions. We will use In order issue, out of order execution, out of order commit ( also called completion) First used in CDC6600 in 1963. Our example has been modified to fit for MIPS. CDC had 4 FP units, 5 memory reference units, 7 integer units. MIPS has 2 FP multiply, 1 FP adder, 1 FP divider, 1 integer.

Typical Scoreboard Structure 2 FP multiply, 1 FP adder, 1 FP divider, 1 integer

Using A Scoreboard: 4 stages 1. Issue —decode instructions & check for structural & WAW hazards (ID1) If a functional unit for the instruction is free (no structural hazards) and no other active instruction has the same destination register (no WAW), the scoreboard issues the instruction to the functional unit and updates its internal data structure. If a structural or WAW hazard exists, then the instruction issue stalls, and no further instructions will issue until these hazards are cleared. 2. Read operands —wait until no data hazards, then read operands (ID2) A source operand is available if no earlier issued active instruction is going to write it, or if the register containing the operand is being written by a currently active functional unit (no RAW). When the source operands are available, the scoreboard tells the functional unit to proceed to read the operands from the registers and begin execution. The scoreboard resolves RAW hazards dynamically in this step, and instructions may be sent into execution out of order. Always done in program order Can be done out of program order

Using A Scoreboard: 4 stages 3. Execution —operate on operands (EX) The functional unit begins execution upon receiving operands. When the result is ready, it notifies the scoreboard that it has completed execution. 4. Write result —finish execution (WB) Once the scoreboard is aware of the fact that the functional unit has completed execution, the scoreboard checks for WAR hazards. If none, it writes results. If WAR, then it stalls the instruction. Example: DIVD F0,F2,F4 ADDD F10,F0,F8 SUBD F8,F8,F14 Scoreboard would stall SUBD until ADDD reads operands

Using A Scoreboard: 3 parts 1. Instruction status—which of 4 steps the instruction is in 2. Functional unit status—Indicates the state of the functional unit (FU). 9 fields for each functional unit Busy—Indicates whether the unit is busy or not Op—Operation to perform in the unit (e.g., + or –) Fi—Destination register Fj, Fk—Source-register numbers Qj, Qk—Functional units producing source registers Fj, Fk Rj, Rk—Flags indicating when Fj, Fk are ready. Set to No after operands are read. 3. Register result status—Indicates which functional unit will write each register, if one exists. Blank when no pending instructions will write that register What you might have thought 1. 4 stages of instruction executino 2.Status of FU: Normal things to keep track of (RAW & structura for busyl): Fi from instruction format of the mahine (Fi is dest) Add unit can Add or Sub Rj, Rk - status of registers (Yes means ready) Qj,Qk - If a no in Rj, Rk, means waiting for a FU to write result; Qj, Qk means wihch FU waiting for it 3.Status of register result (WAW &WAR)s: which FU is going to write into registers Scoreboard on 6600 = size of FU 6.7, 6.8, 6.9, 6.12, 6.13, 6.16, 6.17 FU latencies: Add 2, Mult 10, Div 40 clocks

A Scoreboard Example L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 The following code is run on the MIPS with a scoreboard given earlier with: L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional Unit (FU) # of FUs EX cycles Integer 1 1 Floating Point Multiply 2 10 Floating Point add 1 2 Floating point Divide 1 40 All functional units are not pipelined (similar to CDC6600) Real Data Dependence (RAW) Anti-dependence (WAR) Output Dependence (WAW)

Dependency Graph For Example Code L.D F6, 34 (R2) 1 Example Code L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 1 2 3 4 5 6 L.D F2, 45 (R3) 2 MUL.D F0, F2, F4 3 Date Dependence: (1, 4) (1, 5) (2, 3) (2, 4) (2, 6) (3, 5) (4, 6) Output Dependence: (1, 6) Anti-dependence: (5, 6) SUB.D F8, F6, F2 4 DIV.D F10, F0, F6 5 Real Data Dependence (RAW) Anti-dependence (WAR) Output Dependence (WAW) ADD.D F6, F8, F2 6

Scoreboard Example

Scoreboard Example Cycle 1 Issue LD #1 Shows in which cycle the operation occurred.

Scoreboard Example Cycle 2 LD #2 can’t issue since integer unit is busy. MULT can’t issue because we require in-order issue.

Scoreboard Example Cycle 3

Scoreboard Example Cycle 4

Scoreboard Example Cycle 5 Issue LD #2 since integer unit is now free.

Scoreboard Example Cycle 6 Issue MULT.

Scoreboard Example Cycle 7 MULT can’t read its operands (F2) because LD #2 hasn’t finished.

Scoreboard Example Cycle 8a DIVD issues. MULT and SUBD both waiting for F2.

Scoreboard Example Cycle 8b LD #2 writes F2.

Scoreboard Example Cycle 9 Now MULT and SUBD can both read F2. How can both instructions do this at the same time??

Scoreboard Example Cycle 11 ADDD can’t start because add unit is busy.

Scoreboard Example Cycle 12 SUBD finishes. DIVD waiting for F0.

Scoreboard Example Cycle 13 ADDD issues.

Scoreboard Example Cycle 14

Scoreboard Example Cycle 15

Scoreboard Example Cycle 16

Scoreboard Example Cycle 17 ADDD can’t write because of DIVD. RAW!

Scoreboard Example Cycle 18 Nothing Happens!!

Scoreboard Example Cycle 19 MULT completes execution.

Scoreboard Example Cycle 20 MULT writes.

Scoreboard Example Cycle 21 DIVD loads operands

Scoreboard Example Cycle 22 Now ADDD can write since WAR removed.

Scoreboard Example Cycle 61 DIVD completes execution

Scoreboard Example Cycle 62 DONE!!

Detailed Scoreboard Pipeline Control Read operands Execution complete Instruction status Write result Issue Bookkeeping Rj No; Rk No f(if Qj(f)=FU then Rj(f) Yes); f(if Qk(f)=FU then Rj(f) Yes); Result(Fi(FU)) 0; Busy(FU) No Busy(FU) yes; Op(FU) op; Fi(FU) `D’; Fj(FU) `S1’; Fk(FU) `S2’; Qj Result(‘S1’); Qk Result(`S2’); Rj not Qj; Rk not Qk; Result(‘D’) FU; Rj and Rk Functional unit done Wait until f((Fj( f )≠Fi(FU) or Rj( f )=No) & (Fk( f ) ≠Fi(FU) or Rk( f )=No)) Not busy (FU) and not result(D) 1.Issue - if no structural haards AND non wAW (no Funtional Unit is going to write this destination register; 1 per clock cycle 2. Read -(RAW) if no instructions is going to write a source register of this instruction (alternatively, no write signal this clock cycle) +> gein exection of the instruction; many read ports, so can read many times 3. Execution Complete; multiple during clock cyle 4. Write result - (WAR) If no instructiion is watiing to read the destination register; assume multiple wriite ports; wait for clock cycle to write and tehn read the results; assume can oerlap issue & write show clock cyclesneed 20 or so Latency: minimum is 4 through 4 stages

Summary Techniques to deal with data hazards in instruction pipelines by: Result forwarding to reduce or eliminate RAW hazards Hazard detection hardware to stall the pipeline during hazards Compiler-based static scheduling to separate the dependent instructions minimizing actual hazard-prevention stalls in scheduled code (will discuss in detail next week.) Uses a hardware-based mechanism to rearrange instruction execution order to reduce stalls dynamically at runtime (dynamic scheduling) Better dynamic exploitation of instruction-level parallelism (ILP) We learned scoreboard techniques today We will learn another technique Tomasulo next week. (In Appendix A.8, Chapter 3.2, 3.3)

Typical Scoreboard Structure 2 FP multiply, 1 FP adder, 1 FP divider, 1 integer

Using A Scoreboard: 3 parts 1. Instruction status—which of 4 steps the instruction is in 2. Functional unit status—Indicates the state of the functional unit (FU). 9 fields for each functional unit Busy—Indicates whether the unit is busy or not Op—Operation to perform in the unit (e.g., + or –) Fi—Destination register Fj, Fk—Source-register numbers Qj, Qk—Functional units producing source registers Fj, Fk Rj, Rk—Flags indicating when Fj, Fk are ready. Set to No after operands are read. 3. Register result status—Indicates which functional unit will write each register, if one exists. Blank when no pending instructions will write that register What you might have thought 1. 4 stages of instruction executino 2.Status of FU: Normal things to keep track of (RAW & structura for busyl): Fi from instruction format of the mahine (Fi is dest) Add unit can Add or Sub Rj, Rk - status of registers (Yes means ready) Qj,Qk - If a no in Rj, Rk, means waiting for a FU to write result; Qj, Qk means wihch FU waiting for it 3.Status of register result (WAW &WAR)s: which FU is going to write into registers Scoreboard on 6600 = size of FU 6.7, 6.8, 6.9, 6.12, 6.13, 6.16, 6.17 FU latencies: Add 2, Mult 10, Div 40 clocks

A Scoreboard Example L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 The following code is run on the MIPS with a scoreboard given earlier with: L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional Unit (FU) # of FUs EX cycles Integer 1 1 Floating Point Multiply 2 10 Floating Point add 1 2 Floating point Divide 1 40

Dependency Graph For Example Code L.D F6, 34 (R2) 1 Example Code L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 1 2 3 4 5 6 L.D F2, 45 (R3) 2 MUL.D F0, F2, F4 3 SUB.D F8, F6, F2 4 DIV.D F10, F0, F6 5 Real Data Dependence (RAW) Anti-dependence (WAR) Output Dependence (WAW) ADD.D F6, F8, F2 6

Dependency Graph For Example Code L.D F6, 34 (R2) 1 Example Code L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 1 2 3 4 5 6 L.D F2, 45 (R3) 2 MUL.D F0, F2, F4 3 Date Dependence: (1, 4) (1, 5) (2, 3) (2, 4) (2, 6) (3, 5) (4, 6) Output Dependence: (1, 6) Anti-dependence: (5, 6) SUB.D F8, F6, F2 4 DIV.D F10, F0, F6 5 Real Data Dependence (RAW) Anti-dependence (WAR) Output Dependence (WAW) ADD.D F6, F8, F2 6

Scoreboard Example

Detailed Scoreboard Pipeline Control Read operands Execution complete Instruction status Write result Issue Bookkeeping Rj No; Rk No f(if Qj(f)=FU then Rj(f) Yes); f(if Qk(f)=FU then Rj(f) Yes); Result(Fi(FU)) 0; Busy(FU) No Busy(FU) yes; Op(FU) op; Fi(FU) `D’; Fj(FU) `S1’; Fk(FU) `S2’; Qj Result(‘S1’); Qk Result(`S2’); Rj not Qj; Rk not Qk; Result(‘D’) FU; Rj and Rk Functional unit done Wait until f((Fj( f )≠Fi(FU) or Rj( f )=No) & (Fk( f ) ≠Fi(FU)or Rk( f )=No)) Not Busy(FU) and not Result(D) Avoid Structural and WAW Hazards Avoid RAW Hazards Avoid WAR Hazards 1.Issue - if no structural haards AND non wAW (no Funtional Unit is going to write this destination register; 1 per clock cycle 2. Read -(RAW) if no instructions is going to write a source register of this instruction (alternatively, no write signal this clock cycle) +> gein exection of the instruction; many read ports, so can read many times 3. Execution Complete; multiple during clock cyle 4. Write result - (WAR) If no instructiion is watiing to read the destination register; assume multiple wriite ports; wait for clock cycle to write and tehn read the results; assume can oerlap issue & write show clock cyclesneed 20 or so Latency: minimum is 4 through 4 stages

Limitations of Scoreboard The amount of parallelism available among the instructions (chosen from the same basic block) The number of score entries (The size of the scoreboard determines the size of the window) The number and types of functional units (Structural hazards increase when dynamic scheduling is used) The presence of antidependence and output dependences lead to WAR and WAW stalls. (In Appendix A.8, Chapter 3.2, 3.3)