A. Moshovos ©ECE1773 - Fall ‘07 ECE Toronto Out-of-Order Execution Scheduling.

Slides:



Advertisements
Similar presentations
Spring 2003CSE P5481 Out-of-Order Execution Several implementations out-of-order completion CDC 6600 with scoreboarding IBM 360/91 with Tomasulos algorithm.
Advertisements

CSE 502: Computer 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.
1 Lecture 11: Modern Superscalar Processor Models Generic Superscalar Models, Issue Queue-based Pipeline, Multiple-Issue Design.
A. Moshovos ©ECE Spring ‘02 ECE Toronto Instruction Level Parallel Processing Sequential Execution Semantics Superscalar Execution –Interruptions.
Computer Structure 2014 – Out-Of-Order Execution 1 Computer Structure Out-Of-Order Execution Lihu Rappoport and Adi Yoaz.
A scheme to overcome data hazards
Dynamic ILP: Scoreboard Professor Alvin R. Lebeck Computer Science 220 / ECE 252 Fall 2008.
1 Lecture: Out-of-order Processors Topics: out-of-order implementations with issue queue, register renaming, and reorder buffer, timing, LSQ.
CS6290 Tomasulo’s Algorithm. Implementing Dynamic Scheduling Tomasulo’s Algorithm –Used in IBM 360/91 (in the 60s) –Tracks when operands are available.
Dyn. Sched. CSE 471 Autumn 0219 Tomasulo’s algorithm “Weaknesses” in scoreboard: –Centralized control –No forwarding (more RAW than needed) Tomasulo’s.
Computer Organization and Architecture (AT70.01) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Dr. Sumanta Guha Slide Sources: Based.
COMP25212 Advanced Pipelining Out of Order Processors.
ECE 2162 Tomasulo’s Algorithm. Implementing Dynamic Scheduling Tomasulo’s Algorithm –Used in IBM 360/91 (in the 60s) –Tracks when operands are available.
Microprocessor Microarchitecture Dependency and OOO Execution Lynn Choi Dept. Of Computer and Electronics Engineering.
Spring 2003CSE P5481 Reorder Buffer Implementation (Pentium Pro) Hardware data structures retirement register file (RRF) (~ IBM 360/91 physical registers)
CPE 731 Advanced Computer Architecture ILP: Part IV – Speculative Execution Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University.
© A. Moshovos (ECE, Toronto) ECE1773 – Spring 2002 ILP, cont. Maintaining Sequential Appearance –Precise Interrupts –RUU approach to OoO Scheduling.
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.
Computer Architecture 2011 – Out-Of-Order Execution 1 Computer Architecture Out-Of-Order Execution Lihu Rappoport and Adi Yoaz.
1 Lecture 18: Core Design Today: basics of implementing a correct ooo core: register renaming, commit, LSQ, issue queue.
1 Lecture 7: Out-of-Order Processors Today: out-of-order pipeline, memory disambiguation, basic branch prediction (Sections 3.4, 3.5, 3.7)
Computer Architecture 2011 – out-of-order execution (lec 7) 1 Computer Architecture Out-of-order execution By Dan Tsafrir, 11/4/2011 Presentation based.
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.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed, Oct 5, 2005 Topic: Instruction-Level Parallelism (Dynamic Scheduling: Scoreboarding)
Computer Architecture 2010 – Out-Of-Order Execution 1 Computer Architecture Out-Of-Order Execution Lihu Rappoport and Adi Yoaz.
A. Moshovos ©ECE Fall ‘06 ECE Toronto Instruction Level Parallel Processing Sequential Execution Semantics Superscalar Execution –Interruptions Out-of-Order.
Nov. 9, Lecture 6: Dynamic Scheduling with Scoreboarding and Tomasulo Algorithm (Section 2.4)
1 Sixth Lecture: Chapter 3: CISC Processors (Tomasulo Scheduling and IBM System 360/91) Please recall:  Multicycle instructions lead to the requirement.
1 Lecture 5 Overview of Superscalar Techniques CprE 581 Computer Systems Architecture, Fall 2009 Zhao Zhang Reading: Textbook, Ch. 2.1 “Complexity-Effective.
1 Lecture 6 Tomasulo Algorithm CprE 581 Computer Systems Architecture, Fall 2009 Zhao Zhang Reading:Textbook 2.4, 2.5.
Professor Nigel Topham Director, Institute for Computing Systems Architecture School of Informatics Edinburgh University Informatics 3 Computer Architecture.
1 Lecture 5: Dependence Analysis and Superscalar Techniques Overview Instruction dependences, correctness, inst scheduling examples, renaming, speculation,
1 Lecture 7: Speculative Execution and Recovery Branch prediction and speculative execution, precise interrupt, reorder buffer.
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 –
Dataflow Order Execution  Use data copying and/or hardware register renaming to eliminate WAR and WAW ­register name refers to a temporary value produced.
COMP25212 Advanced Pipelining Out of Order Processors.
1 Lecture 10: Memory Dependence Detection and Speculation Memory correctness, dynamic memory disambiguation, speculative disambiguation, Alpha Example.
CS203 – Advanced Computer Architecture ILP and Speculation.
Instruction-Level Parallelism and Its Dynamic Exploitation
Dynamic Scheduling Why go out of style?
/ Computer Architecture and Design
Tomasulo’s Algorithm Born of necessity
Out of Order Processors
CS203 – Advanced Computer Architecture
Microprocessor Microarchitecture Dynamic Pipeline
Computer Architecture
Advantages of Dynamic Scheduling
Sequential Execution Semantics
High-level view Out-of-order pipeline
CMSC 611: Advanced Computer Architecture
Out of Order Processors
Lecture 8: ILP and Speculation Contd. Chapter 2, Sections 2. 6, 2
ECE 2162 Reorder Buffer.
Lecture 11: Memory Data Flow Techniques
Out-of-Order Execution Scheduling
CS 704 Advanced Computer Architecture
Adapted from the slides of Prof
Checking for issue/dispatch
Lecture 7: Dynamic Scheduling with Tomasulo Algorithm (Section 2.4)
Static vs. dynamic scheduling
Advanced Computer Architecture
Static vs. dynamic scheduling
Tomasulo Organization
Adapted from the slides of Prof
Prof. Onur Mutlu Carnegie Mellon University Fall 2011, 9/30/2011
High-level view Out-of-order pipeline
Lecture 7 Dynamic Scheduling
Conceptual execution on a processor which exploits ILP
Presentation transcript:

A. Moshovos ©ECE Fall ‘07 ECE Toronto Out-of-Order Execution Scheduling

A. Moshovos ©ECE Fall ‘07 ECE Toronto Instruction Level Parallel Processing Sequential Execution Semantics Out-of-Order Execution –How it can help –Issues: Maintaining Sequential Semantics Scheduling –Scoreboard Register Renaming Initially, we’ll focus on Registers, Memory later on

A. Moshovos ©ECE Fall ‘07 ECE Toronto Sequential Semantics - Review Instructions appear as if they executed: –In the order they appear in the program –One after the other Program Order PipeliningSuperscalarOut-of-Order

A. Moshovos ©ECE Fall ‘07 ECE Toronto fetchdecode fetchdecode sub bne fetchdecodeadd fetchdecodeld fetchdecodeadd Out-of-Order Execution do { sum += a[++m]; i--; } while (i != 0); out-of-order loop:addr4,r4,1 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop fetchdecode fetchdecode sub bne fetchdecodeadd fetchdecodeld fetchdecodeadd Superscalar

A. Moshovos ©ECE Fall ‘07 ECE Toronto fetchdecode fetchdecode sub bne fetchdecodeadd fetchdecodeld fetchdecodeadd Sequential Semantics? Execution does NOT adhere to sequential semantics To be precise: Eventually it may Simplest solution: Define problem away Not acceptable today: e.g., Virtual Memory Three-phase Instruction execution –In-Progress, Completed and Committed inconsistent consistent

A. Moshovos ©ECE Fall ‘07 ECE Toronto Out-of-order Execution Issues Preserving Sequential Semantics Stalling Instructions w/ dependences Issuing Instructions when dependences are satisfied

A. Moshovos ©ECE Fall ‘07 ECE Toronto Back to Sequential Semantics Instr. exec. in 3 phases: –In-progress, Completed, Committed –OOO for in-progress and Completed –In-order Commits Completed - out-of-order: ”Visible only inside” –Results visible to subsequent instructions –Results not visible to outsiders On interrupts completed results are discarded Committed - in-order: ”Visible to all” –Results visible to subsequent instructions –Results visible to outsiders On interrupt committed results are preserved

A. Moshovos ©ECE Fall ‘07 ECE Toronto How Completes Help w/ Performance Time DIV R3, _, _ ADD R1, _, _ ADD _, R1, _ In-order commits in-order completes out-of-order completes in-order commits complete fetchdecode fetchdecode sub bne fetchdecodeadd fetchdecodeld fetchdecodeadd commit

A. Moshovos ©ECE Fall ‘07 ECE Toronto Implementing Completes/Commits Key idea: –Maintain sufficient state around to be able to roll- back when necessary –Roll-back: Discard (aka Squash) all not committed One solution (conceptual): –Upon Complete instruction records previous value of target register –Upon Discard, instruction restores target value –Upon Commit, nothing to do We will return to this shortly Focus on scheduling mechanisms

A. Moshovos ©ECE Fall ‘07 ECE Toronto Out-of-Order Execution Overview Program FormProcessing Phase Static program dynamic inst. Stream (trace) execution window completed instructions Dispatch/ dependences inst. Issue inst execution inst. Reorder & commit In-Progress Completed Committed

A. Moshovos ©ECE Fall ‘07 ECE Toronto Out-of-Order Execution: Stages Fetch: get instruction from memory Decode/Dispatch: what is it? What are the dependences Issue: Go – all dependences satisfied Execute: perform operation Complete: result available to other insts. Commit: result available to outsiders We’ll start w/ Decode/Dispatch Then we’ll consider Issue

A. Moshovos ©ECE Fall ‘07 ECE Toronto OOO Scheduling Decode: –Do I have dependences yet to be satisfied? –Yes, stall until they are –No, clear to issue Wakeup Instructions Stalled: –Dependences satisfied –Allow instruction to issue Dependence: –(later instruction, earlier instruction) & type We’ll first consider RAW and then move on to WAW and WAR

A. Moshovos ©ECE Fall ‘07 ECE Toronto Decode for RAW Are there unsatisfied dependences? –RAW: have to wait for register value –We don’t really care who is producing the value –Only whether it is available Can use the Register Availability Vector as in pipelining/superscalar –Also known as scoreboard At Decode –Reset bit corresponding to your target –At writeback set –Check all bits for source regs: if any is 0 stall

A. Moshovos ©ECE Fall ‘07 ECE Toronto Issuing Instructions: Scheduling Determine when an instruction can issue –Ignore resources for the time being Stalled because of RAW w/ preceding instruction Concept: –Producer (write) notifies consumers (read) Requirements: –Consumers need to be able to identify producer –The register name is one possible link Mechanism –Consumer placed in a reservation station –Producers on complete broadcasts identity –Waiting instructions observe –Update Operand Availability –Issue if all operands now available

A. Moshovos ©ECE Fall ‘07 ECE Toronto Reservation Station State pertaining to an instruction –What registers it reads –Whether they are available –What is the destination register –What state is the instruction in Waiting Executing

A. Moshovos ©ECE Fall ‘07 ECE Toronto Out-Of-Order Exec. Example loop:addr4,r4,4 ld r2, 10(r4)4 cycles lat addr3,r3,r2 subr1,r1,1 bner1,r0,loop 1111 r1r2r3r4 RAV opsrc1src2tgt Cycle 0 status

A. Moshovos ©ECE Fall ‘07 ECE Toronto Out-Of-Order Exec. Example: Cycle r1r2r3r4 RAV opsrc1src2tgt Cycle 0 addr4/1NA/1r4/0Rdy status loop:addr4,r4,4 ld r2, 10(r4)5 cycles lat addr3,r3,r2 subr1,r1,1 bner1,r0,loop Ready to be executed

A. Moshovos ©ECE Fall ‘07 ECE Toronto Cycle 1 loop:addr4,r4,4 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop 1011 r1r2r3r4 RAV opsrc1src2tgt addr4/1NA/1r4Exec status ldr4/1NA/1r2Rdy R4 gets produced now Notify those waiting for R4

A. Moshovos ©ECE Fall ‘07 ECE Toronto Cycle 2 loop:addr4,r4,4 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop 1001 r1r2r3r4 RAV opsrc1src2tgt addr4/1NA/1r4Cmtd status ldr4/1NA/1r2Exec Wait for r2 Result cycle 6 addr3/1r2/0r3Wait

A. Moshovos ©ECE Fall ‘07 ECE Toronto Cycle 3 loop:addr4,r4,4 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop 0001 r1r2r3r4 RAV opsrc1src2tgt addr4/1NA/1r4Cmtd status ldr4/1NA/1r2Exec Wait for r2 Result cycle 6 addr3/1r2/0r3Wait subr1/1NA/1r1Rdy No dependences

A. Moshovos ©ECE Fall ‘07 ECE Toronto Cycle 4 loop:addr4,r4,4 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop 1001 r1r2r3r4 RAV opsrc1src2tgt addr4/1NA/1r4Cmtd status ldr4/1NA/1r2Exec Wait for r2 Result cycle 6 addr3/1r2/0r3Wait subr1/1NA/1r1Exec r1 produced now Notify consumers bner1/1r0/1NARdy r1 will be available next cycle

A. Moshovos ©ECE Fall ‘07 ECE Toronto Cycle 5 loop:addr4,r4,4 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop 1001 r1r2r3r4 RAV opsrc1src2tgt addr4/1NA/1r4Cmtd status ldr4/1NA/1r2Exec Wait for r2 Result cycle 6 addr3/1r2/0r3Wait subr1/1NA/1r1Compl Completed bner1/1r0/1NAExec executing

A. Moshovos ©ECE Fall ‘07 ECE Toronto Cycle 6 loop:addr4,r4,4 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop 1101 r1r2r3r4 RAV opsrc1src2tgt addr4/1NA/1r4Cmtd status ldr4/1NA/1r2Exec Wait for r2 Result cycle 6 Notify consumers addr3/1r2/1r3Rdy subr1/1NA/1r1Compl Completed bner1/1r0/1NAExec executing

A. Moshovos ©ECE Fall ‘07 ECE Toronto Cycle 7 loop:addr4,r4,4 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop 1111 r1r2r3r4 RAV opsrc1src2tgt addr4/1NA/1r4Cmtd status ldr4/1NA/1r2Cmtd Executing Notify consumers addr3/1r2/1r3Exec subr1/1NA/1r1Compl Completed bner1/1r0/1NACompl

A. Moshovos ©ECE Fall ‘07 ECE Toronto Cycle 8 loop:addr4,r4,4 ld r2, 10(r4) addr3,r3,r2 subr1,r1,1 bner1,r0,loop 1111 r1r2r3r4 RAV opsrc1src2tgt addr4/1NA/1r4Cmtd status ldr4/1NA/1r2Cmtd addr3/1r2/1r3Cmtd subr1/1NA/1r1Cmtd bner1/1r0/1NACmtd

A. Moshovos ©ECE Fall ‘07 ECE Toronto Notifying Consumers Identity of Producer Uniquely Identify the Instruction Easily decode by others –Target Register Recall we stall on WAR or WAW –Functional Unit If not pipelined –Place in instruction window –PC? not. Why?

A. Moshovos ©ECE Fall ‘07 ECE Toronto Name Dependences and OOO WAW or WAR: We need to update register but others are still using it –add r1, r1, 10 –sw r1, 20(r2) –addr1, r3, 30 –subr2, r1, 40 There is only one r1 –sw needs to see the value of 1 st add –sub needs to wait for 2 nd add and not 1 st Solution: Stall decode when WAW or WAR

A. Moshovos ©ECE Fall ‘07 ECE Toronto Detecting WAW and WAR WAW? Look at Scoreboard –If bit is 0 then there is a pending write –Stall WAR? Need to know whether all preceding consumers have read the value –Keep a count per register –Increase at decode for all reads –Decrease on issue More elegant solution via register renaming –Soon

A. Moshovos ©ECE Fall ‘07 ECE Toronto Window vs. Scheduler Window –Distance between oldest and youngest instruction that can co-exist inside the CPU –Larger window  Potential for more ILP Scheduler –Number of instructions that are waiting to be issued Window –Instructions enter at Fetch –Exit at Commit Scheduler –Instructions enter at Decode –Leave at writeback Window >= Scheduler –Can be the same structure In window but not in scheduler  completed instructions

A. Moshovos ©ECE Fall ‘07 ECE Toronto Scoreboarding Schedule based on RAW dependences WAW and WAR cause stalls –WAW at decode –WAR at writeback Optimization: Why is this OK? Implemented in the CDC 6600 in ‘64 –18 non-pipelined FUs 4 FP: 2 mul, 1 add, 1 div 7 MEM: 5 load, 2 store 7 INT: add, shift, logical etc. Centralized Control Scheme –Controls all Instruction Issue –Detects all hazards

A. Moshovos ©ECE Fall ‘07 ECE Toronto MIPS/DLX w/ Scoreboarding Register File FP mul FP divide FP add FP integer scoreboard

A. Moshovos ©ECE Fall ‘07 ECE Toronto Scoreboarding Overview Ignore IF and MEM for simplicity 4-stage execution –IssueCheck for structural hazards Check for WAW hazards Stall until all clear –ReadOpCheck for RAW hazards Wait until all operands ready Read Registers –ExecuteExecute Operations Notify scoreboard when complete –WriteCheck for WAR hazards Stall Write until all clear A completing instruction cannot write dest if an earlier instruction has not read dest.

A. Moshovos ©ECE Fall ‘07 ECE Toronto Scoreboarding Optimizations/Tricks WAW as in original OOO WAR is optimized –Second Producer is allowed to execute up to complete –It is stalled there until preceding consumers complete No Commit –No precise interrupts Window is implemented in the scoreboard One entry per Functional Unit –Recall not pipelined –Instructions identified by FU id

A. Moshovos ©ECE Fall ‘07 ECE Toronto Scoreboarding Organization Three structures –Instruction Status –Functional Unit Status –Register Result Status Instruction Status –Which stage the instruction is currently in Functional Unit Status: scheduling –Busy –OPOperation –FiDest. Reg. –Fj, FkSource Regs –Qj, QkFUs producing sources –Rj, RkReady bits for sources Register Result Status: dep. determination –Which FU will produce a register

A. Moshovos ©ECE Fall ‘07 ECE Toronto Scoreboarding explained Register status reg: –Which FU produces the register Use at decode –Source reg match is a RAW –Target reg macth is a WAW stall

A. Moshovos ©ECE Fall ‘07 ECE Toronto Functional Unit Status Busy: –resource allocation OP: –what to do once issued (e.g., add, sub) Dest. Reg.: –Where to write result –To find WAR Fj, FkSource Regs –for WAR: can’t write if consumers pending for previous value of register (if FU not the same) Qj, QkFUs producing sources –To wait for appropriate producer Rj, RkReady bits for sources –To determine when ready: all ready

A. Moshovos ©ECE Fall ‘07 ECE Toronto Scoreboarding Example

A. Moshovos ©ECE Fall ‘07 ECE Toronto Example: Cycle 0

A. Moshovos ©ECE Fall ‘07 ECE Toronto Example, contd. The rest you’ll find on the web site Go through it Source: Patterson Summary: –Execution proceeds in an order dictated by dependences –RAW, WAR and WAW force ordering –Tricks may be possible

A. Moshovos ©ECE Fall ‘07 ECE Toronto Beyond Simple OoO AB CD E A:LFF6, 34(R2) B:LFF2,45(R3) C:MULFF0,F2, F4 D:SUBFF8,F2,F6 E:ADDFF2,F7,F4 E will wait for B, C and D. WAR w/ C and D WAW w/ B Can we do better?

A. Moshovos ©ECE Fall ‘07 ECE Toronto What if we had infinite registers A:LFF6, 34(R2) B:LFF2,45(R3) C:MULFF0,F2, F4 D:SUBFF8,F2,F6 E:ADDFF2,F7,F4 A:LFF6, 34(R2) B:LFF2,45(R3) C:MULFF0,F2, F4 D:SUBFF8,F2,F6 E:ADDFF9,F7,F4 No false dependences anymore Since we do not reuse a name we can’t have WAW and WAR

A. Moshovos ©ECE Fall ‘07 ECE Toronto Why we can’t have Infinite Registers False/Name dependences (WAR and WAW) –Artifact of having finite registers There is no such thing as infinite There is no such thing as large enough –Well there is (in a sec.) –Computers execute Billions of Instructions per sec. Even a multi-billion register file would soon be exhausted Want to exploit parallelism across several instances of the same code –Loops, recursive functions (most frequent part)

A. Moshovos ©ECE Fall ‘07 ECE Toronto Yes, there is “large enough” At any given point there will be a finite number of instructions in the window if each instruction has a single register target if there are N instructions How many registers do we need? N? N + X?

A. Moshovos ©ECE Fall ‘07 ECE Toronto Register Renaming Register Version –Every Write creates a new version –Uses read the last version –Need to keep a version until all uses have read it. Register Renaming: –Architectural vs. Physical Registers more phys. than arch. –Maintain a map of arch. to phys. regs. –Use in-order decoding to properly identify dependences. –Instructions wait only for input op. availability. –Only last version is written to reg. file.

A. Moshovos ©ECE Fall ‘07 ECE Toronto Register Renaming A:DIVFF3, F1,F0r1, -, - B:SUBFF2,F1,F0 r2, -, - C:MULFF0,F2, F4 r3, r2, - D:SUBFF6,F2,F3 r4, r2, r1 E:ADDFF2,F5,F4r5, -, - F: ADDFF0,F0,F2 r6, r3, r5 Need more physical registers than architectural Ignore control flow for the time being.

A. Moshovos ©ECE Fall ‘07 ECE Toronto Register Renaming Process Only need to remember last producer of each architectural register –Vector At decode –Find the most recent producers for all source registers –After: declare self as most recent producer of target register Complication: –May have to retract Speculative Execution, e.g., interrupts –Need to be able to restore the mapping state

A. Moshovos ©ECE Fall ‘07 ECE Toronto Register Renaming Support Structures Register Rename Table –f(aR) = pR –one entry per architectural Register Free Register List –Lists not used Physical Registers At Decode –grab a new register from the free list –Change mapping in rename table At Commit –Release Register? Not… Why? –Could release previous version

A. Moshovos ©ECE Fall ‘07 ECE Toronto How Many Physical Registers? Correctness: –At least as many architectural plus? Performance: –As many as possible –Not correctness –Recall not all instructions produce register results stores and branches

A. Moshovos ©ECE Fall ‘07 ECE Toronto Dynamic Scheduling A:DIVFF3, F1,F0r1, -, - B:SUBFF2, F1,F0r2, -, - C:MULFF0, F2, F4r3, r2, - D:SUBFF6, F2,F3r4, r2, r1 E:ADDFF2, F5,F4r5, -, - F: ADDFF0, F0,F2r6, r3, r5 Name Value - Values and Names flow together - Writeback specifies both value and name - A waiting instruction inspects all results - It is allowed to execute when all inputs are available

A. Moshovos ©ECE Fall ‘07 ECE Toronto Physical Registers Physical register file is just one option What we need is separate storage –Consumers could keep values in their reservation station –Tomasulo’s next

A. Moshovos ©ECE Fall ‘07 ECE Toronto Tomasulo’s Algorithm IBM 360/91 - Fast 360 for scientific code –Completed in 1967 –Dynamic scheduling –Predates cache memories Pipelined FUs –Adder up to 3 instructions –Multiplier up to 2 instructions Tomasulo vs. Scoreboard –Distributed hazard detection and control –Results are bypassed to FUs –Common Data Bus (CDB) for results All results visible to all instead of via a register

A. Moshovos ©ECE Fall ‘07 ECE Toronto DLX w/ Tomasulo Tomasulo’s Algorithm –Use “tags” to identify data values –Reservation stations distributed control –CDB broadcasts all results to all RSs Extend DLX as example –Assume multiple FUs than pipelined –Main difference is Register-Memory Insts. I.e., DLX does not have them But that’s really a detail :-) Physical Registers? –Not really. What we need is different storage and name for every version. –Here it’s the producing reservation station

A. Moshovos ©ECE Fall ‘07 ECE Toronto Dynamic DLX addersMults Load buffers Store buffers CDB RS Operation Stack Registers

A. Moshovos ©ECE Fall ‘07 ECE Toronto Tomasulo’s Algorithm 3 major steps –Dispatch Get instruction from fetch queue ALU op: check for available RS Load: Check for available load buffer If available: dispatch and copy read regs to RS or load buffer if not: stall - structural hazard –Issue If all ops are available: issue If not monitor CDB for operands –Complete If CDB available, broadcast result else stall

A. Moshovos ©ECE Fall ‘07 ECE Toronto Tomasulo’s Algorithm contd. Reservation stations –Handle distributed hazard detection and instruction control Everything receiving data get its tag –4-bit tag specifies reservation station or load buffer –Also which FU will produce result Register specifier is used to assign tags –Then they are discarded –Input register specifiers are ONLY used in dispatch. (Rename table) Common Data Bus: –value + “tag” = where this comes from –vs. typical bus: value + “tag” = where this goes to

A. Moshovos ©ECE Fall ‘07 ECE Toronto Tomasulo’s Algorithm Contd. Reservation Stations –OpOpcode –Qj, QkTag Fields (source ops) –Vj, VkOperand values (source ops) –BusyCurrently in use Register file and Store Buffer –QiTag field –BusyCurrently in use –ViValue Load Buffers –Busy Currently in Use

A. Moshovos ©ECE Fall ‘07 ECE Toronto Arch. Reg. Name Tomasulo’s: Understanding Speculative vs. Architectural State add r1, r2, 10 sub r4, r1, 20 add r1, r3, 30 Value of r1I have it Value of r2I have it Value of r3I have it Value of r4I have it Register file Where is the register? Can be: “I have it”, “reservation station id” Value of Src1NA Value of Src2NA tgtsrc2 Value of Src1NA Value of Src2NA Reservation Stations Reg Arch. name src1

A. Moshovos ©ECE Fall ‘07 ECE Toronto Renaming 1 st Instruction add r1, r2, 10 sub r4, r1, 20 add r1, r3, RS0 Value of r2I have it Value of r3I have it Value of r4I have it Register file Value of R2r1I have it10I have it tgtsrc2 Value of Src1NA Value of Src2NA Reservation Stations src1 Value of Src1NA Value of Src2NA RS0 Read sources (r2) Rename r1 to RS0

A. Moshovos ©ECE Fall ‘07 ECE Toronto Renaming 2 nd Instruction -----RS0 Value of r2I have it Value of r3I have it ----RS1 Register file Value of R2r1I have it10I have it tgtsrc2 ----r4RS020I have it Reservation Stations src1 Value of Src1NA Value of Src2NA RS1 Sources: r1 in RS0 NYA Rename r4 to RS1 add r1, r2, 10 sub r4, r1, 20 add r1, r3, 30

A. Moshovos ©ECE Fall ‘07 ECE Toronto Renaming 3 rd Instruction -----RS2 Value of r2I have it Value of r3I have it ----RS1 Register file Value of R2r1I have it10I have it tgtsrc2 ----r4RS020I have it Reservation Stations src1 Value of R3r1I have it30I have it RS2 Sources: r3 Avail. Rename r1 to RS2 add r1, r2, 10 sub r4, r1, 20 add r1, r3, 30

A. Moshovos ©ECE Fall ‘07 ECE Toronto Example: cycle 0

A. Moshovos ©ECE Fall ‘07 ECE Toronto Example: cycle 1

A. Moshovos ©ECE Fall ‘07 ECE Toronto Example: cycle 3 - Mul is issued vs. scoreboard - What’s waiting for L1?

A. Moshovos ©ECE Fall ‘07 ECE Toronto Example… Check the web site… Too much for in-class Summary: –Execution proceeds in any order that does not violate RAW dependences –WAR and WAW are removed

A. Moshovos ©ECE Fall ‘07 ECE Toronto Tomasulo’s vs. Scoreboard - In-order issue - Out-of-order execution - Out-of-order completion Scoreboard:

A. Moshovos ©ECE Fall ‘07 ECE Toronto Tomasulo’s Out-of-order loads and stores? –What about WAW, RAW and WAR? –Compare all load addresses against the addresses of all preceding store buffers –Stall if they match CDB is a bottleneck –One write per cycle –Could duplicate –But, come at a cost –Datapath + duplicated tags and control Complex Implementation –Scalability? –All results to all sources –What if we want 128 instrs?

A. Moshovos ©ECE Fall ‘07 ECE Toronto Tomasulo’s Advantages –Distribution of hazard detection –Elimination of WAR and WAW stalls Common Data Bus –Broadcasts result to multiple instrs (+) –Bottleneck Register Renaming –Removes WAR and WAW hazards –More interesting when same code appears twice Think of loops More on this later –BUT: Associative lookups –RECALL: direct map is faster

A. Moshovos ©ECE Fall ‘07 ECE Toronto In Summary