EEC 581 Computer Architecture. Instruction Level Parallelism (3.4 & 3.5 Dynamic Scheduling)

Similar documents
Instruction Level Parallelism and Its. (Part II) ECE 154B

Tomasulo Algorithm. Developed at IBM and first implemented in IBM s 360/91

Advanced Pipelining and Instruction-Level Paralelism (2)

CS152 Computer Architecture and Engineering Lecture 17 Advanced Pipelining: Tomasulo Algorithm

Computer Architecture Spring 2016

Dynamic Scheduling. Differences between Tomasulo. Tomasulo Algorithm. CDC 6600 scoreboard. Or ydanicm ceshuldngi

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

Instruction Level Parallelism Part III

Instruction Level Parallelism Part III

Differences between Tomasulo. Another Dynamic Algorithm: Tomasulo Organization. Reservation Station Components

Lecture 16: Instruction Level Parallelism -- Dynamic Scheduling (OOO) via Tomasulo s Approach

Outline. 1 Reiteration. 2 Dynamic scheduling - Tomasulo. 3 Superscalar, VLIW. 4 Speculation. 5 ILP limitations. 6 What we have done so far.

Scoreboard Limitations

Scoreboard Limitations!

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

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

DYNAMIC INSTRUCTION SCHEDULING WITH TOMASULO

Out-of-Order Execution

Instruction Level Parallelism

CS 152 Midterm 2 May 2, 2002 Bob Brodersen

Very Short Answer: (1) (1) Peak performance does or does not track observed performance.

Enhancing Performance in Multiple Execution Unit Architecture using Tomasulo Algorithm

Slide Set 6. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Contents Slide Set 6. Introduction to Chapter 7 of the textbook. Outline of Slide Set 6. An outline of the first part of Chapter 7

EECS150 - Digital Design Lecture 9 - CPU Microarchitecture. CMOS Devices

On the Rules of Low-Power Design

BUSES IN COMPUTER ARCHITECTURE

Pipeline design. Mehran Rezaei

06 1 MIPS Implementation Pipelined DLX and MIPS Implementations: Hardware, notation, hazards.

PIPELINING: BRANCH AND MULTICYCLE INSTRUCTIONS

Sequencing and Control

Modeling Digital Systems with Verilog

CS/ECE 250: Computer Architecture. Basics of Logic Design: ALU, Storage, Tristate. Benjamin Lee

A VLIW Processor for Multimedia Applications

CS 250 VLSI System Design

Low Power VLSI Circuits and Systems Prof. Ajit Pal Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Registers. Unit 12 Registers and Counters. Registers (D Flip-Flop based) Register Transfers (example not out of text) Accumulator Registers

CS 110 Computer Architecture. Finite State Machines, Functional Units. Instructor: Sören Schwertfeger.

AN ABSTRACT OF THE THESIS OF

Optimization of Multi-Channel BCH Error Decoding for Common Cases. Russell Dill Master's Thesis Defense April 20, 2015

CPE300: Digital System Architecture and Design

Sequential Logic. Introduction to Computer Yung-Yu Chuang

An Adaptive Technique for Reducing Leakage and Dynamic Power in Register Files and Reorder Buffers

Logic Devices for Interfacing, The 8085 MPU Lecture 4

6.3 Sequential Circuits (plus a few Combinational)

Pipelining. Improve performance by increasing instruction throughput Program execution order. Data access. Instruction. fetch. Data access.

DC Ultra. Concurrent Timing, Area, Power and Test Optimization. Overview

Microprocessor Design

Sequential Elements con t Synchronous Digital Systems

ECE 250 / CPS 250 Computer Architecture. Basics of Logic Design ALU and Storage Elements

Logic Design II (17.342) Spring Lecture Outline

Digital Integrated Circuits EECS 312. Review. Remember the ENIAC? IC ENIAC. Trend for one company. First microprocessor

Outline. EECS150 - Digital Design Lecture 27 - Asynchronous Sequential Circuits. Cross-coupled NOR gates. Asynchronous State Transition Diagram

Digital Integrated Circuits EECS 312

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

More Digital Circuits

CHAPTER 4: Logic Circuits

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

CS3350B Computer Architecture Winter 2015

Sharif University of Technology. SoC: Introduction

CHAPTER 4: Logic Circuits

A Case for Merging the ILP and DLP Paradigms

CS 61C: Great Ideas in Computer Architecture

Tomasulo Algorithm Based Out of Order Execution Processor

ECSE-323 Digital System Design. Datapath/Controller Lecture #1

Long and Fast Up/Down Counters Pushpinder Kaur CHOUHAN 6 th Jan, 2003

Timing EECS141 EE141. EE141-Fall 2011 Digital Integrated Circuits. Pipelining. Administrative Stuff. Last Lecture. Latch-Based Clocking.

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

CprE 281: Digital Logic

Sequencing. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C. Fall,

VLSI Design: 3) Explain the various MOSFET Capacitances & their significance. 4) Draw a CMOS Inverter. Explain its transfer characteristics

CprE 281: Digital Logic

Sequential Logic Design CS 64: Computer Organization and Design Logic Lecture #14

Go BEARS~ What are Machine Structures? Lecture #15 Intro to Synchronous Digital Systems, State Elements I C


Logic Design. Flip Flops, Registers and Counters

Bubble Razor An Architecture-Independent Approach to Timing-Error Detection and Correction

First Name Last Name November 10, 2009 CS-343 Exam 2

OUT-OF-ORDER processors with precise exceptions

VLSI System Testing. BIST Motivation

THE USE OF forward error correction (FEC) in optical networks

Why FPGAs? FPGA Overview. Why FPGAs?

CacheCompress A Novel Approach for Test Data Compression with cache for IP cores

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

HIGH SPEED ASYNCHRONOUS DATA MULTIPLEXER/ DEMULTIPLEXER FOR HIGH DENSITY DIGITAL RECORDERS

CS61C : Machine Structures

12-bit Wallace Tree Multiplier CMPEN 411 Final Report Matthew Poremba 5/1/2009

Implementation of an MPEG Codec on the Tilera TM 64 Processor

Laboratory Exercise 4

Chapter 4 (Part I) The Processor. Baback Izadi Division of Engineering Programs

Clock and Asynchronous Signals

An automatic synchronous to asynchronous circuit convertor

FPGA Development for Radar, Radio-Astronomy and Communications

FPGA Design. Part I - Hardware Components. Thomas Lenzi

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o. Lecture #14

CS61C : Machine Structures

EECS150 - Digital Design Lecture 10 - Interfacing. Recap and Topics

MPEG decoder Case. K.A. Vissers UC Berkeley Chamleon Systems Inc. and Pieter van der Wolf. Philips Research Eindhoven, The Netherlands

SoC IC Basics. COE838: Systems on Chip Design

Logic Analysis Basics

Transcription:

1 EEC 581 Computer Architecture Instruction Level Parallelism (3.4 & 3.5 Dynamic Scheduling) Chansu Yu Electrical and Computer Engineering Cleveland State University Overview of Chap. 3 (again) Pipelined architecture allows multiple instructions run in parallel (ILP) But, it has data and control hazard problems How can we avoid or alleviate the hazard problems in pipelined architecture? Key idea is to reorder the execution of instructions!!! 3.3 Branch prediction (branch history table) 3.4 & 3.5 Multiple issue dependency Dynamic scheduling (forwarding) 3.6 Speculative execution ( commit ) 3.7 Multiple issue dependency 9/4/2018 Static scheduling ( VLIW ) 2

2 Outline ILP (3.1) Compiler techniques to increase ILP (3.1) Loop Unrolling (3.2) Static Branch Prediction (3.3) Dynamic Branch Prediction (3.3) Overcoming Data Hazards with Dynamic Scheduling (3.4) Tomasulo Algorithm (3.5) Speculation, Speculative Tomasulo, Memory Aliases, Exceptions, Register Renaming vs. Reorder Buffer (3.6) VLIW, Increasing instruction bandwidth (3.7) Instruction Delivery (3.9) 9/4/2018 3 Extracting Yet More Performance Two options: Increase the depth of the pipeline to increase the clock rate superpipelining Fetch (and execute) more than one instructions at one time (expand every pipeline stage to accommodate multiple instructions) multiple-issue (VLIW or superscalar) 9/4/2018 4

3 Extracting Yet More Performance Superpipelined: Increase the depth of the pipeline leading to shorter clock cycles (and more instructions in flight at one time) The higher the degree of superpipelining, the more forwarding/hazard hardware needed, the more pipeline latch overhead, and the bigger the clock skew Multiple-issue: Launching multiple instructions per stage allows the instruction execution rate, CPI, to be less than 1 So instead we use IPC: instructions per clock cycle E.g., a 6 GHz, four-way multiple-issue processor can execute at a peak rate of 24 billion instructions per second with a best case CPI of 0.25 or a best case IPC of 4 9/4/2018 5 Multiple-Issue Processor Styles Static multiple-issue processors (aka VLIW) Decisions on which instructions to execute simultaneously are being made statically (at compile time by the compiler) E.g., Intel Itanium and Itanium 2 for the IA-64 ISA EPIC (Explicit Parallel Instruction Computer) Dynamic multiple-issue processors (aka superscalar) Decisions on which instructions to execute simultaneously are being made dynamically (at run time by the hardware) E.g., IBM Power 2, Pentium 4, MIPS R10K, HP PA 8500 9/4/2018 6

4 Multiple-Issue Datapath Responsibilities Must handle, with a combination of hardware and software fixes, the fundamental limitations of Data hazards» We ll see in more detail Control hazards» Use dynamic branch prediction to help resolve the ILP issue Structural hazards» A SS/VLIW processor has a much larger number of potential resource conflicts» Functional units may have to arbitrate for result buses and register-file write ports» Resource conflicts can be eliminated by duplicating the resource or by pipelining the resource 9/4/2018 7 Instruction Issue and Completion Policies Instruction-issue initiate execution Instruction lookahead capability fetch, decode and issue instructions beyond the current instruction Instruction-completion complete execution Processor lookahead capability complete issued instructions beyond the current instruction Instruction-commit write back results to the RegFile In-order issue with in-order completion In-order issue with out-of-order completion Out-of-order issue with out-of-order completion Out-of-order issue with out-of-order completion and inorder commit 9/4/2018 8

5 In-Order Issue with In-Order Completion Simplest policy is to issue instructions in exact program order and to complete them in the same order they were fetched (i.e., in program order) Example: Assume a pipelined processor» that can fetch and decode two instructions per cycle,» that has three functional units, and» that can complete (and write back) two results per cycle I1 needs two execute cycles (a multiply) I2 I3 I4 needs the same function unit as I3 I5 needs data value produced by I4 I6 needs the same function unit as I5 9/4/2018 9 In-Order Issue, In-Order Completion I n s t r. O r d e r I1 I2 I3 I4 I5 I6 In parallel can Fetch/decode 2 Commit 2 I1 two execute cycles I2 I3 I4 same function unit as I3 I5 data value produced by I4 I6 same function unit as I5 need forwarding hardware 8 cycles in total 9/4/2018 10

6 In-Order Issue with Out-of-Order Completion With out-of-order completion, a later instruction may complete before a previous instruction Instruction issue is stalled when there is a resource conflict (e.g., for a functional unit) or a data conflict New type of hazards due to Anti-dependency (WAR hazard) Output dependency (WAW hazard) 9/4/2018 11 IOI-OOC Example I n s t r. O r d e r I1 I2 I3 I4 I5 I6 I1 two execute cycles I2 I3 I4 same function unit as I3 I5 data value produced by I4 I6 same function unit as I5 7 cycles in total: 1 cycle faster than IOI-IOC 9/4/2018 12

7 Data Dependence and Hazards Instr J is data dependent on Instr I => RAW hazard I: add r1,r2,r3 J: sub r4,r1,r3 Instr J is name dependent (anti-dependency) on Instr I => WAR hazard H: div r1,r2,r3 I: add r4,r1,r5 J: sub r5,r6,r7 Instr J is output dependent on Instr I => WAW hazard I: mul r1,r4,r3 J: add r1,r2,r3 K: sub r6,r1,r7 Not a problem in IOI-IOC processor 9/4/2018 13 IOI-OOC: Output Dependencies I n s t r. O r d e r I1 I2 I3 I4 I5 I6 There is one more situation that stalls instruction issuing with IOI- OOC. I1 writes to R1 I2 writes to R1 I5 reads R1 The issuing of I2 would have to be stalled While IOI-OOC yields higher performance, it requires more dependency checking hardware 9/4/2018 14

8 IOI-OOC: Output Dependencies WAW hazard I1: mul r1,r4,r3 I2: add r1,r2,r3 I3: or r0,r0,r0 I4: sub r6,r1,r7 r1 r1 r1 9/4/2018 15 Out-of-Order Issue with Out-of-Order Completion IOI processor stops decoding an instruction whenever it has a resource conflict or a data dependency. But, next instructions might have neither resource conflict nor a data dependency Fetch and decode instructions beyond the conflicted one, store them in an instruction buffer (as long as there s room), and flag those instructions in the buffer that don t have resource conflicts or data dependencies Flagged instructions are then issued from the buffer without regard to their program order 9/4/2018 16

9 OOI-OOC Example I n s t r. O r d e r I1 I2 I3 I4 I5 I6 I1 two execute cycles I2 I3 I4 same function unit as I3 I5 data value produced by I4 I6 same function unit as I5 6 cycles in total: 1 cycle faster than IOI-OOC 9/4/2018 17 OOI-OOC: Anti-Dependencies I n s t r. O r d e r I1 I2 I3 I4 I5 There is one more situation that stalls instruction issuing with OOI- OOC. I5 read R5 I6 writes to R5 The execution of I6 would have to be stalled While OOI-OOC requires more dependency checking. I6 9/4/2018 18

10 OOI-OOC: Anti-Dependencies WAR hazard I4: div r1,r2,r3 I5: div r4,r1,r5 I6: sub r5,r6,r7 r5 r5 9/4/2018 19 Dependencies Review Each of the three data dependencies True data dependencies (RAW) Anti-dependencies (WAR) storage conflicts Output dependencies (WAW) manifests itself through the use of registers (or other storage locations) True dependencies represent the flow of data and information through a program Anti- and output dependencies arise because of the limited number of registers; programmers reuse registers for different computations 9/4/2018 20

11 IOI-OOC: Output Dependencies WAW hazard I1: mul r1,r4,r3 I2: add r1,r2,r3 I3: or r0,r0,r0 I4: sub r6,r1,r7 Can be avoided by register renaming I1: mul r1,r4,r3 I2: add r10,r2,r3 I3: or r0,r0,r0 I4: sub r6,r10,r7 r10 r1 r10 9/4/2018 21 IOI-OOC: Output Dependencies WAW hazard I1: mul r1,r4,r3 I2: add r1,r2,r3 I3: or r0,r0,r0 I4: sub r6,r1,r7 r10 r1 adder Or, specify the functional unit that produces the new value of the register 9/4/2018 22

12 OOI-OOC: Anti-Dependencies WAR hazard I4: div r1,r2,r3 I5: div r4,r1,r5 I6: sub r5,r6,r7 Can be avoided by register renaming I4: div r1,r2,r3 I5: div r4,r1,r5 I6: sub r10,r6,r7 r5 r10 9/4/2018 23 Storage Conflicts and Register Renaming Storage conflicts can be reduced (or eliminated) by increasing or duplicating the troublesome resource Provide additional registers that are used to reestablish the correspondence between registers and values Register renaming the processor renames the original register identifier in the instruction to a new register (one not in the visible register set) R3 := R3 * R5 R4 := R3 + 1 R3 := R5 + 1 R3b := R3a * R5a R4a := R3b + 1 R3c := R5a + 1 With a limited number of registers (e.g., IBM 360 in 1966), hardware-based, dynamic scheduling was used. 9/4/2018 24

13 OOI-OOC: Anti-Dependencies WAR hazard I4: div r1,r2,r3 I5: div r4,r1,r5 I6: sub r5,r6,r7 r5 divider Specify the functional unit that produces the new value of the register, similar to forwarding => generalized forwarding 9/4/2018 25 Forwarding : Review 0 M u x 1 add r1, r2, r3 sub r2, and r3,. (ADDER3 ADDER2 ADDER1) / / /MEM MEM/ Add 4 Add Add result Shift left 2 PC Address Instruction memory Instruction Read register 1 Read register 2 Registers Write register Write data Comes from Read data 1 ADDER2 Read data 2 0 M u x 1 Comes from ADDER1 Zero ALU ALU result Address Write data Data memory Read data 1 M u x 0 16 Sign extend 32 In IOI-IOC processor, the forwarding unit takes care of the forwarding In OOI-OOC processor, operands specify values (Vj/Vk) or source ALU (Qj/Qk) 9/4/2018 26

14 Advantages of Dynamic Scheduling Dynamic scheduling - hardware rearranges the instruction execution to reduce stalls while maintaining data flow and exception behavior Stalls occur due to hazards or cache misses It handles cases when dependences unknown at compile time It simplifies the compiler and allows code that compiled for one pipeline to run efficiently on a different pipeline 9/4/2018 27 HW Schemes: Instruction Parallelism Key idea: Allow instructions behind stall to proceed DIVD ADDD SUBD F0,F2,F4 F10,F0,F8 F12,F8,F14 Enables out-of-order execution and allows out-oforder completion (e.g., SUBD) In a dynamically scheduled pipeline, all instructions still pass through issue stage in order (in-order issue) Will distinguish when an instruction begins execution and when it completes execution; between 2 times, the instruction is in execution Note: Dynamic execution creates WAR and WAW hazards and makes exceptions harder 9/4/2018 28

15 A Dynamic Algorithm: Tomasulo s For IBM 360/91 (before caches!) Long memory latency (cache miss delay in modern architecture) Long FP delays Architecture Small number of FP registers (4 in 360) prevented interesting compiler scheduling of operations Pipelined FP functional units (3 cycles for adder, 2 cycles multiplier, 6cycles load, 3 cycles store) 9/4/2018 29 Historical Perspective (2) When IBM announced the System/360 series of computers in 1964, Fortune magazine called it a $5B gamble possibly the riskiest business judgment of modern times. The name 360 came from the 360 degrees in a circle, because IBM intended to take over the entire world of computing business, science, defense, everything. IBM hired 60 thousand new employees, sank $750M into engineering development, and opened five major new factories at a cost of $4.5B. It was so successful, and their sales had soared to $7B by 1970... The attorney general of the US of Johnson administration in 1969 signed a complaint charging IBM with unlawful monopolization of the computer industry and requested that the federal courts dismember the company. The revolutionary new principle of the System/360 was compatibility, at a single stroke cutting through both the software problem and the breadth-of-market conundrum. Customers would be able to buy a range of computers, from a small $2K/month machine up to an $115K/month behemoth. But all the machines would run on the same software; better yet, IBM could emulate the 1400 (their old machine) software on the 360. (this is due to microprogramming) 9/4/2018 30

16 A Dynamic Algorithm: Tomasulo s The smaller number of FP registers and pipelined FP functional units 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, Pentium 4, AMD Opteron, Power 5, 9/4/2018 31 Tomasulo Organization Register file Forwarding unit Reservation station Adder Adder Adder Mul Mul Common Data Bus Memory 9/4/2018 32

17 Tomasulo Organization From Mem FP Op Queue Load Buffers Load1 Load2 Load3 Load4 Load5 Load6 FP Registers Store Buffers Add1 Add2 Add3 Mult1 Mult2 FP adders Reservation Stations FP multipliers To Mem Common Data Bus (CDB) 9/4/2018 33 Tomasulo Algorithm Control & buffers distributed with Function Units (FU) FU buffers called reservation stations ; have pending operands Registers in instructions replaced by values or pointers to reservation stations (RS); called register renaming ; 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 Avoids RAW hazards by executing an instruction only when its operands are available Load and Stores treated as FUs with RSs as well Integer instructions can go past branches (predict taken), allowing FP ops beyond basic block in FP queue 9/4/2018 34

18 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 => ready Store buffers only have Qi for RS producing result Busy: Indicates reservation station or FU is busy Either Vj or Qj Register result status Indicates which functional unit will write each register, if one exists. Blank when no pending instructions that will write that register. 9/4/2018 35 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 () When both operands ready then execute; if not ready, watch Common Data Bus for result 3. Write result finish execution () Write on Common Data Bus to all awaiting units; mark reservation station available 9/4/2018 36

19 Three Stages of Tomasulo Algorithm 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: 3 clocks for Fl.pt. +,-; 10 for * ; 40 clks for / 9/4/2018 37 Instruction stream Tomasulo Example LD F6 34+ R2 L oad1 No LD F2 45+ R3 L oad2 No M UL TD F0 F2 F4 L oad3 No SUB D F8 F6 F2 D IVD F10 F0 F6 A D D D F6 F8 F2 Tim e N am e B usy Op Vj Vk Qj Qk FU count down A dd1 A dd2 A dd3 M ult1 M ult2 No No No No No 0 FU Clock cycle counter 3 Load/Buffers 3 FP Adder R.S. 2 FP Mult R.S. 9/4/2018 38

20 Tomasulo Example Cycle 1 LD F6 34+ R2 1 L oad1 Yes 34+R2 LD F2 45+ R3 L oad2 No M UL TD F0 F2 F4 L oad3 No SUB D F8 F6 F2 D IVD F10 F0 F6 A D D D F6 F8 F2 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 A dd2 A dd3 M ult1 M ult2 No No No No No 1 FU L oad1 9/4/2018 39 Tomasulo Example Cycle 2 LD F6 34+ R2 1 L oad1 Yes 34+R2 LD F2 45+ R3 2 L oad2 Yes 45+R3 M UL TD F0 F2 F4 L oad3 No SUB D F8 F6 F2 D IVD F10 F0 F6 A D D D F6 F8 F2 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 A dd2 A dd3 M ult1 M ult2 No No No No No 2 FU L oad2 L oad1 Note: Can have multiple loads outstanding 9/4/2018 40

21 Tomasulo Example Cycle 3 LD F6 34+ R2 1 3 L oad1 Yes 34+R2 LD F2 45+ R3 2 L oad2 Yes 45+R3 M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 D IVD F10 F0 F6 A D D D F6 F8 F2 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No M ult1 Yes M ULTD R (F4) L oad2 M ult2 No 3 FU M ult1 L oad2 L oad1 Note: registers names are removed ( renamed ) in Reservation Stations; MULT issued Load1 completing; what is waiting for Load1? 9/4/2018 41 Tomasulo Example Cycle 4 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 L oad2 Yes 45+R3 M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 D IVD F10 F0 F6 A D D D F6 F8 F2 Tim e N am e B usy O p Vj Vk Q j Q k Add1 Yes SUBD M (A1) Load2 A dd2 No M ult1 Yes M ULTD R (F4) L oad2 M ult2 No 4 FU M ult1 L oad2 M (A 1) A dd1 Load2 completing; what is waiting for Load2? 9/4/2018 42

22 Tomasulo Example Cycle 5 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 D IVD F10 F0 F6 5 A D D D F6 F8 F2 Tim e N am e B usy O p Vj Vk Q j Q k 2 Add1 Yes SUBD M (A1) M (A2) A dd2 No 10 M ult1 Yes M ULTD M (A2) R (F4) M ult2 Yes DIVD M (A1) M ult1 5 FU M ult1 M (A 2) M (A 1) A dd1 M ult2 Timer starts down for Add1, Mult1 9/4/2018 43 Tomasulo Example Cycle 6 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 Tim e N am e B usy O p Vj Vk Q j Q k 1 Add1 Yes SUBD M (A1) M (A2) Add2 Yes ADDD M (A2) Add1 9 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 6 FU M ult1 M (A2) Add2 Add1 M ult2 Issue ADDD here despite name dependency on F6? 9/4/2018 44

23 Tomasulo Example Cycle 7 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 7 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 Tim e N am e B usy O p Vj Vk Q j Q k 0 Add1 Yes SUBD M (A1) M (A2) Add2 Yes ADDD M (A2) Add1 8 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 7 FU M ult1 M (A2) Add2 Add1 M ult2 Add1 (SUBD) completing; what is waiting for it? 9/4/2018 45 Tomasulo Example Cycle 8 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No 2 Add2 Yes ADDD (M -M ) M (A2) 7 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 8 FU M ult1 M (A 2) A dd2 (M -M ) M ult2 9/4/2018 46

24 Tomasulo Example Cycle 9 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No 1 Add2 Yes ADDD (M -M ) M (A2) 6 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 9 FU M ult1 M (A 2) A dd2 (M -M ) M ult2 9/4/2018 47 Tomasulo Example Cycle 10 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 10 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No 0 Add2 Yes ADDD (M -M ) M (A2) 5 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 10 FU M ult1 M (A 2) A dd2 (M -M ) M ult2 Add2 (ADDD) completing; what is waiting for it? 9/4/2018 48

25 Tomasulo Example Cycle 11 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No 4 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 11 FU M ult1 M (A 2) (M -M + M (M -M ) M ult2 Write result of ADDD here? All quick instructions complete in this cycle! 9/4/2018 49 Tomasulo Example Cycle 12 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No 3 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 12 FU M ult1 M (A 2) (M -M + M (M -M ) M ult2 9/4/2018 50

26 Tomasulo Example Cycle 13 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No 2 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 13 FU M ult1 M (A 2) (M -M + M (M -M ) M ult2 9/4/2018 51 Tomasulo Example Cycle 14 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No 1 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 14 FU M ult1 M (A 2) (M -M + M (M -M ) M ult2 9/4/2018 52

27 Tomasulo Example Cycle 15 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 15 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No 0 M ult1 Y es M UL TD M (A 2) R (F4) M ult2 Yes DIVD M (A1) M ult1 15 FU M ult1 M (A 2) (M -M + M (M -M ) M ult2 Mult1 (MULTD) completing; what is waiting for it? 9/4/2018 53 Tomasulo Example Cycle 16 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 15 16 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No M ult1 No 40 M ult2 Yes DIVD M *F4 M (A1) 16 FU M *F4 M (A 2) (M -M + M (M -M ) M ult2 Just waiting for Mult2 (DIVD) to complete 9/4/2018 54

28 Skip a couple of cycles 9/4/2018 55 Tomasulo Example Cycle 55 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 15 16 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No M ult1 No 1 M ult2 Y es D IVD M *F4 M (A 1) 55 FU M *F4 M (A 2) (M -M + M (M -M ) M ult2 9/4/2018 56

29 Tomasulo Example Cycle 56 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 15 16 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 56 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No M ult1 No 0 M ult2 Y es D IVD M *F4 M (A 1) 56 FU M *F4 M (A 2) (M -M + M (M -M ) M ult2 Mult2 (DIVD) is completing; what is waiting for it? 9/4/2018 57 Tomasulo Example Cycle 57 LD F6 34+ R2 1 3 4 L oad1 No LD F2 45+ R3 2 4 5 L oad2 No M UL TD F0 F2 F4 3 15 16 L oad3 No SUB D F8 F6 F2 4 7 8 D IVD F10 F0 F6 5 56 57 A D D D F6 F8 F2 6 10 11 Tim e N am e B usy Op Vj Vk Qj Qk A dd1 No A dd2 No M ult1 No M ult2 Yes DIVD M *F4 M (A1) 56 FU M *F4 M (A 2) (M -M + M (M -M ) R esult Once again: In-order issue, out-of-order execution and out-of-order completion. 9/4/2018 58

30 Loop Unrolling with Tomasulo 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 Other perspective: Tomasulo building data flow dependency graph on the fly 9/4/2018 59 Loop Unrolling (review) Loop: L.D F0,0(R1) ;F0=vector element MUL.D F4,F0,F2 ;multiply scalar from F2 S.D F4,0(R1) ;store result DADDUI R1,R1,-8 ;decrement pointer 8B BNEZ R1,Loop ;branch R1!=zero => (2 loops) L.D F0,0(R1) ;F0=vector element MUL.D F4,F0,F2 ;multiply scalar from F2 S.D F4,0(R1) ;store result L.D F0,0(R1) ;F0=vector element MUL.D F4,F0,F2 ;multiply scalar from F2 S.D F4,0(R1) ;store result 9/4/2018 60

31 Loop Unrolling with Tomasulo Instruction status: Exec Write Instruction j k Issue Comp Result Busy Address Vk Qk LD F0 0+ R1 Load1 Yes R1+0 MULTD F4 F0 F2 Load2 Yes R1-8 SD F4 0+ R1 Load3 No LD F0 0+ R1 Store1 Yes R1 Mult1 MULTD F4 F0 F2 Store2 Yes R1-8 Mult2 SD F4 0+ R1 Reservation Stations: S1 S2 RS RS Time Name Busy Op Vj Vk Qj Qk Add1 No Add2 No Add3 No Mult1 Yes MUL F2 Load1 Mult2 Yes MUL F2 Load2 Same F4 Same F0 Register result status: Clock F0 F2 F4 F6 F8 F10 F12... F30??? FU Load2 Mult2 9/4/2018 61 Tomasulo s scheme offers 2 major advantages 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 Elimination of stalls for WAW and WAR hazards 9/4/2018 62

32 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! (Section 2.6) 9/4/2018 63 Conclusions Reservations stations: renaming to larger set of registers + buffering source operands Prevents registers as bottleneck Avoids WAR, WAW hazards Allows loop unrolling in HW Not limited to basic blocks (integer units gets ahead, beyond branches) Helps cache misses as well Lasting Contributions Dynamic scheduling Register renaming Load/store disambiguation 360/91 descendants are Intel Pentium 4, IBM Power 5, AMD Athlon/Opteron, 9/4/2018 64