CS 152 Computer Architecture and Engineering. Lecture 10 - Complex Pipelines, Out-of-Order Issue, Register Renaming

Similar documents
CS 152 Computer Architecture and Engineering. Lecture 13 - Out-of-Order Issue and Register Renaming

CS 252 Graduate Computer Architecture. Lecture 4: Instruction-Level Parallelism

ECE 252 / CPS 220 Advanced Computer Architecture I. Lecture 8 Instruction-Level Parallelism Part 1

C 1. Last time. CSE 490/590 Computer Architecture. Complex Pipelining I. Complex Pipelining: Motivation. Floating-Point Unit (FPU) Floating-Point ISA

ECE 552 / CPS 550 Advanced Computer Architecture I. Lecture 9 Instruction-Level Parallelism Part 2

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

Complex Pipelining. Motivation

Lecture 4 Pipelining Part II

CS 152 Computer Architecture and Engineering. Lecture 12 - Advanced Out-of-Order Superscalars

EC 513 Computer Architecture

CS 152, Spring 2011 Section 8

Lecture 13 - VLIW Machines and Statically Scheduled ILP

CS 152 Computer Architecture and Engineering CS252 Graduate Computer Architecture. Lecture 4 Pipelining Part II

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

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

CS 152 Computer Architecture and Engineering. Lecture 13 - VLIW Machines and Statically Scheduled ILP

CS 152 Computer Architecture and Engineering. Lecture 11 - Virtual Memory and Caches

ECE 552 / CPS 550 Advanced Computer Architecture I. Lecture 15 Very Long Instruction Word Machines

Announcements. ECE4750/CS4420 Computer Architecture L11: Speculative Execution I. Edward Suh Computer Systems Laboratory

Processor: Superscalars Dynamic Scheduling

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

CS425 Computer Systems Architecture

CS252 Spring 2017 Graduate Computer Architecture. Lecture 8: Advanced Out-of-Order Superscalar Designs Part II

CS152 Computer Architecture and Engineering. Complex Pipelines

Announcement. ECE475/ECE4420 Computer Architecture L4: Advanced Issues in Pipelining. Edward Suh Computer Systems Laboratory

ECE 252 / CPS 220 Advanced Computer Architecture I. Lecture 14 Very Long Instruction Word Machines

CS152 Computer Architecture and Engineering March 13, 2008 Out of Order Execution and Branch Prediction Assigned March 13 Problem Set #4 Due March 25

Lecture 4 - Pipelining

CS 152 Computer Architecture and Engineering. Lecture 16 - VLIW Machines and Statically Scheduled ILP

CISC 662 Graduate Computer Architecture. Lecture 10 - ILP 3

CSC 631: High-Performance Computer Architecture

Lecture 12 Branch Prediction and Advanced Out-of-Order Superscalars

E0-243: Computer Architecture

CS 152 Computer Architecture and Engineering. Lecture 9 - Virtual Memory

Lecture 9 - Virtual Memory

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

Complex Pipelining COE 501. Computer Architecture Prof. Muhamed Mudawar

CS 152 Computer Architecture and Engineering. Lecture 8 - Address Translation

Lecture 14: Multithreading

Donn Morrison Department of Computer Science. TDT4255 ILP and speculation

Computer Architecture Lecture 12: Out-of-Order Execution (Dynamic Instruction Scheduling)

COSC4201 Instruction Level Parallelism Dynamic Scheduling

Static vs. Dynamic Scheduling

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

15-740/ Computer Architecture Lecture 10: Out-of-Order Execution. Prof. Onur Mutlu Carnegie Mellon University Fall 2011, 10/3/2011

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

Lecture 9: Multiple Issue (Superscalar and VLIW)

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

ECE 552 / CPS 550 Advanced Computer Architecture I. Lecture 6 Pipelining Part 1

Advanced Computer Architecture

Handout 2 ILP: Part B

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

CS 152 Computer Architecture and Engineering. Lecture 8 - Address Translation

Computer Architecture ELEC3441

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

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

CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

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

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

CISC 662 Graduate Computer Architecture Lecture 13 - CPI < 1

Branch Prediction & Speculative Execution. Branch Penalties in Modern Pipelines

FINAL REVIEW PART1. Howard Mao

Scoreboard information (3 tables) Four stages of scoreboard control

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

Advanced Computer Architecture

C 1. Last Time. CSE 490/590 Computer Architecture. ISAs and MIPS. Instruction Set Architecture (ISA) ISA to Microarchitecture Mapping

CS 152 Computer Architecture and Engineering

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

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

CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

COSC 6385 Computer Architecture - Pipelining (II)

CS 152 Computer Architecture and Engineering. Lecture 5 - Pipelining II (Branches, Exceptions)

Computer Architecture and Engineering CS152 Quiz #3 March 22nd, 2012 Professor Krste Asanović

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

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

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

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

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

DYNAMIC AND SPECULATIVE INSTRUCTION SCHEDULING

Hardware-Based Speculation

Computer Systems Architecture I. CSE 560M Lecture 10 Prof. Patrick Crowley

Precise Exceptions and Out-of-Order Execution. Samira Khan

Lecture: Out-of-order Processors. Topics: out-of-order implementations with issue queue, register renaming, and reorder buffer, timing, LSQ

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

Advanced issues in pipelining

Instruction Level Parallelism. Appendix C and Chapter 3, HP5e

DYNAMIC INSTRUCTION SCHEDULING WITH SCOREBOARD

Dynamic Scheduling. CSE471 Susan Eggers 1

Hardware-based Speculation

Lecture 18: Instruction Level Parallelism -- Dynamic Superscalar, Advanced Techniques,

CS252 Spring 2017 Graduate Computer Architecture. Lecture 17: Virtual Memory and Caches

Case Study IBM PowerPC 620

Slide Set 8. for ENCM 501 in Winter Steve Norman, PhD, PEng

5008: Computer Architecture

EECC551 Exam Review 4 questions out of 6 questions

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

COSC 6385 Computer Architecture - Pipelining

CS 152 Computer Architecture and Engineering. Lecture 9 - Address Translation

Multiple Instruction Issue. Superscalars

ECE 4750 Computer Architecture, Fall 2017 T10 Advanced Processors: Out-of-Order Execution

Transcription:

CS 152 Computer Architecture and Engineering Lecture 10 - Complex Pipelines, Out-of-Order Issue, Register Renaming John Wawrzynek Electrical Engineering and Computer Sciences University of California at Berkeley http://www.eecs.berkeley.edu/~johnw http://inst.eecs.berkeley.edu/~cs152

Last time in Lecture 9 Modern page-based virtual memory systems provide: Translation, Protection, Demand paging. Translation and protection information stored in page tables, held in main memory Translation and protection information cached in translation-lookaside buffer (TLB) to provide single-cycle translation+protectioncheck in common case Virtual memory interacts with cache design Physical cache tags require address translation before tag lookup, or use untranslated offset bits to index cache. Virtual tags do not require translation before cache hit/miss determination, but need to be flushed or extended with ASID to cope with context swaps. Also, must deal with virtual address aliases (usually by disallowing copies in cache). 2

Complex Pipelining: Motivation Pipelining becomes complex when we want high performance in the presence of: Long latency or partially pipelined floatingpoint units Memory systems with variable access time Multiple arithmetic and memory units 3

Floating-Point Unit (FPU) Much more hardware than an integer unit Single-cycle FPU is a bad idea why? Common to have several FPU s Common to have different types of FPU s: Fadd, Fmul, Fdiv, An FPU may be pipelined, partially pipelined or not pipelined To operate several FPU s concurrently the FP register file needs to have multiple read and write ports 4

Functional Unit Characteristics fully pipelined 1cyc 1cyc 1cyc partially pipelined 2 cyc 2 cyc Functional units have internal pipeline registers operands are latched when an instruction enters a functional unit following instructions are able to write register file during a long-latency operation 5

Floating-Point ISA Interaction between floating-point datapath and integer datapath is determined by ISA RISC-V ISA separate register files for FP and Integer instructions the only interaction is via a set of move/convert instructions (some ISA s don t even permit this) separate load/store for FPR s and GPR s but both use GPR s for address calculation FP compares write integer registers, then use integer branch 6

Challenges in Complex Pipeline Control 1. Structural conflicts at the execution stage if some FPU or memory unit is not pipelined and takes more than one cycle 2. Structural conflicts at the write-back stage due to variable latencies of different functional units 3. Out-of-order write hazards due to variable latencies of different functional units 4. How to handle exceptions? ALU Mem IF ID Issue WB Fadd GPRs FPRs Fmul Fdiv 8

Complex In-Order Pipeline PC Inst. Mem D Decode GPRs X1 + X2 Data Mem X3 W Delay writeback so all operations have same latency to W stage Write ports never oversubscribed (one inst. in & one inst. out every cycle) Stall pipeline on long latency operations, e.g., divides, cache misses Handle exceptions in-order at FPRs commit point Bypassing to prevent the increased writeback latency from slowing down single cycle integer operations? X1 FDiv X2 FAdd X3 X2 FMul X3 Unpipelined X2 divider X3 Commit Point W 9

Simple In-Order Superscalar Pipeline PC Inst. Mem 2 D Dual Decode GPRs X1 + X2 Data Mem X3 W FPRs X1 X2 FAdd X3 W Fetch two instructions per cycle; issue both simultaneously if one is integer/memory and other is floating point Inexpensive way of increasing throughput, examples include Alpha 21064 (1992) & MIPS R5000 series (1996) Same idea can be extended to wider issue by duplicating functional units (e.g. 4-issue UltraSPARC & Alpha 21164) but regfile ports and bypassing costs grow quickly FDiv X2 FMul X3 Unpipelined divider X2 X3 Commit Point 10

Boosting Performance How do we keep more functional units busy? How can we do useful work during long latency operations? Allow instructions to execute out-of-order (OOO). Possible, but hazards avoidance becomes more complex! 11

Register vs. Memory Dependence Data hazards due to register operands can be determined at the decode stage, but data hazards due to memory operands can be determined only after computing the effective address Store: M[r1 + disp1] r2 Load: r3 M[r4 + disp2] Does (r1 + disp1) = (r4 + disp2)? 12

Types of Data Hazards Consider executing a sequence of r k r i op r j type of instructions Data-dependence r 3 r 1 op r 2 r 5 r 3 op r 4 Anti-dependence r 3 r 1 op r 2 r 1 r 4 op r 5 Output-dependence r 3 r 1 op r 2 r 3 r 6 op r 7 Read-after-Write (RAW) hazard Write-after-Read (WAR) hazard Write-after-Write (WAW) hazard 13

Data Hazards: An Example I 1 FDIV.D f6, f6, f4 I 2 FLD f2, 45(x3) I 3 FMUL.D f0, f2, f4 I 4 FDIV.D f8, f6, f2 I 5 FSUB.D f10, f0, f6 I 6 FADD.D f6, f8, f2 RAW Hazards WAR Hazards WAW Hazards 14

Instruction Scheduling I 1 FDIV.D f6, f6, f4 I 2 FLD f2, 45(x3) I 3 FMULT.D f0, f2, f4 I 4 FDIV.D f8, f6, f2 I 5 FSUB.D f10, f0, f6 I 6 FADD.D f6, f8, f2 Constraint graph defines partial ordering. I 1 I 2 I 3 I 4 Valid orderings: in-order I 1 I 2 I 3 I 4 I 5 I 6 I 5 out-of-order out-of-order I 2 I 1 I 3 I 4 I 5 I 6 I 1 I 2 I 3 I 5 I 4 I 6 I 6 15

Out-of-order Completion In-order Issue Latency I 1 FDIV.D f6, f6, f4 4 I 2 FLD f2, 45(x3) 1 I 3 FMULT.D f0, f2, f4 3 I 4 FDIV.D f8, f6, f2 4 I 5 FSUB.D f10, f0, f6 1 I 6 FADD.D f6, f8, f2 1 in-order comp 1 2 out-of-order comp 1 2 1 2 3 4 3 5 4 6 5 6 2 3 1 4 3 5 5 4 6 6 16

Complex Pipeline ALU Mem IF ID Issue WB Fadd GPR s FPR s Fmul Can we solve write hazards without equalizing all pipeline depths and without bypassing? Fdiv 17

When is it Safe to Issue an Instruction? Suppose a data structure keeps track of all the instructions in all the functional units The following checks need to be made before the Issue stage can dispatch an instruction Is the required function unit available? Is the input data available? RAW? Is it safe to write the destination? WAR? WAW? Is there a structural conflict at the WB stage? 18

A Data Structure for Correct Issues Keeps track of the status of Functional Units Name Busy Op Dest Src1 Src2 Int Mem Add1 Add2 Add3 Mult1 Mult2 Div The instruction i at the Issue stage consults this table FU available? RAW? WAR? WAW? check the busy column search the dest column for i s sources search the source columns for i s destination search the dest column for i s destination An entry is added to the table if no hazard is detected; An entry is removed from the table after Write-Back 19

Simplifying the Data Structure Assuming In-order Issue Suppose the instruction is not dispatched by the Issue stage if a RAW hazard exists or the required FU is busy, and that operands are latched by functional unit on issue: Can the dispatched instruction cause a WAR hazard? WAW hazard? NO: Operands read at issue YES: Out-of-order completion 20

Simplifying the Data Structure... No WAR hazard no need to keep src1 and src2 The Issue stage does not dispatch an instruction in case of a WAW hazard a register name can occur at most once in the dest column WP[reg#] : a bit-vector to record the registers for which writes are pending These bits are set by the Issue stage and cleared by the WB stage 21

CS152 Administrivia Quiz 2, Thursday Oct 6 Interrupts + Caches and Virtual memory L6 L9, PS 2, Lab 2, readings 22

Scoreboard for In-order Issues Busy[FU#] : a bit-vector to indicate FU s availability. (FU = Int, Add, Mult, Div) These bits are hardwired to FU's. WP[reg#] : a bit-vector to record the registers for which writes are pending. These bits are set by Issue stage and cleared by WB stage Issue checks the instruction (opcode dest src1 src2) against the scoreboard (Busy & WP) to dispatch FU available? RAW? WAR? WAW? Busy[FU#] WP[src1] or WP[src2] cannot arise WP[dest] 23

Scoreboard Dynamics Functional Unit Status Registers Reserved Int(1) Add(1) Mult(3) Div(4) WB for Writes t0 I 1 f6 f6 t1 I 2 f2 f6 f6, f2 t2 f6 f2 f6, f2 I 2 t3 I 3 f0 f6 f6, f0 t4 f0 f6 f6, f0 I 1 t5 I 4 f0 f8 f0, f8 t6 f8 f0 f0, f8 I 3 t7 I 5 f10 f8 f8, f10 t8 f8 f10 f8, f10 I 5 t9 f8 f8 I 4 t10 I 6 f6 f6 t11 f6 f6 I 6 I 1 FDIV.D f6, f6, f4 I 2 FLD f2, 45(x3) I 3 FMULT.D f0, f2, f4 I 4 FDIV.D f8, f6, f2 I 5 FSUB.D f10, f0, f6 I 6 FADD.D f6, f8, f2 24

In-Order Issue Limitations: an example latency 1 FLD f2, 34(x2) 1 1 2 2 FLD f4, 45(x3) long 3 FMULT.D f6, f4, f2 3 4 FSUB.D f8, f2, f2 1 5 FDIV.D f4, f2, f8 4 4 5 3 6 FADD.D f10, f6, f4 1 6 In-order: 1 (2,1)...... 2 3 4 4 3 5... 5 6 6 In-order issue restriction prevents instruction 4 from being dispatched 25

Out-of-Order Issue ALU Mem IF ID Issue WB Fadd Fmul Issue stage buffer holds multiple instructions waiting to issue. Decode adds next instruction to buffer if there is space and the instruction does not cause a WAR or WAW hazard. Note: WAR possible again because issue is out-of-order (WAR not possible with in-order issue and latching of input operands at functional unit) Any instruction in buffer whose RAW hazards are satisfied can be issued (for now at most one dispatch per cycle). On a write back (WB), new instructions may get enabled. 26

Issue Limitations: In-Order and Out-of-Order latency 1 FLD f2, 34(x2) 1 1 2 2 FLD f4, 45(x3) long 3 FMULT.D f6, f4, f2 3 4 FSUB.D f8, f2, f2 1 5 FDIV.D f4, f2, f8 4 4 5 3 6 FADD.D f10, f6, f4 1 6 In-order: 1 (2,1)...... 2 3 4 4 3 5... 5 6 6 Out-of-order: 1 (2,1) 4 4.... 2 3.. 3 5... 5 6 6 Out-of-order execution did not allow any significant improvement! 27

How many instructions can be in the pipeline? Which features of an ISA limit the number of instructions in the pipeline? Number of Registers Out-of-order dispatch by itself does not provide any significant performance improvement! 28

Overcoming the Lack of Register Names It was observed that Floating Point pipelines often cannot be kept filled with small number of registers. IBM 360 had only 4 floating-point registers Can a microarchitecture use more registers than specified by the ISA without loss of ISA compatibility? Robert Tomasulo of IBM suggested an ingenious solution in 1967 using on-the-fly register renaming (more physical registers than architected registers) 29

Issue Limitations: In-Order and Out-of-Order latency 1 FLD f2, 34(x2) 1 1 2 2 FLD f4, 45(x3) long 3 FMULT.D f6, f4, f2 3 4 FSUB.D f8, f2, f2 1 5 FDIV.D f4, f2, f8 4 4 5 X 3 6 FADD.D f10, f6, f4 1 In-order: 1 (2,1)...... 2 3 4 4 3 5... 5 6 6 Out-of-order: 1 (2,1) 4 4 5... 2 (3,5) 3 6 6 Any antidependence can be eliminated by renaming. Compiler could be smarter about register use. Can it be done in hardware? 6 yes! 30

Register Renaming ALU Mem IF ID Issue WB Fadd Fmul Decode does register renaming and adds instructions to the issue-stage instruction reorder buffer (ROB) renaming makes WAR or WAW hazards impossible Any instruction in ROB whose RAW hazards have been satisfied can be dispatched. Out-of-order or dataflow execution 31

Renaming table & regfile Reorder buffer Replacing the tag by its value is an expensive operation Renaming Structures Ins# use exec op p1 src1 p2 src2 t 1 t2.. t n Load Unit FU FU Store Unit < t, result > Instruction template (i.e., tag t) is allocated by the Decode stage, which also associates tag with register in regfile When an instruction completes, its tag is deallocated 32

ptr 2 next to deallocate ptr 1 next available Reorder Buffer Management Ins# use exec op p1 src1 p2 src2 Instruction slot is candidate for execution when: It holds a valid instruction ( use bit is set) It has not already started execution ( exec bit is clear) Both operands are available (p1 and p2 are set) t 1 t 2... t n Destination registers are renamed to the instruction s slot tag ROB managed circularly exec bit is set when instruction begins execution When an instruction completes its use bit is marked free ptr 2 is incremented only if the use bit is marked free 33

Renaming & Out-of-order Issue An example Renaming table p data f1 f2 v1 t1 f3 f4 t2 t5 f5 f6 t3 f7 f8 v4 t4 Reorder buffer Ins# use exec op p1 src1 p2 src2 1 1 0 10 LD 2 10 01 LD 3 1 0 MUL 10 v2 t2 1 v1 4 1 0 10 SUB 1 v1 1 v1 5 1 0 DIV 1 v1 01 t4 v4 t 1 t 2 t 3 t 4 t 5.. data / t i 1 FLD f2, 34(x2) 2 FLD f4, 45(x3) 3 FMULT.D f6, f4, f2 4 FSUB.D f8, f2, f2 5 FDIV.D f4, f2, f8 6 FADD.D f10, f6, f4 When are tags in sources replaced by data? Whenever an FU produces data When can a name be reused? Whenever an instruction completes 34

1 2 3 4 5 6 IBM 360/91 Floating-Point Unit R. M. Tomasulo, 1967 load buffers (from memory) instructions... 1 2 3 4 Floating-Point Regfile Distribute instruction templates by functional units 1 2 3 Adder 1 2 < tag, result > Mult store buffers (to memory) Common bus ensures that data is made available immediately to all the instructions waiting for it. Match tag, if equal, copy value & set presence p. 35

Effectiveness? Renaming and Out-of-order execution was first implemented in 1969 in IBM 360/91 but did not show up in the subsequent models until mid-nineties. Why? Reasons 1. Effective on a very small class of programs 2. Memory latency a much bigger problem 3. Exceptions not precise! One more problem needed to be solved Control transfers 36

Acknowledgements These slides contain material developed and copyright by: Arvind (MIT) Krste Asanovic (MIT/UCB) Joel Emer (Intel/MIT) James Hoe (CMU) John Kubiatowicz (UCB) David Patterson (UCB) MIT material derived from course 6.823 UCB material derived from course CS252 37