Out-of-Order Execution & Register Renaming

Slides:



Advertisements
Similar presentations
Asanovic/Devadas Spring Advanced Superscalar Architectures Krste Asanovic Laboratory for Computer Science Massachusetts Institute of Technology.
Advertisements

Spring 2003CSE P5481 Out-of-Order Execution Several implementations out-of-order completion CDC 6600 with scoreboarding IBM 360/91 with Tomasulos algorithm.
Scoreboarding & Tomasulos Approach Bazat pe slide-urile lui Vincent H. Berk.
Complex Pipelining Krste Asanovic Laboratory for Computer Science Massachusetts Institute of Technology Asanovic/Devadas Spring
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon., Sep 30, 2002 Topic: Instruction-Level Parallelism (Dynamic Scheduling: Tomasulo’s.
Topics Left Superscalar machines IA64 / EPIC architecture
Hardware-Based Speculation. Exploiting More ILP Branch prediction reduces stalls but may not be sufficient to generate the desired amount of ILP One way.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture VLIW Steve Ko Computer Sciences and Engineering University at Buffalo.
2/28/2013 CS152, Spring 2013 CS 152 Computer Architecture and Engineering Lecture 11 - Out-of-Order Issue, Register Renaming, & Branch Prediction Krste.
Dynamic ILP: Scoreboard Professor Alvin R. Lebeck Computer Science 220 / ECE 252 Fall 2008.
Computer Organization and Architecture (AT70.01) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Dr. Sumanta Guha Slide Sources: Based.
Dynamic Branch PredictionCS510 Computer ArchitecturesLecture Lecture 10 Dynamic Branch Prediction, Superscalar, VLIW, and Software Pipelining.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture Complex Pipelining II Steve Ko Computer Sciences and Engineering University at Buffalo.
Pipeline Hazards Pipeline hazards These are situations that inhibit that the next instruction can be processed in the next stage of the pipeline. This.
February 28, 2011CS152, Spring 2011 CS 152 Computer Architecture and Engineering Lecture 10 - Complex Pipelines, Out-of-Order Issue, Register Renaming.
THE MIPS R10000 SUPERSCALAR MICROPROCESSOR Kenneth C. Yeager IEEE Micro in April 1996 Presented by Nitin Gupta.
Spring 2003CSE P5481 Reorder Buffer Implementation (Pentium Pro) Hardware data structures retirement register file (RRF) (~ IBM 360/91 physical registers)
CS 211: Computer Architecture Lecture 5 Instruction Level Parallelism and Its Dynamic Exploitation Instructor: M. Lancaster Corresponding to Hennessey.
CPE 731 Advanced Computer Architecture ILP: Part IV – Speculative Execution Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture ILP II Steve Ko Computer Sciences and Engineering University at Buffalo.
February 28, 2012CS152, Spring 2012 CS 152 Computer Architecture and Engineering Lecture 11 - Out-of-Order Issue, Register Renaming, & Branch Prediction.
CS 152 Computer Architecture and Engineering Lecture 13 - Out-of-Order Issue, Register Renaming, & Branch Prediction Krste Asanovic Electrical Engineering.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture ILP III Steve Ko Computer Sciences and Engineering University at Buffalo.
March 11, 2010CS152, Spring 2010 CS 152 Computer Architecture and Engineering Lecture 14 - Advanced Superscalars Krste Asanovic Electrical Engineering.
CSE 490/590, Spring 2011 CSE 490/590 Computer Architecture ILP I Steve Ko Computer Sciences and Engineering University at Buffalo.
1 Lecture 7: Out-of-Order Processors Today: out-of-order pipeline, memory disambiguation, basic branch prediction (Sections 3.4, 3.5, 3.7)
CS 152 Computer Architecture and Engineering Lecture 15 - Advanced Superscalars Krste Asanovic Electrical Engineering and Computer Sciences University.
March 4, 2010CS152, Spring 2010 CS 152 Computer Architecture and Engineering Lecture 13 - Out-of-Order Issue, Register Renaming, & Branch Prediction Krste.
Chapter 12 Pipelining Strategies Performance Hazards.
CS 152 Computer Architecture and Engineering Lecture 13 - Out-of-Order Issue and Register Renaming Krste Asanovic Electrical Engineering and Computer Sciences.
March 9, 2011CS152, Spring 2011 CS 152 Computer Architecture and Engineering Lecture 12 - Advanced Out-of-Order Superscalars Krste Asanovic Electrical.
Chapter 12 CPU Structure and Function. Example Register Organizations.
CS 252 Graduate Computer Architecture Lecture 4: Instruction-Level Parallelism Krste Asanovic Electrical Engineering and Computer Sciences University of.
March 2, 2011CS152, Spring 2011 CS 152 Computer Architecture and Engineering Lecture 11 - Out-of-Order Issue, Register Renaming, & Branch Prediction Krste.
Arvind and Joel Emer Computer Science and Artificial Intelligence Laboratory M.I.T. Branch Prediction.
Ch2. Instruction-Level Parallelism & Its Exploitation 2. Dynamic Scheduling ECE562/468 Advanced Computer Architecture Prof. Honggang Wang ECE Department.
1 Sixth Lecture: Chapter 3: CISC Processors (Tomasulo Scheduling and IBM System 360/91) Please recall:  Multicycle instructions lead to the requirement.
ECE 552 / CPS 550 Advanced Computer Architecture I Lecture 9 Instruction-Level Parallelism – Part 2 Benjamin Lee Electrical and Computer Engineering Duke.
Branch.1 10/14 Branch Prediction Static, Dynamic Branch prediction techniques.
CS 152 Computer Architecture and Engineering Lecture 15 - Out-of-Order Memory, Complex Superscalars Review Krste Asanovic Electrical Engineering and Computer.
Out-of-Order Execution & Register Renaming Krste Asanovic Laboratory for Computer Science Massachusetts Institute of Technology Asanovic/Devadas Spring.
1 Lecture 7: Speculative Execution and Recovery Branch prediction and speculative execution, precise interrupt, reorder buffer.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 13: Branch prediction (Chapter 4/6)
1 Lecture: Out-of-order Processors Topics: a basic out-of-order processor with issue queue, register renaming, and reorder buffer.
March 1, 2012CS152, Spring 2012 CS 152 Computer Architecture and Engineering Lecture 12 - Advanced Out-of-Order Superscalars Krste Asanovic Electrical.
CS203 – Advanced Computer Architecture ILP and Speculation.
CS 152 Computer Architecture and Engineering Lecture 10 - Complex Pipelines, Out-of-Order Issue, Register Renaming John Wawrzynek Electrical Engineering.
Dynamic Scheduling Why go out of style?
Computer Organization CS224
CS 152 Computer Architecture and Engineering Lecture 11 - Out-of-Order Issue, Register Renaming, & Branch Prediction John Wawrzynek Electrical Engineering.
Lecture 10 - Complex Pipelines, Out-of-Order Issue, Register Renaming
/ Computer Architecture and Design
PowerPC 604 Superscalar Microprocessor
CS252 Graduate Computer Architecture Spring 2014 Lecture 8: Advanced Out-of-Order Superscalar Designs Part-II Krste Asanovic
CIS-550 Advanced Computer Architecture Lecture 10: Precise Exceptions
The processor: Pipelining and Branching
Lecture 8: ILP and Speculation Contd. Chapter 2, Sections 2. 6, 2
Lecture 11: Memory Data Flow Techniques
Electrical and Computer Engineering
CS 152 Computer Architecture and Engineering Lecture 13 - Out-of-Order Issue, Register Renaming, & Branch Prediction Krste Asanovic Electrical Engineering.
Krste Asanovic Electrical Engineering and Computer Sciences
Lecture 8: Dynamic ILP Topics: out-of-order processors
Adapted from the slides of Prof
15-740/ Computer Architecture Lecture 5: Precise Exceptions
Krste Asanovic Electrical Engineering and Computer Sciences
Krste Asanovic Electrical Engineering and Computer Sciences
Lecture 7: Dynamic Scheduling with Tomasulo Algorithm (Section 2.4)
Adapted from the slides of Prof
Prof. Onur Mutlu Carnegie Mellon University Fall 2011, 9/30/2011
Lecture 9: Dynamic ILP Topics: out-of-order processors
Presentation transcript:

Out-of-Order Execution & Register Renaming Asanovic/Devadas Spring 2002 6.823 Out-of-Order Execution & Register Renaming Krste Asanovic Laboratory for Computer Science Massachusetts Institute of Technology

Scoreboard for In-order Issue Asanovic/Devadas Spring 2002 6.823 Scoreboard for In-order Issue Busy[unit#] : a bit-vector to indicate unit’s availability. (unit = 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 Issue checks the instruction (opcode dest src1 src2) against the scoreboard (Busy & WP) to dispatch FU available? not Busy[FU#] RAW? WP[src1] or WP[src2] WAR? cannot arise WAW? WP[dest]

Out-of-Order Dispatch Asanovic/Devadas Spring 2002 6.823 Out-of-Order Dispatch ALU Mem IF ID WB Issue 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. • Any instruction in buffer whose RAW hazards are satisfied can be dispatched (for now, at most one dispatch per cycle). On a write back (WB), new instructions may get enabled.

Out-of-Order Issue: an example Asanovic/Devadas Spring 2002 6.823 Out-of-Order Issue: an example latency 1 LD F2, 34(R2) 1 2 LD F4, 45(R3) long 3 MULTD F6, F4, F2 3 4 SUBD F8, F2, F2 1 5 DIVD F4, F2, F8 4 6 ADDD F10, F6, F4 1 1 2 4 3 5 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 did not allow any significant improvement !

How many Instructions can be in the pipeline Asanovic/Devadas Spring 2002 6.823 How many Instructions can be in the pipeline Which features of an ISA limit the number of instructions in the pipeline? Which features of a program limit the number of

Overcoming the Lack of Register Names Asanovic/Devadas Spring 2002 6.823 Overcoming the Lack of Register Names Number of registers in an ISA limits the number of partially executed instructions in complex pipelines 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 based on on-the-fly register renaming

Instruction-Level Parallelism with Renaming Asanovic/Devadas Spring 2002 6.823 Instruction-Level Parallelism with Renaming latency 1 LD F2, 34(R2) 1 2 LD F4, 45(R3) long 3 MULTD F6, F4, F2 3 4 SUBD F8, F2, F2 1 5 DIVD F4’, F2, F8 4 6 ADDD F10, F6, F4’ 1 1 2 4 3 X 5 6 In-order: 1 (2,1) . . . . . . 2 3 4 4 (5,3) . . . 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 renaming ⇒ additional storage Can it be done in hardware? yes!

Asanovic/Devadas Spring 2002 6.823 Register Renaming ALU Mem IF ID WB ROB Fadd Fmul • Decode does register renaming and adds instructions to the issue stage 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

Renaming & Out-of-order Issue An example Asanovic/Devadas Spring 2002 6.823 Renaming & Out-of-order Issue An example Renaming table Reorder buffer p data Ins# use exec op p1 src1 p2 src2 t1 t2 . . . F1 F2 F3 F4 F5 F6 F7 F8 data / ti 1 LD F2, 34(R2) 2 LD F4, 45(R3) 3 MULTD F6, F4, F2 4 SUBD F8, F2, F2 5 DIVD F4, F2, F8 6 ADDD F10, F6, F4 • When are names in sources replaced by data? • When can a name be reused?

Data-Driven Execution Asanovic/Devadas Spring 2002 6.823 Data-Driven Execution Renaming table & reg file Ins# use exec op p1 src1 p2 src2 Reorder buffer t1 t2 . tn Replacing the tag by its value is an expensive operation Load Unit Store Unit FU FU < t, result > • Instruction template (i.e., tag t) is allocated by the Decode stage, which also stores the tag in the reg file • When an instruction completes, its tag is deallocated

Simplifying Allocation/Deallocation Asanovic/Devadas Spring 2002 6.823 Simplifying Allocation/Deallocation Reorder buffer Ins# use exec op p1 src1 p2 src2 t1 t2 . . . tn ptr2 next to deallocate prt1 next available Instruction buffer is managed circularly • When an instruction completes its “use” bit is marked free • ptr2 is incremented only if the “use” bit is marked free

IBM 360/91 Floating Point Unit Asanovic/Devadas Spring 2002 6.823 R. M. Tomasulo, 1967 data load buffers (from memory) instructions p data Floating Point Reg . . . distribute instruction templates by functional units p data p data p data p data Addr Mult < t, result > Common bus ensures that data is made available immediately to all the instructions waiting for it store buffers (to memory) p data

Effectiveness? Renaming and Out-of-order execution was first Asanovic/Devadas Spring 2002 6.823 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. Exceptions not precise! 2. Effective on a very small class of programs One more problem needed to be solved

Asanovic/Devadas Spring 2002 6.823 Precise Interrupts It must appear as if an interrupt is taken between two instructions (say Ii and Ii+1) • the effect of all instructions up to and including Ii is totally complete • no effect of any instruction after Ii has taken place The interrupt handler either aborts the program or restarts it at Ii+1 .

Effect on Interrupts Out-of-order Completion Asanovic/Devadas Spring 2002 6.823 Effect on Interrupts Out-of-order Completion 1 LD f6, f6, f4 2 LD f2, 45(r3) 3 MULTD f0, f2, f4 4 SUBD f8, f6, f2 5 DIVD f10, f0, f6 6 ADDD f6, f8, f2 Out-of-order comp 1 2 2 3 1 4 3 5 5 4 6 6 restore f10 Consider interrupts Precise interrupts are difficult to implement at high speed - want to start execution of later instructions before exception checks finished on earlier instructions

Exception Handling (In-Order Five-Stage Pipeline) Asanovic/Devadas Spring 2002 6.823 Exception Handling (In-Order Five-Stage Pipeline) Commit Point PC Inst. Mem D Decode M Data Mem E + W Illegal Opcode Kill Writeback Data Address Exceptions Overflow Select Handler Pc PC Address Exceptions Exc D Exc E Exc M Cause PC D PC E PC M Kill D Stage EPC Kill F Stage Kill E Stage Asynchronous Interrupts • Hold exception flags in pipeline until commit point (M stage) • Exceptions in earlier pipe stages override later exceptions • Inject external interrupts at commit point (override others) • If exception at commit: update Cause and EPC registers, kill all stages, inject handler PC into fetch stage

Phases of Instruction Execution Asanovic/Devadas Spring 2002 6.823 Phases of Instruction Execution PC Fetch: Instruction bits retrieved from cache. I-cache Fetch Buffer Decode: Instructions placed in appropriate issue stage buffer (sometimes called “issue” or “dispatch”) Issue Buffer Execute: Instructions and operands sent to execution units (sometimes called “issue” or “dispatch”). When execution completes, all results and exception flags are available. Func. Units Result Buffer Commit: Instruction irrevocably updates architectural state (sometimes called “graduation” or “completion”). Arch. State

In-Order Commit for Precise Exceptions Asanovic/Devadas Spring 2002 6.823 In-Order Commit for Precise Exceptions • Instructions fetched and decoded into instruction reorder buffer in-order • Execution is out-of-order (⇒ out-of-order completion) • Commit (write-back to architectural state, regfile+memory) is in-order Temporary storage needed to hold results before commit (shadow registers and store buffers) In-order In-order Out-of-order Commit Fetch Decode Reorder Buffer Kill Kill Kill Execute Inject handler PC Exception?

Extensions for Precise Exceptions Asanovic/Devadas Spring 2002 6.823 Instruction reorder buffer Inst# use exec op p1 src1 p2 src2 pd dest data cause ptr2 next to commit ptr1 next available • add <pd, dest, data, cause> fields in the instruction template • commit instructions to reg file and memory in program order ⇒ buffers can be maintained circularly • on exception, clear reorder buffer by resetting ptr1=ptr2 (stores must wait for commit before updating memory)

Asanovic/Devadas Spring 2002 6.823 Rollback and Renaming Register File (now holds only committed state) t1 t2 . tn Reorder buffer Load Unit Store Unit Commit FU FU FU < t, result > Register file does not contain renaming tags any more. How does the decode stage find the tag of a source register?

Asanovic/Devadas Spring 2002 6.823 Renaming Table r1 r2 ti vi Rename Table Register File t1 t2 . tn Reorder buffer Load Unit Store Unit Commit FU FU FU < t, result > Renaming table is like a cache to speed up register name look up (rename tag + valid bit per entry). It needs to be cleared after each exception taken . When else are valid bits cleared?

Effect of Control Transfer on Pipelined Execution Asanovic/Devadas Spring 2002 6.823 Effect of Control Transfer on Pipelined Execution Control transfer instructions require insertion of bubbles in the pipeline. The number of bubbles depends upon the number of cycles it takes • to determine the next instruction address, and • to fetch the next instruction

Branch penality PC Next fetch started I-cache Fetch Fetch Buffer Asanovic/Devadas Spring 2002 6.823 Branch penality PC Next fetch started I-cache Fetch Fetch Buffer Decode Issue Buffer Func. Units Execute Result Buffer Branch executed Commit Arch. State

Branch Penalties in Modern Pipelines Asanovic/Devadas Spring 2002 6.823 Branch Penalties in Modern Pipelines UltraSPARC-III instruction fetch pipeline stages (in-order issue, 4-way superscalar, 750MHz, 2000) PC Generation/Mux Instruction Fetch Stage 1 Instruction Fetch Stage 2 Branch Address Calc/Begin Decode Complete Decode Steer Instructions to Functional units Register File Read Integer Execute Remainder of execute pipeline (+another 6 stages) A P F B I J R E Fetch Decode Branch penalty: Cycles?________ Instructions?_________

Average Run-Length between Branches Asanovic/Devadas Spring 2002 6.823 Average Run-Length between Branches Average dynamic instruction mix from SPEC92: SPECint92 SPECfp92 ALU 39 % 13 % FPU Add 20 % FPU Mult 13 % load 26 % 23 % store 9 % 9 % branch 16 % 8 % other 10 % 12 % SPECint92: compress, eqntott, espresso, gcc , li SPECfp92: doduc, ear, hydro2d, mdijdp2, su2cor What is the average run length between branches?

Reducing Control Transfer Penalties Asanovic/Devadas Spring 2002 6.823 Reducing Control Transfer Penalties Software solution • loop unrolling Increases the run length • instruction scheduling Compute the branch condition as early as possible (limited) Hardware solution • delay slots replaces pipeline bubbles with useful work (requires software cooperation) • branch prediction & speculative execution of instructions beyond the branch

Asanovic/Devadas Spring 2002 6.823 Branch Prediction Motivation: branch penalties limit performance of deeply pipelined processors Modern branch predictors have high accuracy (>95%) and can reduce branch penalties significantly Required hardware support: Prediction structures: branch history tables, branch target buffers, etc. Mispredict recovery mechanisms: • In-order machines: kill instructions following branch in pipeline • Out-of-order machines: shadow registers and memory buffers for each speculated branch

DLX Branches and Jumps Instruction Taken known? Target known? Asanovic/Devadas Spring 2002 6.823 DLX Branches and Jumps Instruction Taken known? Target known? BEQZ/BNEZ After Reg. Fetch After Inst. Fetch J Always Taken After Inst. Fetch JR Always Taken After Reg. Fetch Must know (or guess) both target address and whether taken to execute branch/jump.