CPE 631 Lecture 11: Instruction Level Parallelism and Its Dynamic Exploitation

Similar documents
CPE 631 Lecture 10: Instruction Level Parallelism and Its Dynamic Exploitation

CPE 631 Lecture 10: Instruction Level Parallelism and Its Dynamic Exploitation

Page 1. Recall from Pipelining Review. Lecture 16: Instruction Level Parallelism and Dynamic Execution #1: Ideas to Reduce Stalls

Recall from Pipelining Review. Lecture 16: Instruction Level Parallelism and Dynamic Execution #1: Ideas to Reduce Stalls

Page 1. Recall from Pipelining Review. Lecture 15: Instruction Level Parallelism and Dynamic Execution

吳俊興高雄大學資訊工程學系. October Example to eleminate WAR and WAW by register renaming. Tomasulo Algorithm. A Dynamic Algorithm: Tomasulo s Algorithm

CISC 662 Graduate Computer Architecture. Lecture 10 - ILP 3

Processor: Superscalars Dynamic Scheduling

CS252 Graduate Computer Architecture Lecture 6. Recall: Software Pipelining Example

ELEC 5200/6200 Computer Architecture and Design Fall 2016 Lecture 9: Instruction Level Parallelism

Review: Compiler techniques for parallelism Loop unrolling Ÿ Multiple iterations of loop in software:

Reduction of Data Hazards Stalls with Dynamic Scheduling So far we have dealt with data hazards in instruction pipelines by:

COSC4201 Instruction Level Parallelism Dynamic Scheduling

Metodologie di Progettazione Hardware-Software

Superscalar Architectures: Part 2

Hardware-based speculation (2.6) Multiple-issue plus static scheduling = VLIW (2.7) Multiple-issue, dynamic scheduling, and speculation (2.

Outline Review: Basic Pipeline Scheduling and Loop Unrolling Multiple Issue: Superscalar, VLIW. CPE 631 Session 19 Exploiting ILP with SW Approaches

Static vs. Dynamic Scheduling

Website for Students VTU NOTES QUESTION PAPERS NEWS RESULTS

ILP concepts (2.1) Basic compiler techniques (2.2) Reducing branch costs with prediction (2.3) Dynamic scheduling (2.4 and 2.5)

Handout 2 ILP: Part B

Adapted from David Patterson s slides on graduate computer architecture

EITF20: Computer Architecture Part3.2.1: Pipeline - 3

Instruction Level Parallelism. Taken from

Chapter 3 Instruction-Level Parallelism and its Exploitation (Part 1)

Instruction-Level Parallelism and Its Exploitation

CPE 631 Lecture 09: Instruction Level Parallelism and Its Dynamic Exploitation

Load1 no Load2 no Add1 Y Sub Reg[F2] Reg[F6] Add2 Y Add Reg[F2] Add1 Add3 no Mult1 Y Mul Reg[F2] Reg[F4] Mult2 Y Div Reg[F6] Mult1

Dynamic Scheduling. Better than static scheduling Scoreboarding: Tomasulo algorithm:

Instruction Level Parallelism (ILP)

CSE 820 Graduate Computer Architecture. week 6 Instruction Level Parallelism. Review from Last Time #1

CS252 Graduate Computer Architecture Lecture 8. Review: Scoreboard (CDC 6600) Explicit Renaming Precise Interrupts February 13 th, 2010

Topics. Digital Systems Architecture EECE EECE Predication, Prediction, and Speculation

Instruction Level Parallelism

Instruction Level Parallelism

Graduate Computer Architecture. Chapter 3. Instruction Level Parallelism and Its Dynamic Exploitation

Four Steps of Speculative Tomasulo cycle 0

EECC551 Exam Review 4 questions out of 6 questions

Chapter 4 The Processor 1. Chapter 4D. The Processor

The basic structure of a MIPS floating-point unit

Lecture-13 (ROB and Multi-threading) CS422-Spring

NOW Handout Page 1. Review from Last Time #1. CSE 820 Graduate Computer Architecture. Lec 8 Instruction Level Parallelism. Outline

5008: Computer Architecture

Scoreboard information (3 tables) Four stages of scoreboard control

Multicycle ALU Operations 2/28/2011. Diversified Pipelines The Path Toward Superscalar Processors. Limitations of Our Simple 5 stage Pipeline

Functional Units. Registers. The Big Picture: Where are We Now? The Five Classic Components of a Computer Processor Input Control Memory

CISC 662 Graduate Computer Architecture Lecture 11 - Hardware Speculation Branch Predictions

NOW Handout Page 1. Outline. Csci 211 Computer System Architecture. Lec 4 Instruction Level Parallelism. Instruction Level Parallelism

Hardware-based Speculation

CSE 502 Graduate Computer Architecture. Lec 8-10 Instruction Level Parallelism

NOW Handout Page 1. Review from Last Time. CSE 820 Graduate Computer Architecture. Lec 7 Instruction Level Parallelism. Recall from Pipelining Review

Computer Architectures. Chapter 4. Tien-Fu Chen. National Chung Cheng Univ.

Hardware-based Speculation

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Recall from Pipelining Review. Instruction Level Parallelism and Dynamic Execution

Advanced Computer Architecture CMSC 611 Homework 3. Due in class Oct 17 th, 2012

332 Advanced Computer Architecture Chapter 3. Dynamic scheduling, out-of-order execution, register renaming and speculative execution

What is ILP? Instruction Level Parallelism. Where do we find ILP? How do we expose ILP?

ESE 545 Computer Architecture Instruction-Level Parallelism (ILP) and Static & Dynamic Instruction Scheduling Instruction level parallelism

Chapter 3: Instruction Level Parallelism (ILP) and its exploitation. Types of dependences

Exploiting ILP with SW Approaches. Aleksandar Milenković, Electrical and Computer Engineering University of Alabama in Huntsville

Outline EEL 5764 Graduate Computer Architecture. Chapter 2 - Instruction Level Parallelism. Recall from Pipelining Review

High Performance Computer Architecture Prof. Ajit Pal Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Super Scalar. Kalyan Basu March 21,

Advanced Computer Architecture

Chapter 4. Advanced Pipelining and Instruction-Level Parallelism. In-Cheol Park Dept. of EE, KAIST

NOW Handout Page 1. COSC 5351 Advanced Computer Architecture

Instruction Frequency CPI. Load-store 55% 5. Arithmetic 30% 4. Branch 15% 4

Chapter 3 (CONT II) Instructor: Josep Torrellas CS433. Copyright J. Torrellas 1999,2001,2002,2007,

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

CISC 662 Graduate Computer Architecture Lecture 13 - CPI < 1

Computer Architecture 计算机体系结构. Lecture 4. Instruction-Level Parallelism II 第四讲 指令级并行 II. Chao Li, PhD. 李超博士

EEC 581 Computer Architecture. Instruction Level Parallelism (3.6 Hardware-based Speculation and 3.7 Static Scheduling/VLIW)

Advanced issues in pipelining

Multiple Instruction Issue and Hardware Based Speculation

Review: Evaluating Branch Alternatives. Lecture 3: Introduction to Advanced Pipelining. Review: Evaluating Branch Prediction

Compiler Optimizations. Lecture 7 Overview of Superscalar Techniques. Memory Allocation by Compilers. Compiler Structure. Register allocation

EEC 581 Computer Architecture. Lec 7 Instruction Level Parallelism (2.6 Hardware-based Speculation and 2.7 Static Scheduling/VLIW)

CMSC411 Fall 2013 Midterm 2 Solutions

Multi-cycle Instructions in the Pipeline (Floating Point)

Page # CISC 662 Graduate Computer Architecture. Lecture 8 - ILP 1. Pipeline CPI. Pipeline CPI (I) Michela Taufer

Advanced Computer Architecture. Chapter 4: More sophisticated CPU architectures

Lecture 4: Introduction to Advanced Pipelining

CS 614 COMPUTER ARCHITECTURE II FALL 2004

ESE 545 Computer Architecture Instruction-Level Parallelism (ILP): Speculation, Reorder Buffer, Exceptions, Superscalar Processors, VLIW

ELE 818 * ADVANCED COMPUTER ARCHITECTURES * MIDTERM TEST *

Complex Pipelining COE 501. Computer Architecture Prof. Muhamed Mudawar

CS433 Midterm. Prof Josep Torrellas. October 19, Time: 1 hour + 15 minutes

Page 1. CISC 662 Graduate Computer Architecture. Lecture 8 - ILP 1. Pipeline CPI. Pipeline CPI (I) Pipeline CPI (II) Michela Taufer

CS433 Homework 2 (Chapter 3)

Donn Morrison Department of Computer Science. TDT4255 ILP and speculation

Complex Pipelining: Out-of-order Execution & Register Renaming. Multiple Function Units

COSC 6385 Computer Architecture - Instruction Level Parallelism (II)

Tomasulo s Algorithm

Computer Architecture A Quantitative Approach, Fifth Edition. Chapter 3. Instruction-Level Parallelism and Its Exploitation

CS433 Homework 2 (Chapter 3)

EECC551 Review. Dynamic Hardware-Based Speculation

Case Study IBM PowerPC 620

COSC 6385 Computer Architecture - Pipelining (II)

EE382A Lecture 7: Dynamic Scheduling. Department of Electrical Engineering Stanford University

Transcription:

Lecture 11: Instruction Level Parallelism and Its Dynamic Exploitation Aleksandar Milenkovic, milenka@ece.uah.edu Electrical and Computer Engineering University of Alabama in Huntsville Outline Instruction Level Parallelism (ILP) Recap: Data Dependencies Extended MIPS Pipeline and Hazards Dynamic scheduling with a scoreboard 18/02/2004 UAH- 2 Aleksandar Milenkovich 1

Techniques to exploit parallelism Technique (Section in the textbook) Reduces Forwarding and bypassing (Section A.2) Delayed branches (A.2) Basic dynamic scheduling (A.8) Dynamic scheduling with register renaming (3.2) Dynamic branch prediction (3.4) Issuing multiple instruction per cycle (3.6) Speculation (3.7) Dynamic memory disambiguation (3.2, 3.7) Loop Unrolling (4.1) Basic compiler pipeline scheduling (A.2, 4.1) Compiler dependence analysis (4.4) Software pipelining and trace scheduling (4.3) Data hazard (DH) stalls Control hazard stalls DH stalls (RAW) WAR and WAW stalls CH stalls Ideal CPI Data and control stalls RAW stalls w. memory CH stalls DH stalls Ideal CPI, DH stalls Ideal CPI and DH stalls Compiler speculation (4.4) Ideal CPI, and D/CH stalls 18/02/2004 UAH- 3 Scoreboard Results For the CDC 6600 70% improvement for Fortran 150% improvement for hand coded assembly language cost was similar to one of the functional units surprisingly low bulk of cost was in the extra busses Still this was in ancient time no caches & no main semiconductor memory no software pipelining compilers? So, why is it coming back performance via ILP 18/02/2004 UAH- 4 Aleksandar Milenkovich 2

Scoreboard Limitations Amount of parallelism among instructions can we find independent instructions to execute Number of scoreboard entries how far ahead the pipeline can look for independent instructions (we assume a window does not extend beyond a branch) Number and types of functional units avoid structural hazards Presence of antidependences and output dependences WAR and WAW stalls become more important 18/02/2004 UAH- 5 Tomasulo s Algorithm Used in IBM 360/91 FPU (before caches) Goal: high FP performance without special compilers Conditions: Small number of floating point registers (4 in 360) prevented interesting compiler scheduling of operations Long memory accesses and long FP delays This led Tomasulo to try to figure out how to get more effective registers renaming in hardware! Why Study 1966 Computer? The descendants of this have flourished! Alpha 21264, HP 8000, MIPS 10000, Pentium III, PowerPC 604, 18/02/2004 UAH- 6 Aleksandar Milenkovich 3

Tomasulo s Algorithm (cont d) Control & buffers distributed with Function Units (FU) FU buffers called reservation stations => buffer the operands of instructions waiting to issue; Registers in instructions replaced by values or pointers to reservation stations (RS) => register renaming avoids WAR, WAW hazards More reservation stations than registers, so can do optimizations compilers can t Results to FU from RS, not through registers, over Common Data Bus that broadcasts results to all FUs Load and Stores treated as FUs with RSs as well Integer instructions can go past branches, allowing FP ops beyond basic block in FP queue 18/02/2004 UAH- 7 Tomasulo-based FPU for MIPS From Mem FP Op Queue Load Buffers Load1 Load2 Load3 Load4 Load5 Load6 Add1 Add2 Add3 FP FP adders adders From Instruction Unit Mult1 Mult2 Reservation Stations FP Registers FP FP multipliers Store Buffers Store1 Store2 Store3 To Mem Common Data Bus (CDB) 18/02/2004 UAH- 8 Aleksandar Milenkovich 4

Reservation Station Components Op: Operation to perform in the unit (e.g., + or ) Vj, Vk: Value of Source operands Store buffers has V field, result to be stored Qj, Qk: Reservation stations producing source registers (value to be written) Note: Qj/Qk=0 => source operand is already available in Vj /Vk Store buffers only have Qi for RS producing result Busy: Indicates reservation station or FU is busy Indicates which functional unit will write each register, if one exists. Blank when no pending instructions that will write that register. 18/02/2004 UAH- 9 Three Stages of Tomasulo Algorithm 1. Issue get instruction from FP Op Queue If reservation station free (no structural hazard), control issues instr & sends operands (renames registers) 2. Execute operate on operands (EX) When both operands ready then execute; if not ready, watch Common Data Bus for result 3. Write result finish execution (WB) Write it on Common Data Bus to all awaiting units; mark reservation station available Normal data bus: data + destination ( go to bus) Common data bus: data + source ( come from bus) 64 bits of data + 4 bits of Functional Unit source address Write if matches expected Functional Unit (produces result) Does the broadcast Example speed: 2 clocks for Fl.pt. +,-; 10 for * ; 40 clks for / 18/02/2004 UAH- 10 Aleksandar Milenkovich 5

Tomasulo Example Instruction stream Instruction status: LD F6 34+ R2 Load1 No LD F2 45+ R3 Load2 No MULTD F0 F2 F4 Load3 No SUBD F8 F6 F2 DIVD F10 F0 F6 ADDD F6 F8 F2 3 Load/Buffers RS FU count down Add1 Add2 Add3 Mult1 Mult2 No No No No No 3 FP Adder R.S. 2 FP Mult R.S. : 0 FU Clock cycle counter 18/02/2004 UAH- 11 Instruction status: Tomasulo Example Cycle 1 LD F6 34+ R2 1 Load1 Yes 34+R2 LD F2 45+ R3 Load2 No MULTD F0 F2 F4 Load3 No SUBD F8 F6 F2 DIVD F10 F0 F6 ADDD F6 F8 F2 RS Add1 Add2 Add3 Mult1 Mult2 No No No No No : 1 FU Load1 18/02/2004 UAH- 12 Aleksandar Milenkovich 6

Instruction status: Tomasulo Example Cycle 2 LD F6 34+ R2 1 Load1 Yes 34+R2 LD F2 45+ R3 2 Load2 Yes 45+R3 MULTD F0 F2 F4 Load3 No SUBD F8 F6 F2 DIVD F10 F0 F6 ADDD F6 F8 F2 RS Add1 Add2 Add3 Mult1 Mult2 No No No No No : 2 FU Load2 Load1 Note: Can have multiple loads outstanding 18/02/2004 UAH- 13 Instruction status: Tomasulo Example Cycle 3 LD F6 34+ R2 1 3 Load1 Yes 34+R2 LD F2 45+ R3 2 Load2 Yes 45+R3 MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 DIVD F10 F0 F6 ADDD F6 F8 F2 RS Add1 No Add2 No Mult1 Yes MULTD R(F4) Load2 Mult2 No : 3 FU Mult1 Load2 Load1 Note: registers names are removed ( renamed ) in Reservation Stations; MULT issued Load1 completing; what is waiting for Load1? 18/02/2004 UAH- 14 Aleksandar Milenkovich 7

Instruction status: Tomasulo Example Cycle 4 LD F2 45+ R3 2 4 Load2 Yes 45+R3 MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 DIVD F10 F0 F6 ADDD F6 F8 F2 RS Add1 Yes SUBD M(A1) Load2 Add2 No Mult1 Yes MULTD R(F4) Load2 Mult2 No : 4 FU Mult1 Load2 M(A1) Add1 Load2 completing; what is waiting for Load2? 18/02/2004 UAH- 15 Instruction status: Tomasulo Example Cycle 5 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 DIVD F10 F0 F6 5 ADDD F6 F8 F2 RS 2 Add1 Yes SUBD M(A1) M(A2) Add2 No 10 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 5 FU Mult1 M(A2) M(A1) Add1 Mult2 Timer starts down for Add1, Mult1 18/02/2004 UAH- 16 Aleksandar Milenkovich 8

Instruction status: Tomasulo Example Cycle 6 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 RS 1 Add1 Yes SUBD M(A1) M(A2) Add2 Yes ADDD M(A2) Add1 9 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 6 FU Mult1 M(A2) Add2 Add1 Mult2 Issue ADDD here despite name dependency on F6? 18/02/2004 UAH- 17 Instruction status: Tomasulo Example Cycle 7 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 7 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 RS 0 Add1 Yes SUBD M(A1) M(A2) Add2 Yes ADDD M(A2) Add1 8 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 7 FU Mult1 M(A2) Add2 Add1 Mult2 Add1 (SUBD) completing; what is waiting for it? 18/02/2004 UAH- 18 Aleksandar Milenkovich 9

Instruction status: Tomasulo Example Cycle 8 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 RS Add1 No 2 Add2 Yes ADDD (M-M) M(A2) 7 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 8 FU Mult1 M(A2) Add2 (M-M) Mult2 18/02/2004 UAH- 19 Instruction status: Tomasulo Example Cycle 9 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 RS Add1 No 1 Add2 Yes ADDD (M-M) M(A2) 6 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 9 FU Mult1 M(A2) Add2 (M-M) Mult2 18/02/2004 UAH- 20 Aleksandar Milenkovich 10

Instruction status: Tomasulo Example Cycle 10 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 10 RS Add1 No 0 Add2 Yes ADDD (M-M) M(A2) 5 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 10 FU Mult1 M(A2) Add2 (M-M) Mult2 Add2 (ADDD) completing; what is waiting for it? 18/02/2004 UAH- 21 Instruction status: Tomasulo Example Cycle 11 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No 4 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 11 FU Mult1 M(A2) (M-M+M(M-M) Mult2 Write result of ADDD here? All quick instructions complete in this cycle! 18/02/2004 UAH- 22 Aleksandar Milenkovich 11

Instruction status: Tomasulo Example Cycle 12 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No 3 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 12 FU Mult1 M(A2) (M-M+M(M-M) Mult2 18/02/2004 UAH- 23 Instruction status: Tomasulo Example Cycle 13 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No 2 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 13 FU Mult1 M(A2) (M-M+M(M-M) Mult2 18/02/2004 UAH- 24 Aleksandar Milenkovich 12

Instruction status: Tomasulo Example Cycle 14 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No 1 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 14 FU Mult1 M(A2) (M-M+M(M-M) Mult2 18/02/2004 UAH- 25 Instruction status: Tomasulo Example Cycle 15 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 15 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No 0 Mult1 Yes MULTD M(A2) R(F4) Mult2 Yes DIVD M(A1) Mult1 : 15 FU Mult1 M(A2) (M-M+M(M-M) Mult2 Mult1 (MULTD) completing; what is waiting for it? 18/02/2004 UAH- 26 Aleksandar Milenkovich 13

Instruction status: Tomasulo Example Cycle 16 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 15 16 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No Mult1 No 40 Mult2 Yes DIVD M*F4 M(A1) : 16 FU M*F4 M(A2) (M-M+M(M-M) Mult2 Just waiting for Mult2 (DIVD) to complete 18/02/2004 UAH- 27 Instruction status: Tomasulo Example Cycle 55 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 15 16 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No Mult1 No 1 Mult2 Yes DIVD M*F4 M(A1) : 55 FU M*F4 M(A2) (M-M+M(M-M) Mult2 18/02/2004 UAH- 28 Aleksandar Milenkovich 14

Instruction status: Tomasulo Example Cycle 56 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 15 16 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 56 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No Mult1 No 0 Mult2 Yes DIVD M*F4 M(A1) : 56 FU M*F4 M(A2) (M-M+M(M-M) Mult2 Mult2 (DIVD) is completing; what is waiting for it? 18/02/2004 UAH- 29 Instruction status: Tomasulo Example Cycle 57 LD F2 45+ R3 2 4 5 Load2 No MULTD F0 F2 F4 3 15 16 Load3 No SUBD F8 F6 F2 4 7 8 DIVD F10 F0 F6 5 56 57 ADDD F6 F8 F2 6 10 11 RS Add1 No Add2 No Mult1 No Mult2 Yes DIVD M*F4 M(A1) : 56 FU M*F4 M(A2) (M-M+M(M-M) Result Once again: In-order issue, out-of-order execution and out-of-order completion. 18/02/2004 UAH- 30 Aleksandar Milenkovich 15

Tomasulo Drawbacks Complexity delays of 360/91, MIPS 10000, Alpha 21264, IBM PPC 620 in CA:AQA 2/e, but not in silicon! Many associative stores (CDB) at high speed Performance limited by Common Data Bus Each CDB must go to multiple functional units high capacitance, high wiring density Number of functional units that can complete per cycle limited to one! Multiple CDBs more FU logic for parallel assoc stores Non-precise interrupts! We will address this later 18/02/2004 UAH- 31 Tomasulo Loop Example Loop: LD F0 0(R1) MULTD F4 F0 F2 SD F4 0 R1 SUBI R1 R1 #8 BNEZ R1 Loop This time assume Multiply takes 4 clocks Assume 1st load takes 8 clocks (L1 cache miss), 2nd load takes 1 clock (hit) To be clear, will show clocks for SUBI, BNEZ Reality: integer instructions ahead of Fl. Pt. Instructions Show 2 iterations 18/02/2004 UAH- 32 Aleksandar Milenkovich 16

Loop Example Instruction status: 1 LD F0 0 R1 Load1 No 1 MULTD F4 F0 F2 Load2 No 1 SD F4 0 R1 Load3 No Iteration 2 LD F0 0 R1 Store1 No 2 MULTD F4 F0 F2 Store2 No Count 2 SD F4 0 R1 Store3 No Added Store Buffers Mult1 No SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop Instruction Loop 0 80 Fu Value of Register used for address, iteration control 18/02/2004 UAH- 33 Loop Example Cycle 1 Instruction status: 1 LD F0 0 R1 1 Load1 Yes 80 Load2 No Load3 No Store1 No Store2 No Store3 No Mult1 No SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 1 80 Fu Load1 18/02/2004 UAH- 34 Aleksandar Milenkovich 17

Loop Example Cycle 2 Instruction status: 1 LD F0 0 R1 1 Load1 Yes 80 1 MULTD F4 F0 F2 2 Load2 No Load3 No Store1 No Store2 No Store3 No Mult1 Yes Multd R(F2) Load1 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 2 80 Fu Load1 Mult1 18/02/2004 UAH- 35 Loop Example Cycle 3 Instruction status: 1 LD F0 0 R1 1 Load1 Yes 80 1 MULTD F4 F0 F2 2 Load2 No 1 SD F4 0 R1 3 Load3 No Store1 Yes 80 Mult1 Store2 No Store3 No Mult1 Yes Multd R(F2) Load1 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 3 80 Fu Load1 Mult1 Implicit renaming sets up data flow graph 18/02/2004 UAH- 36 Aleksandar Milenkovich 18

Loop Example Cycle 4 Instruction status: 1 LD F0 0 R1 1 Load1 Yes 80 1 MULTD F4 F0 F2 2 Load2 No 1 SD F4 0 R1 3 Load3 No Store1 Yes 80 Mult1 Store2 No Store3 No Mult1 Yes Multd R(F2) Load1 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 4 80 Fu Load1 Mult1 18/02/2004 UAH- 37 Loop Example Cycle 5 Instruction status: 1 LD F0 0 R1 1 Load1 Yes 80 1 MULTD F4 F0 F2 2 Load2 No 1 SD F4 0 R1 3 Load3 No Store1 Yes 80 Mult1 Store2 No Store3 No Mult1 Yes Multd R(F2) Load1 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 5 72 Fu Load1 Mult1 18/02/2004 UAH- 38 Aleksandar Milenkovich 19

Loop Example Cycle 6 Instruction status: 1 LD F0 0 R1 1 Load1 Yes 80 1 MULTD F4 F0 F2 2 Load2 Yes 72 1 SD F4 0 R1 3 Load3 No 2 LD F0 0 R1 6 Store1 Yes 80 Mult1 Store2 No Store3 No Mult1 Yes Multd R(F2) Load1 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 6 72 Fu Load2 Mult1 18/02/2004 UAH- 39 Loop Example Cycle 7 Instruction status: 1 LD F0 0 R1 1 Load1 Yes 80 1 MULTD F4 F0 F2 2 Load2 Yes 72 1 SD F4 0 R1 3 Load3 No 2 LD F0 0 R1 6 Store1 Yes 80 Mult1 2 MULTD F4 F0 F2 7 Store2 No Store3 No Mult1 Yes Multd R(F2) Load1 SUBI R1 R1 #8 Mult2 Yes Multd R(F2) Load2 BNEZ R1 Loop 7 72 Fu Load2 Mult2 18/02/2004 UAH- 40 Aleksandar Milenkovich 20

Loop Example Cycle 8 Instruction status: 1 LD F0 0 R1 1 Load1 Yes 80 1 MULTD F4 F0 F2 2 Load2 Yes 72 1 SD F4 0 R1 3 Load3 No 2 LD F0 0 R1 6 Store1 Yes 80 Mult1 2 MULTD F4 F0 F2 7 Store2 Yes 72 Mult2 2 SD F4 0 R1 8 Store3 No Mult1 Yes Multd R(F2) Load1 SUBI R1 R1 #8 Mult2 Yes Multd R(F2) Load2 BNEZ R1 Loop 8 72 Fu Load2 Mult2 18/02/2004 UAH- 41 Loop Example Cycle 9 Instruction status: 1 LD F0 0 R1 1 9 Load1 Yes 80 1 MULTD F4 F0 F2 2 Load2 Yes 72 1 SD F4 0 R1 3 Load3 No 2 LD F0 0 R1 6 Store1 Yes 80 Mult1 2 MULTD F4 F0 F2 7 Store2 Yes 72 Mult2 2 SD F4 0 R1 8 Store3 No Mult1 Yes Multd R(F2) Load1 SUBI R1 R1 #8 Mult2 Yes Multd R(F2) Load2 BNEZ R1 Loop 9 72 Fu Load2 Mult2 18/02/2004 UAH- 42 Aleksandar Milenkovich 21

Loop Example Cycle 10 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 Load2 Yes 72 1 SD F4 0 R1 3 Load3 No 2 LD F0 0 R1 6 10 Store1 Yes 80 Mult1 2 MULTD F4 F0 F2 7 Store2 Yes 72 Mult2 2 SD F4 0 R1 8 Store3 No 4 Mult1 Yes Multd M[80] R(F2) SUBI R1 R1 #8 Mult2 Yes Multd R(F2) Load2 BNEZ R1 Loop 10 64 Fu Load2 Mult2 18/02/2004 UAH- 43 Loop Example Cycle 11 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 Load2 No 1 SD F4 0 R1 3 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 Yes 80 Mult1 2 MULTD F4 F0 F2 7 Store2 Yes 72 Mult2 2 SD F4 0 R1 8 Store3 No 3 Mult1 Yes Multd M[80] R(F2) SUBI R1 R1 #8 4 Mult2 Yes Multd M[72] R(F2) BNEZ R1 Loop 11 64 Fu Load3 Mult2 18/02/2004 UAH- 44 Aleksandar Milenkovich 22

Loop Example Cycle 12 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 Load2 No 1 SD F4 0 R1 3 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 Yes 80 Mult1 2 MULTD F4 F0 F2 7 Store2 Yes 72 Mult2 2 SD F4 0 R1 8 Store3 No 2 Mult1 Yes Multd M[80] R(F2) SUBI R1 R1 #8 3 Mult2 Yes Multd M[72] R(F2) BNEZ R1 Loop 12 64 Fu Load3 Mult2 18/02/2004 UAH- 45 Loop Example Cycle 13 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 Load2 No 1 SD F4 0 R1 3 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 Yes 80 Mult1 2 MULTD F4 F0 F2 7 Store2 Yes 72 Mult2 2 SD F4 0 R1 8 Store3 No 1 Mult1 Yes Multd M[80] R(F2) SUBI R1 R1 #8 2 Mult2 Yes Multd M[72] R(F2) BNEZ R1 Loop 13 64 Fu Load3 Mult2 18/02/2004 UAH- 46 Aleksandar Milenkovich 23

Loop Example Cycle 14 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 14 Load2 No 1 SD F4 0 R1 3 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 Yes 80 Mult1 2 MULTD F4 F0 F2 7 Store2 Yes 72 Mult2 2 SD F4 0 R1 8 Store3 No 0 Mult1 Yes Multd M[80] R(F2) SUBI R1 R1 #8 1 Mult2 Yes Multd M[72] R(F2) BNEZ R1 Loop 14 64 Fu Load3 Mult2 18/02/2004 UAH- 47 Loop Example Cycle 15 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 14 15 Load2 No 1 SD F4 0 R1 3 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 Yes 80 [80]*R2 2 MULTD F4 F0 F2 7 15 Store2 Yes 72 Mult2 2 SD F4 0 R1 8 Store3 No Mult1 No SUBI R1 R1 #8 0 Mult2 Yes Multd M[72] R(F2) BNEZ R1 Loop 15 64 Fu Load3 Mult2 18/02/2004 UAH- 48 Aleksandar Milenkovich 24

Loop Example Cycle 16 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 14 15 Load2 No 1 SD F4 0 R1 3 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 Yes 80 [80]*R2 2 MULTD F4 F0 F2 7 15 16 Store2 Yes 72 [72]*R2 2 SD F4 0 R1 8 Store3 No 4 Mult1 Yes Multd R(F2) Load3 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 16 64 Fu Load3 Mult1 18/02/2004 UAH- 49 Loop Example Cycle 17 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 14 15 Load2 No 1 SD F4 0 R1 3 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 Yes 80 [80]*R2 2 MULTD F4 F0 F2 7 15 16 Store2 Yes 72 [72]*R2 2 SD F4 0 R1 8 Store3 Yes 64 Mult1 Mult1 Yes Multd R(F2) Load3 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 17 64 Fu Load3 Mult1 18/02/2004 UAH- 50 Aleksandar Milenkovich 25

Loop Example Cycle 18 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 14 15 Load2 No 1 SD F4 0 R1 3 18 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 Yes 80 [80]*R2 2 MULTD F4 F0 F2 7 15 16 Store2 Yes 72 [72]*R2 2 SD F4 0 R1 8 Store3 Yes 64 Mult1 Mult1 Yes Multd R(F2) Load3 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 18 64 Fu Load3 Mult1 18/02/2004 UAH- 51 Loop Example Cycle 19 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 No 1 MULTD F4 F0 F2 2 14 15 Load2 No 1 SD F4 0 R1 3 18 19 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 No 2 MULTD F4 F0 F2 7 15 16 Store2 Yes 72 [72]*R2 2 SD F4 0 R1 8 19 Store3 Yes 64 Mult1 Mult1 Yes Multd R(F2) Load3 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 19 56 Fu Load3 Mult1 18/02/2004 UAH- 52 Aleksandar Milenkovich 26

Loop Example Cycle 20 Instruction status: 1 LD F0 0 R1 1 9 10 Load1 Yes 56 1 MULTD F4 F0 F2 2 14 15 Load2 No 1 SD F4 0 R1 3 18 19 Load3 Yes 64 2 LD F0 0 R1 6 10 11 Store1 No 2 MULTD F4 F0 F2 7 15 16 Store2 No 2 SD F4 0 R1 8 19 20 Store3 Yes 64 Mult1 Mult1 Yes Multd R(F2) Load3 SUBI R1 R1 #8 Mult2 No BNEZ R1 Loop 20 56 Fu Load1 Mult1 Once again: In-order issue, out-of-order execution and out-of-order completion. 18/02/2004 UAH- 53 Why can Tomasulo overlap iterations of loops? Register renaming Multiple iterations use different physical destinations for registers (dynamic loop unrolling) Reservation stations Permit instruction issue to advance past integer control flow operations Also buffer old values of registers - totally avoiding the WAR stall that we saw in the scoreboard Other perspective: Tomasulo building data flow dependency graph on the fly 18/02/2004 UAH- 54 Aleksandar Milenkovich 27

Tomasulo s scheme offers 2 major advantages (1) the distribution of the hazard detection logic distributed reservation stations and the CDB If multiple instructions waiting on single result, & each instruction has other operand, then instructions can be released simultaneously by broadcast on CDB If a centralized register file were used, the units would have to read their results from the registers when register buses are available. (2) the elimination of stalls for WAW and WAR hazards 18/02/2004 UAH- 55 What about Precise Interrupts? Tomasulo had: In-order issue, out-of-order execution, and out-of-order completion Need to fix the out-of-order completion aspect so that we can find precise breakpoint in instruction stream 18/02/2004 UAH- 56 Aleksandar Milenkovich 28

Relationship between precise interrupts and speculation Speculation is a form of guessing Important for branch prediction: Need to take our best shot at predicting branch direction If we speculate and are wrong, need to back up and restart execution to point at which we predicted incorrectly: This is exactly same as precise exceptions! Technique for both precise interrupts/exceptions and speculation: in-order completion or commit 18/02/2004 UAH- 57 HW support for precise interrupts Need HW buffer for results of uncommitted instructions: reorder buffer 3 fields: instr, destination, value Use reorder buffer number instead of reservation station when execution completes Supplies operands between execution complete & commit (Reorder buffer can be operand source => more registers like RS) Instructions commit Once instruction commits, result is put into register As a result, easy to undo speculated instructions on mispredicted branches or exceptions FP Op Queue Res Stations FP Adder Reorder Buffer FP Regs Res Stations FP Adder 18/02/2004 UAH- 58 Aleksandar Milenkovich 29

Four Steps of Speculative Tomasulo Algorithm 1. Issue get instruction from FP Op Queue If reservation station and reorder buffer slot free, issue instr & send operands & reorder buffer no. for destination (this stage sometimes called dispatch ) 2. Execution operate on operands (EX) When both operands ready then execute; if not ready, watch CDB for result; when both in reservation station, execute; checks RAW (sometimes called issue ) 3. Write result finish execution (WB) Write on Common Data Bus to all awaiting FUs & reorder buffer; mark reservation station available. 4. Commit update register with reorder result When instr. at head of reorder buffer & result present, update register with result (or store to memory) and remove instr from reorder buffer. Mispredicted branch flushes reorder buffer (sometimes called graduation ) 18/02/2004 UAH- 59 What are the hardware complexities with reorder buffer (ROB)? How do you find the latest version of a register? (As specified by Smith paper) need associative comparison network Could use future file or just use the register result status buffer to track which specific reorder buffer has received the value Need as many ports on ROB as register file Dest Reg Result Exceptions? Valid Program Counter FP Op Queue Compar network Reorder Buffer FP Regs Reorder Table Res Stations FP Adder Res Stations FP Adder 18/02/2004 UAH- 60 Aleksandar Milenkovich 30

Summary Reservations stations: implicit register renaming to larger set of registers + buffering source operands Prevents registers as bottleneck Avoids WAR, WAW hazards of Scoreboard Allows loop unrolling in HW Not limited to basic blocks (integer units gets ahead, beyond branches) Today, helps cache misses as well Don t stall for L1 Data cache miss (insufficient ILP for L2 miss?) Lasting Contributions Dynamic scheduling Register renaming Load/store disambiguation 360/91 descendants are Pentium III; PowerPC 604; MIPS R10000; HP-PA 8000; Alpha 21264 18/02/2004 UAH- 61 Aleksandar Milenkovich 31