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

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

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

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

5008: Computer Architecture

Getting CPI under 1: Outline

Handout 2 ILP: Part B

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

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

Hardware-based Speculation

Super Scalar. Kalyan Basu March 21,

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

Four Steps of Speculative Tomasulo cycle 0

Hardware-Based Speculation

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

CISC 662 Graduate Computer Architecture Lecture 13 - CPI < 1

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

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

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

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

Donn Morrison Department of Computer Science. TDT4255 ILP and speculation

CPI < 1? How? What if dynamic branch prediction is wrong? Multiple issue processors: Speculative Tomasulo Processor

Adapted from David Patterson s slides on graduate computer architecture

CPI IPC. 1 - One At Best 1 - One At best. Multiple issue processors: VLIW (Very Long Instruction Word) Speculative Tomasulo Processor

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

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

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

Instruction Level Parallelism

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

Static vs. Dynamic Scheduling

Metodologie di Progettazione Hardware-Software

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

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

Copyright 2012, Elsevier Inc. All rights reserved.

Multi-cycle Instructions in the Pipeline (Floating Point)

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

EITF20: Computer Architecture Part3.2.1: Pipeline - 3

EECC551 - Shaaban. 1 GHz? to???? GHz CPI > (?)

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

The Processor: Instruction-Level Parallelism

EECC551 Exam Review 4 questions out of 6 questions

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

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

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

CS425 Computer Systems Architecture

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

The basic structure of a MIPS floating-point unit

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

Advanced issues in pipelining

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

EEC 581 Computer Architecture. Lec 4 Instruction Level Parallelism

Processor (IV) - advanced ILP. Hwansoo Han

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

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

CISC 662 Graduate Computer Architecture. Lecture 10 - ILP 3

Website for Students VTU NOTES QUESTION PAPERS NEWS RESULTS

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

TDT 4260 lecture 7 spring semester 2015

UG4 Honours project selection: Talk to Vijay or Boris if interested in computer architecture projects

Advanced d Instruction Level Parallelism. Computer Systems Laboratory Sungkyunkwan University

NOW Handout Page 1. COSC 5351 Advanced Computer Architecture

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

Lecture 9: Multiple Issue (Superscalar and VLIW)

Lecture 8 Dynamic Branch Prediction, Superscalar and VLIW. Computer Architectures S

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

Instruction-Level Parallelism and Its Exploitation

DYNAMIC AND SPECULATIVE INSTRUCTION SCHEDULING

Hardware-Based Speculation

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

Computer Science 246 Computer Architecture

COSC4201 Instruction Level Parallelism Dynamic Scheduling

Instruction-Level Parallelism (ILP)

As the amount of ILP to exploit grows, control dependences rapidly become the limiting factor.

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Computer Architecture ECE 568

EE 4683/5683: COMPUTER ARCHITECTURE

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

Several Common Compiler Strategies. Instruction scheduling Loop unrolling Static Branch Prediction Software Pipelining

Instruction Level Parallelism. Appendix C and Chapter 3, HP5e

Processor: Superscalars Dynamic Scheduling

Multiple Instruction Issue and Hardware Based Speculation

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

CS433 Homework 2 (Chapter 3)

TDT 4260 TDT ILP Chap 2, App. C

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

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

CS433 Homework 2 (Chapter 3)

Lecture 5: VLIW, Software Pipelining, and Limits to ILP. Review: Tomasulo

Real Processors. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

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

Instruction Level Parallelism

DYNAMIC INSTRUCTION SCHEDULING WITH SCOREBOARD

Instruction Level Parallelism. Taken from

Hardware-based Speculation

ILP: Instruction Level Parallelism

INSTRUCTION LEVEL PARALLELISM

E0-243: Computer Architecture

Pipelining and Exploiting Instruction-Level Parallelism (ILP)

CS 152 Computer Architecture and Engineering

Chapter 4 The Processor (Part 4)

HY425 Lecture 09: Software to exploit ILP

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

Transcription:

EEC 581 Computer Architecture Lec 7 Instruction Level Parallelism (2.6 Hardware-based Speculation and 2.7 Static Scheduling/VLIW) Chansu Yu Electrical and Computer Engineering Cleveland State University Acknowledgement Part of class notes are from David Patterson Electrical Engineering and Computer Sciences University of California, Berkeley http://www.eecs.berkeley.edu/~pattrsn http://www-inst.eecs.berkeley.edu/~cs252 And, from Mary Jane Irwin Computer Science and Engineering Pennsylvania State University http://www.cse.psu.edu/~mji www.cse.psu.edu/~cg431 9/29/2010 2 1

Overview of Chap. 2 & 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!!! 2.3 Branch prediction (branch history table) 2.4 & 2.5 Multiple issue dependency Dynamic scheduling (forwarding) 2.6 Speculative execution ( commit ) 2.7 Multiple issue dependency 9/29/2010 Static scheduling ( VLIW ) 3 Review of Chap. 2 (so far ) Leverage Implicit Parallelism for Performance: Instruction Level Parallelism Loop unrolling by compiler to increase ILP Branch prediction to increase ILP Dynamic HW exploiting ILP Works when can t know dependence at compile time Can hide L1 cache misses Code for one machine runs well on another Reservations stations: renaming to larger set of registers + buffering source operands» Prevents registers as bottleneck» Avoids WAR, WAW hazards» Allows loop unrolling in HW 360/91 descendants are Pentium 4, Power 5, AMD Athlon/Opteron, 9/29/2010 4 2

Outline ILP (2.1) Compiler techniques to increase ILP (2.1) Loop Unrolling (2.2) Static Branch Prediction (2.3) Dynamic Branch Prediction (2.3) Overcoming Data Hazards with Dynamic Scheduling (2.4) Tomasulo Algorithm (2.5) Speculation, Speculative Tomasulo, Memory Aliases, Exceptions, Register Renaming vs. Reorder Buffer (2.6) VLIW, Increasing instruction bandwidth (2.7) Instruction Delivery (2.9) 9/29/2010 5 Speculation to greater ILP A wide issue processor may execute a branch every cycle => overcoming control dependences is a big burden Dynamic scheduling only fetches and issues those dependent instructions With speculation fetch, issue, and execute those dependent instructions as if branch predictions were always correct Need a mechanism to handle the situation where the speculation is incorrect Additional step: Commit 9/29/2010 6 3

Speculation to greater ILP 3 components of HW-based speculation: 1. Dynamic branch prediction to choose which instructions to execute 2. Speculation to allow execution of instructions before control dependences are resolved + ability to undo effects of incorrectly speculated sequence 3. Dynamic scheduling to deal with scheduling of different combinations of basic blocks 9/29/2010 7 Adding Speculation to Tomasulo Must separate execution from allowing instruction to finish or commit This additional step called instruction commit When an instruction is no longer speculative, allow it to update the register file or memory Requires additional set of buffers to hold results of instructions that have finished execution but have not committed : reorder buffer (ROB) 9/29/2010 8 4

Reorder Buffer (ROB) With speculation, the register file is not updated until the instruction commits Thus, the ROB supplies operands in interval between completion of instruction execution and instruction commit ROB is a source of operands for instructions, just as reservation stations (RS) provide operands in Tomasulo s algorithm ROB extends architectured registers like RS 9/29/2010 9 Tomasulo Organization with Speculation Register file ROB Reservation Station Adder Adder Adder Mul Mul Common Data Bus Memory 9/29/2010 10 5

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/29/2010 11 Reorder Buffer operation Holds instructions in FIFO order, exactly as issued When instructions complete, results placed into ROB Instructions commit values at head of ROB placed in registers As a result, easy to undo speculated instructions on mispredicted branches or on exceptions Commit path FP Op Queue Reorder Buffer FP Regs Res Stations FP Adder Res Stations FP Adder 9/29/2010 12 6

4 Steps of Speculative Tomasulo Algorithm 1. Issue get instruction from FP Op Queue If reservation station and reorder buffer slot free, issue instr & send operands & reorder buffer no. for destination (this stage sometimes called dispatch ) 2. Execution operate on operands (EX) When both operands ready then execute; if not ready, watch CDB for result; when both in reservation station, execute; checks RAW (sometimes called issue ) 3. Write result finish execution (WB) Write on Common Data Bus to all awaiting FUs & reorder buffer; mark reservation station available. 4. Commit update register with reorder result When instr. at head of ROB & result present, update register with result (or store to memory) and remove instr from ROB. Mispredicted branch flushes ROB (also called graduation ) 9/29/2010 13 Reorder Buffer Entry Each entry in the ROB contains four fields: 1. Instruction type a branch (has no destination result), a store (has a memory address destination), or a register operation (ALU operation or load, which has register destinations) 2. Destination Register number (for loads and ALU operations) or memory address (for stores) where the instruction result should be written 3. Value Value of instruction result until the instruction commits 4. Ready Indicates that instruction has completed execution, and the value is ready 9/29/2010 14 7

FP Op Queue Tomasulo With Reorder buffer: Dest 2 ADDD ADDD R(F4),ROB1 6 ADDD ADDD ROB5, ROB5, R(F6) R(F6) FP FP adders adders ROB Speculative execution based on branch prediction (e.g. F0 will not be updated) Registers Reservation Stations -- -- F0 F0 ROB5 ROB5 ST ST 0(R3),F4 ADDD ADDD F0,F4,F6 N N F4 F4 LD LD F4,0(R3) N -- -- BNE BNE F2,< > N F2 F2 F10 F10 F0 F0 DIVD DIVD F2,F10,F6 ADDD ADDD F10,F4,F0 LD LD F0,10(R2) N N N Dest 3 DIVD DIVD ROB2,R(F6) FP FP multipliers multipliers Ready? To Memory from Memory Dest 1 10+R2 10+R2 5 0+R3 0+R3 ROB7 ROB6 ROB5 ROB4 ROB3 ROB2 ROB1 Newest Oldest 9/29/2010 15 Exceptions and Interrupts IBM 360/91 invented imprecise exceptions Imprecise exceptions DIV F0, F2, F4 ADD F10, F10, F8 SUB F12, F12, F14 ADD and SUB can be executed earlier than DIV What if SUB causes an exception (before DIV completes)? Imprecise exceptions The pipeline may have already completed instructions that are later than the offending instruction The pipeline may have not yet completed instructions that are earlier than the offending instruction 9/29/2010 16 8

Exceptions and Interrupts Speculation with in-order commit ensures precise exceptions Exceptions are handled by not recognizing the exception until the offending instruction is ready to commit in ROB If a speculated instruction raises an exception, the exception is recorded in the ROB If we speculate and are wrong, need to back up and restart execution to point at which we predicted incorrectly This is why reorder buffers in all new processors 9/29/2010 17 Outline ILP (2.1) Compiler techniques to increase ILP (2.1) Loop Unrolling (2.2) Static Branch Prediction (2.3) Dynamic Branch Prediction (2.3) Overcoming Data Hazards with Dynamic Scheduling (2.4) Tomasulo Algorithm (2.5) Speculation, Speculative Tomasulo, Memory Aliases, Exceptions, Register Renaming vs. Reorder Buffer (2.6) VLIW, Increasing instruction bandwidth (2.7) Instruction Delivery (2.9) 9/29/2010 18 9

Extracting Yet More Performance: 2 Options Increase the depth of the pipeline to increase the clock rate superpipelining Fetch (and execute) more than one instructions at one time multiple-issue 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 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) 9/29/2010 19 History of VLIW Processors Started with (horizontal) microprogramming Very wide microinstructions used to directly generate control signals in single-issue processors (e.g., IBM 360 series) VLIW for multi-issue processors first appeared in the Multiflow and Cydrome (in the early 1980 s) Current commercial VLIW processors Intel i860 RISC (dual mode: scalar and VLIW) Intel I-64 (EPIC: Itanium and Itanium 2) Transmeta Crusoe Lucent/Motorola StarCore ADI TigerSHARC Infineon (Siemens) Carmel 9/29/2010 20 10

VLIW (Very Long Instruction Word) Processors VLIW processors use the compiler to decide which instructions to issue and execute simultaneously Issue bundle ( packet in IA-64, molecule in Transmeta) the set of instructions that are bundled together and issued in one clock cycle think of it as one large instruction with multiple operations The mix of instructions in the packet (bundle) is usually restricted The compiler does static branch prediction and code scheduling to reduce (control) or eliminate (data) hazards VLIW s have Multiple functional units (like SS processors) Multi-ported register files (again like SS processors) Wide program bus 9/29/2010 21 An Example: A VLIW MIPS Consider a 2-issue MIPS with a 2 instr bundle 64 bits ALU Op (R format) or Brach (I format) Load or Store (I format) add $1, $2, $3 lw $4, 100($5) IF -- -- ID read $2, $3 read $5 EX calculate $2+$3 calculate 100+$5 MEM -- read M[100+$5] WB write $1 write $4 9/29/2010 22 11

An Example: A VLIW MIPS Consider a 2-issue MIPS with a 2 instr bundle 64 bits ALU Op (R format) or Branch (I format) Load or Store (I format) Instructions are always fetched, decoded, and issued in pairs If one instr of the pair can not be used, it is replaced with a noop Need 4 read ports (why?) and 2 write ports (why?) and a separate memory address adder Why isn t Load/Load or Load/Store allowed? Why isn t ALU/ALU allowed? 9/29/2010 23 MIPS (1-issue) Datapath Add Add 4 ALU PC Instruction Memory Sign Extend Register File Write Addr Write Data Data Memory 9/29/2010 24 12

MIPS VLIW (2-issue) Datapath Add Add 4 ALU Instruction Memory Register File PC Write Addr Write Data Add Data Memory Sign Extend Sign Extend 9/29/2010 25 Code Scheduling Example Consider the following loop code lp: L.D $F0,0($R1) # $F0=array element ADD.D $F0,$F0,$F2 # add scalar in $F2 S.D $F0,0($R1) # store result DADDI $R1,$R1,-4 # decrement pointer BNEZ $R1,lp # branch if $R1!= 0 Must schedule the instructions to avoid pipeline stalls Instructions in one bundle must be independent Must separate load use instructions from their loads by one cycle Notice that the first two instructions have a load-use dependency, the next two and last two have data dependencies Assume branches are perfectly predicted by the hardware 9/29/2010 26 13

The Scheduled Code (Not Unrolled) lp: L.D $F0,0($R1) # $F0=array element ADD.D $F0,$F0,$F2 # add scalar in $F2 S.D $F0,0($R1) # store result DADDI $R1,$R1,-4 # decrement pointer BNEZ $R1,lp # branch if $R1!= 0 ALU or branch Data transfer CC lp: 1 2 3 4 9/29/2010 27 The Scheduled Code (Not Unrolled) lp: L.D $F0,0($R1) # $F0=array element ADD.D $F0,$F0,$F2 # add scalar in $F2 S.D $F0,0($R1) # store result DADDI $R1,$R1,-4 # decrement pointer BNEZ $R1,lp # branch if $R1!= 0 ALU or branch Data transfer CC lp: L.D $F0,0($R1) 1 2 3 4 9/29/2010 28 14

The Scheduled Code (Not Unrolled) lp: L.D $F0,0($R1) # $F0=array element ADD.D $F0,$F0,$F2 # add scalar in $F2 S.D $F0,0($R1) # store result DADDI $R1,$R1,-4 # decrement pointer BNEZ $R1,lp # branch if $R1!= 0 ALU or branch Data transfer CC lp: ADD.D $F0,$F0,$F2 L.D $F0,0($R1) 1 2 3 4 9/29/2010 29 The Scheduled Code (Not Unrolled) lp: L.D $F0,0($R1) # $F0=array element ADD.D $F0,$F0,$F2 # add scalar in $F2 S.D $F0,0($R1) # store result DADDI $R1,$R1,-4 # decrement pointer BNEZ $R1,lp # branch if $R1!= 0 ALU or branch Data transfer CC lp: ADD.D $F0,$F0,$F2 L.D S.D $F0,0($R1) $F0,0($R1) 1 2 3 4 9/29/2010 30 15

The Scheduled Code (Not Unrolled) lp: L.D $F0,0($R1) # $F0=array element ADD.D $F0,$F0,$F2 # add scalar in $F2 S.D $F0,0($R1) # store result DADDI $R1,$R1,-4 # decrement pointer BNEZ $R1,lp # branch if $R1!= 0 ALU or branch Data transfer CC lp: DADDI ADD.D $R1,$R1,-4 $F0,$F0,$F2 L.D S.D $F0,0($R1) $F0,4($R1) 1 2 3 4 9/29/2010 31 The Scheduled Code (Not Unrolled) lp: L.D $F0,0($R1) # $F0=array element ADD.D $F0,$F0,$F2 # add scalar in $F2 S.D $F0,0($R1) # store result DADDI $R1,$R1,-4 # decrement pointer BNEZ $R1,lp # branch if $R1!= 0 ALU or branch Data transfer CC lp: DADDI $R1,$R1,-4 ADD.D $F0,$F0,$F2 BNEZ $R1, lp L.D S.D $F0,0($R1) $F0,4($R1) 1 2 3 4 9/29/2010 32 16

The Scheduled Code (Not Unrolled) ALU or branch Data transfer CC lp: L.D $F0,0($R1) 1 DADDI $R1,$R1,-4 2 ADD.D $F0,$F0,$F2 3 BNEZ $R1,lp S.D $F0,4($R1) 4 Four clock cycles to execute 5 instructions for a CPI of 0.8 (versus the best case of 0.5) IPC of 1.25 (versus the best case of 2.0) 9/29/2010 33 Loop Unrolling Loop unrolling multiple copies of the loop body are made and instructions from different iterations are scheduled together as a way to increase ILP Apply loop unrolling (4 times for our example) and then schedule the resulting code Eliminate unnecessary loop overhead instructions Schedule so as to avoid load use hazards During unrolling the compiler applies register renaming to eliminate all data dependencies that are not true dependencies 9/29/2010 34 17

Unrolled Code Example lp: L.D $F0,0($R1) # $F0=array element L.D $F1,-4($R1) # $F1=array element L.D $F2,-8($R1) # $F2=array element L.D $F3,-12($R1) # $F3=array element ADD.D $F0,$F0,$F2 # add scalar in $F2 ADD.D $F1,$F1,$F2 # add scalar in $F2 ADD.D $F3,$F3,$F2 # add scalar in $F2 ADD.D $F4,$F4,$F2 # add scalar in $F2 S.D $F0,0($R1) # store result S.D $F1,-4($R1) # store result S.D $F3,-8($R1) # store result S.D $F4,-12($R1) # store result DADDI $R1,$R1,-16 # decrement pointer BNEZ $R1,lp # branch if $R1!= 0 9/29/2010 35 The Scheduled Code (Unrolled) ALU or branch Data transfer lp: DADDI $R1,$R1,-16 L.D $F0,0($R1) L.D $F1,12($R1) ADD.D $F0,$F0,$F2 L.D $F3,8($R1) ADD.D $F1,$F1,$F2 L.D $F4,4($R1) ADD.D $F3,$F3,$F2 S.D $F0,16($R1) ADD.D $F4,$F4,$F2 S.D $F1,12($R1) S.D $F3,8($R1) BNEZ $R1, lp S.D $F4,4($R1) CC 1 2 3 4 5 6 7 8 Eight clock cycles to execute 14 instructions for a CPI of 0.57 (versus the best case of 0.5) IPC of 1.8 (versus the best case of 2.0) 9/29/2010 36 18

The Scheduled Code (Unrolled) Consider a 5-issue MIPS with 2 memory, 2 FP and one integer Memory Memory FP FP Int. op/ Clock reference 1 reference 2 operation 1 op. 2 branch L.D F0,0(R1) L.D F6,-8(R1) 1 L.D F10,-16(R1) L.D F14,-24(R1) 2 L.D F18,-32(R1) L.D F22,-40(R1) ADD.D F4,F0,F2 ADD.D F8,F6,F2 3 L.D F26,-48(R1) ADD.D F12,F10,F2 ADD.D F16,F14,F2 4 ADD.D F20,F18,F2 ADD.D F24,F22,F2 5 S.D 0(R1),F4 S.D -8(R1),F8 ADD.D F28,F26,F2 6 S.D -16(R1),F12 S.D -24(R1),F16 7 S.D -32(R1),F20 S.D -40(R1),F24 DSUBUI R1,R1,#48 8 S.D -0(R1),F28 BNEZ R1,LOOP 9 Unrolled 7 times to avoid delays CPI of 0.39, IPC of 2.55 Note: Need more registers in VLIW (15 vs. 6 in SS) 9/29/2010 37 Speculation & Predication Speculation is used to allow execution of future instructions that (may) depend on the speculated instruction Speculate based on branch prediction Results are stored in temporary store (reorder buffer) Commit if the speculation is correct Predication can be used to eliminate branches by making the execution of an instruction dependent on a predicate, e.g., if (p) {statement 1} else {statement 2} would normally compile using two branches. With predication it would compile as (p) statement 1 (~p) statement 2 The use of (condition) indicates that the instruction is committed only if condition is true 9/29/2010 38 19

Compiler Support for VLIW Processors The compiler packs groups of independent instructions into the bundle The compiler uses loop unrolling to expose more ILP The compiler uses register renaming to solve name dependencies and ensures no load use hazards occur While superscalars use dynamic prediction, VLIW s primarily depend on the compiler for branch prediction Loop unrolling reduces the number of conditional branches Predication eliminates if-then-else branch structures by replacing them with predicated instructions The compiler predicts memory bank references to help minimize memory bank conflicts 9/29/2010 39 VLIW Advantages & Disadvantages Advantages Simpler hardware (potentially less power hungry) Potentially more scalable Disadvantages Increase in code size» generating enough operations in a straight-line code fragment requires ambitiously unrolling loops» whenever VLIW instructions are not full, unused functional units translate to wasted bits in instruction encoding Operated in lock-step; no hazard detection HW» a stall in any functional unit pipeline caused entire processor to stall, since all functional units must be kept synchronized» Compiler might prediction function units, but caches hard to predict Binary code compatibility» Pure VLIW => different numbers of functional units and unit latencies require different versions of the code 9/29/2010 40 20

Intel/HP IA-64 Explicitly Parallel Instruction Computer (EPIC) IA-64: instruction set architecture 128 64-bit integer regs + 128 82-bit floating point regs Hardware checks dependencies Predicated execution (select 1 out of 64 1-bit flags) Itanium was first implementation (2001) Highly parallel and deeply pipelined hardware at 800Mhz 6-wide, 10-stage pipeline at 800Mhz on 0.18 µ process Itanium 2 was 2nd implementation (2005) 6-wide, 8-stage pipeline at 1666Mhz on 0.13 µ process Caches: 32 KB I, 32 KB D, 128 KB L2I, 128 KB L2D, 9216 KB L3 9/29/2010 41 Outline ILP (2.1) Compiler techniques to increase ILP (2.1) Loop Unrolling (2.2) Static Branch Prediction (2.3) Dynamic Branch Prediction (2.3) Overcoming Data Hazards with Dynamic Scheduling (2.4) Tomasulo Algorithm (2.5) Speculation, Speculative Tomasulo, Memory Aliases, Exceptions, Register Renaming vs. Reorder Buffer (2.6) VLIW, Increasing instruction bandwidth (2.7) Instruction Delivery (2.9) 9/29/2010 42 21

Increasing Instruction Fetch Bandwidth Predicts next instruct address, sends it out before decoding instructuction PC of branch sent to BTB When match is found, Predicted PC is returned If branch predicted taken, instruction fetch continues at Predicted PC Branch Target Buffer (BTB) 9/29/2010 43 Return Address Predictor (Indirect Branch) Small buffer of return addresses acts as a stack Caches most recent return addresses 70% y c60% n e u q50% f r e 40% n io t 30% Call Push a ic d return address r e20% p is on stack 10% M 0% Return Pop an address off stack & predict as new PC 0 1 2 4 8 16 Return address buffer entries go m88ksim cc1 compress xlisp ijpeg perl vortex 9/29/2010 44 22

More Instruction Fetch Bandwidth Integrated branch prediction branch predictor is part of instruction fetch unit and is constantly predicting branches Instruction prefetch Instruction fetch units prefetch to deliver multiple instructions per clock, integrating it with branch prediction Instruction memory access and buffering Fetching multiple instructions per cycle: May require accessing multiple cache blocks (prefetch to hide cost of crossing cache blocks) Provides buffering, acting as on-demand unit to provide instructions to issue stage as needed and in quantity needed 9/29/2010 45 Speculation: Register Renaming vs. ROB Alternative to ROB is a larger physical set of registers combined with register renaming Extended registers replace function of both ROB and reservation stations Instruction issue maps names of architectural registers to physical register numbers in extended register set On issue, allocates a new unused register for the destination (which avoids WAW and WAR hazards) Speculation recovery easy because a physical register holding an instruction destination does not become the architectural register until the instruction commits Most Out-of-Order processors today use extended registers with renaming 9/29/2010 46 23

Value Prediction Attempts to predict value produced by instruction E.g., Loads a value that changes infrequently Value prediction is useful only if it significantly increases ILP Focus of research has been on loads; so-so results, no processor uses value prediction Related topic is address aliasing prediction RAW for load and store or WAW for 2 stores Address alias prediction is both more stable and simpler since need not actually predict the address values, only whether such values conflict Has been used by a few processors 9/29/2010 47 (Mis) Speculation on Pentium 4 % of micro-ops not used 45% 40% 35% 30% 25% 20% 15% 10% 5% 0% 43% 39% 24% Integer 45% 24% 3% 1% 1% 0% 20% Floating Point 9/29/2010 48 24

Perspective Interest in multiple-issue because wanted to improve performance without affecting uniprocessor programming model Taking advantage of ILP is conceptually simple, but design problems are amazingly complex in practice Conservative in ideas, just faster clock and bigger Processors of last 5 years (Pentium 4, IBM Power 5, AMD Opteron) have the same basic structure and similar sustained issue rates (3 to 4 instructions per clock) as the 1st dynamically scheduled, multipleissue processors announced in 1995 Clocks 10 to 20X faster, caches 4 to 8X bigger, 2 to 4X as many renaming registers, and 2X as many load-store units performance 8 to 16X Peak v. delivered performance gap increasing 9/29/2010 49 25