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

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

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

EECC551 Exam Review 4 questions out of 6 questions

CISC 662 Graduate Computer Architecture Lecture 13 - CPI < 1

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

Hardware-based Speculation

CS425 Computer Systems Architecture

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

Four Steps of Speculative Tomasulo cycle 0

5008: Computer Architecture

Advanced issues in pipelining

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

Super Scalar. Kalyan Basu March 21,

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

Handout 2 ILP: Part B

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

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

Multi-cycle Instructions in the Pipeline (Floating Point)

Pipelining and Exploiting Instruction-Level Parallelism (ILP)

Lecture 9: Multiple Issue (Superscalar and VLIW)

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

Getting CPI under 1: Outline

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

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

Processor (IV) - advanced ILP. Hwansoo Han

Hardware-Based Speculation

EITF20: Computer Architecture Part3.2.1: Pipeline - 3

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

INSTRUCTION LEVEL PARALLELISM

TDT 4260 lecture 7 spring semester 2015

Metodologie di Progettazione Hardware-Software

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

Hardware-Based Speculation

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

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

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

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

Instruction-Level Parallelism and Its Exploitation

Advanced d Instruction Level Parallelism. Computer Systems Laboratory Sungkyunkwan University

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

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

Static vs. Dynamic Scheduling

EECC551 Review. Dynamic Hardware-Based Speculation

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

Donn Morrison Department of Computer Science. TDT4255 ILP and speculation

Multiple Issue ILP Processors. Summary of discussions

Instruction Level Parallelism

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

The Processor: Instruction-Level Parallelism

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

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

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

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

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

Exploitation of instruction level parallelism

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

The basic structure of a MIPS floating-point unit

Copyright 2012, Elsevier Inc. All rights reserved.

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

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

Minimizing Data hazard Stalls by Forwarding Data Hazard Classification Data Hazards Present in Current MIPS Pipeline

Processor: Superscalars Dynamic Scheduling

COMPUTER ORGANIZATION AND DESI

Instruction Level Parallelism. Appendix C and Chapter 3, HP5e

Multiple Instruction Issue. Superscalars

Website for Students VTU NOTES QUESTION PAPERS NEWS RESULTS

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

Course on Advanced Computer Architectures

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

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

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

ILP: Instruction Level Parallelism

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

Hardware-based Speculation

COSC 6385 Computer Architecture - Instruction Level Parallelism (II)

CISC 662 Graduate Computer Architecture. Lecture 10 - ILP 3

Advanced Instruction-Level Parallelism

COSC4201 Instruction Level Parallelism Dynamic Scheduling

Adapted from David Patterson s slides on graduate computer architecture

Simultaneous Multithreading (SMT)

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

E0-243: Computer Architecture

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

Simultaneous Multithreading (SMT)

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

ENGN1640: Design of Computing Systems Topic 06: Advanced Processor Design

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

計算機結構 Chapter 4 Exploiting Instruction-Level Parallelism with Software Approaches

TDT 4260 TDT ILP Chap 2, App. C

IF1/IF2. Dout2[31:0] Data Memory. Addr[31:0] Din[31:0] Zero. Res ALU << 2. CPU Registers. extension. sign. W_add[4:0] Din[31:0] Dout[31:0] PC+4

Instruction Pipelining Review

Static Compiler Optimization Techniques

Lecture: Static ILP. Topics: compiler scheduling, loop unrolling, software pipelining (Sections C.5, 3.2)

Lecture 9: More ILP. Today: limits of ILP, case studies, boosting ILP (Sections )

CS 2410 Mid term (fall 2015) Indicate which of the following statements is true and which is false.

EE 4683/5683: COMPUTER ARCHITECTURE

Complex Pipelining COE 501. Computer Architecture Prof. Muhamed Mudawar

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

Review Tomasulo. Lecture 17: ILP and Dynamic Execution #2: Branch Prediction, Multiple Issue. Tomasulo Algorithm and Branch Prediction

Dynamic Scheduling. CSE471 Susan Eggers 1

Transcription:

Evolution of Processor Performance So far we examined static & dynamic techniques to improve the performance of single-issue (scalar) pipelined CPU designs including: static & dynamic scheduling, static & dynamic branch predication. Even with these improvements, the restriction of issuing a single instruction per cycle still limits the ideal CPI = 1 Multi-cycle Pipelined (single issue) Multiple Issue (CPI <1) Superscalar/VLIW/SMT 1 GHz? to???? GHz Original (2002) Intel Predictions 15 GHz IPC CPI > 10 1.1-10 0.5-1.1.35 -.5 (?) Source: John P. Chen, Intel Labs (Chapter 3.6, 3.7, 4.3, 4.5) Single-issue Processor = Scalar Processor Instructions Per Cycle (IPC) = 1/CPI We next examine the two approaches to achieve a CPI < 1 by issuing multiple instructions per cycle: Superscalar CPUs Very Long Instruction Word (VLIW) CPUs. #1 lec # 6 Fall 2005 10-4-2005

Parallelism in Microprocessor VLSI Generations Transistors 100,000,000 10,000,000 1,000,000 100,000 10,000 u ui4004 Bit-level parallelism Instruction-level Thread-level (?) Multiple micro-operations per cycle (multi-cycle non-pipelined) Not Pipelined CPI >> 1 u i8080 ui8008 i80286 u u u i8086 u u u i80386 u uu u u R10000 uu uuu u u uuuu u uu uu u u u uu Pentium u u (ILP) Single-issue Pipelined CPI =1 u R2000 u u u R3000 Superscalar /VLIW CPI <1 Instruction Level Parallelism (ILP) Pipelining single issue Multiple Instruction Issue Simultaneous Multithreading SMT: e.g. Intel s Hyper-threading 1,000 1970 1975 1980 1985 1990 1995 2000 2005 (TLP) Chip-Multiprocessors (CMPs) e.g IBM Power 4, 5 AMD Athlon64 X2 Intel Pentium D Thread Level Parallelism (TLP) Superscalar Processors Very Long Instruction Word (VLIW) ISA/Processors CPI < 1 #2 lec # 6 Fall 2005 10-4-2005

Multiple Instruction Issue: CPI < 1 To improve a pipeline s CPI to be better [less] than one, and to better exploit Instruction Level Parallelism (ILP), a number of instructions have to be issued in the same cycle. Multiple instruction issue processors are of two types: Superscalar: A number of instructions (2-8) is issued in the same cycle, scheduled statically by the compiler or -more commonlydynamically (Tomasulo). PowerPC, Sun UltraSparc, Alpha, HP 8000, Intel PII, III, 4... VLIW (Very Long Instruction Word): A fixed number of instructions (3-6) are formatted as one long instruction word or packet (statically scheduled by the compiler). Example: Explicitly Parallel Instruction Computer (EPIC) Originally a joint HP/Intel effort. ISA: Intel Architecture-64 (IA-64) 64-bit address: First CPU: Itanium, Q1 2001. Itanium 2 (2003) Limitations of the approaches: Available ILP in the program (both). Specific hardware implementation difficulties (superscalar). VLIW optimal compiler design issues. CPI < 1 or Instructions Per Cycle (IPC) > 1 Most common = 4 instructions/cycle called 4-way superscalar processor Chapter 3.6, 3.7, 4.3, 4.5 #3 lec # 6 Fall 2005 10-4-2005

Multiple Instruction Issue: Superscalar Usually dynamically scheduled (Tomasulo) Complex scheduling hardware. Smaller code size. Fewer registers No template field Binary compatibility across generations of hardware. Vs. VLIW Statically scheduled. Complex compiler design. Simplified Hardware for decoding, issuing instructions. Usually no Interlock Hardware (compiler checks?) More ISA registers (no register renaming), but simplified hardware for register ports. #4 lec # 6 Fall 2005 10-4-2005

Simple Statically Scheduled Superscalar Pipeline Two instructions can be issued per cycle (static two-issue or 2-way superscalar). One of the instructions is integer (including load/store, branch). The other instruction is a floating-point operation. This restriction reduces the complexity of hazard checking. Hardware must fetch and decode two instructions per cycle. Then it determines whether zero (a stall), one or two instructions can be issued (in decode stage) per cycle. Instruction Type Integer Instruction FP Instruction Integer Instruction FP Instruction Integer Instruction FP Instruction Integer Instruction FP Instruction 1 2 3 4 5 6 7 8 IF IF ID ID IF IF EX EX ID ID IF IF MEM EX EX EX ID ID IF IF Two-issue statically scheduled pipeline in operation FP instructions assumed to be adds (EX takes 3 cycles) (Ch. 3.6) Ideal CPI = 0.5 Ideal Instructions Per Cycle (IPC) = 2 WB EX MEM EX EX EX ID ID WB WB EX MEM EX EX EX WB WB EX MEM EX WB WB EX Instructions assumed independent (no stalls) #5 lec # 6 Fall 2005 10-4-2005

Intel IA-64: VLIW Explicitly Parallel Instruction Computing (EPIC) Three 41-bit instructions in 128 bit Groups or bundles; an instruction bundle template field (5-bits) determines if instructions are dependent or independent and statically specifies the functional units to used by the instructions: Smaller code size than old VLIW, larger than x86/risc Groups can be linked to show dependencies of more than three instructions. 128 integer registers + 128 floating point registers Hardware checks dependencies (interlocks binary compatibility over time) Predicated execution: An implementation of conditional instructions used to reduce the number of conditional branches used in the generated code larger basic block size IA-64 : Name given to instruction set architecture (ISA). Itanium : Name of the first implementation (2001). In VLIW dependency analysis is done statically by the compiler not dynamically in hardware (Tomasulo) #6 lec # 6 Fall 2005 10-4-2005

Intel/HP EPIC VLIW Approach original source code Sequential Code Dependency Graph compiler Instruction Dependency Analysis Expose Instruction Parallelism (dependency analysis) Optimize Exploit Instruction Parallelism: Generate VLIWs 128-bit bundle 127 Instruction 2 Instruction 1 Instruction 0 Template 41 bits 41 bits 41 bits 5 bits Template field has static assignment/scheduling information #7 lec # 6 Fall 2005 10-4-2005 0

IA-64 Instruction Types Instruction Type Description Execution Unit Type A I Integer ALU Non-integer ALU I-unit or M-unit I-unit M F B L+X Memory Floating Point Branch Extended M-unit F-unit B-unit I-unit/B-unit Information on static assignment of instructions to functional units and instruction typed in a bundle contained in the template field #8 lec # 6 Fall 2005 10-4-2005

IA-64 Template Use The template specifies the functional units for the three operations (instructions) in the instruction bundle. Part of static scheduling Possible instruction combinations: M-unit, I-unit, I-unit M-unit, L-unit, X-unit M-unit, M-unit, I-unit M-unit, F-unit, I-unit M-unit, M-unit, F-unit M-unit, I-unit, B-unit M-unit, B-unit, B-unit B-unit, B-unit, B-unit M-unit, M-unit, B-unit M-unit, F-unit, B-unit #9 lec # 6 Fall 2005 10-4-2005

IA-64 Instruction Format Example: Type A (Integer ALU) Instruction Format Register-register format: 40 37 36 35 34 33 32 29 28 27 26 20 19 13 12 6 5 0 8 X2a Ve X4 X2b R3 R2 R1 qp 4 1 2 1 4 2 7 7 7 6 8 is the major opcode for this instruction type. X2a, X2b, Ve, and X4 are opcode extensions. qp is the predicate register (or predication flag) assigned to this operation (64 such flags) Predication: Any instruction can be cancelled (turned into a no-op) based on the value of one of 64 predication flags (qp) #10 lec # 6 Fall 2005 10-4-2005

IA-64 Instruction Format Example: 64 Instruction Format Example: Type A (Integer ALU) Instruction Format 14-bit Immediate format: 40 37 36 35 34 33 32 27 26 20 19 13 12 6 5 0 8 s X2a Ve imm6d R3 imm7b R1 qp 4 1 2 1 6 7 7 7 6 X2a and Ve are opcode extensions. qp is the predicate register assigned to this operation. The immediate value is made up of s, imm6d, and imm7b. Other formats available for 8-bit and 22-bit immediates. #11 lec # 6 Fall 2005 10-4-2005

IA-64 Instruction Format Example: 64 Instruction Format Example: Type M (Memory) Instruction Format Integer Load/Store operations: 40 37 36 35 30 29 28 27 26 20 19 13 12 6 5 0 4 m X6 hint x R3 R1 qp 4 1 2 2 1 7 7 7 6 m and x determine the subset of load/store operations. Bits 35:32 give special directives for LAT, cache, etc. Bits 31:30 tell the size of the load (1, 2, 4, or 8 bytes). Hint allows for system pre-fetching of data by specifying if temporal locality exists for this data. #12 lec # 6 Fall 2005 10-4-2005

IA-64 Instruction Format Example: Type B (Branch) Instruction Format IP-relative branch: IP = Instruction Pointer (e.g. PC) 40 37 36 35 34 33 26 20 12 11 9 8 6 5 0 opcode s d wh imm20b p btype qp 4 1 1 2 20 1 3 3 6 Opcode 0- indirect branch, 1- indirect call, 4- IP-relative branch, 5- IP-relative call btype sub-category of branch type, qp- branch condition d- cache de-allocation, { 0 0 0 1 Not Taken wh- branch hint (static branch prediction), 1 0 Taken s & imm20b give offset 1 1 p pre-fetch 0-few, or 1-many instructions following the target #13 lec # 6 Fall 2005 10-4-2005

Unrolled Loop Example for Scalar (single-issue) issue) Pipeline 1 Loop: L.D F0,0(R1) 2 L.D F6,-8(R1) 3 L.D F10,-16(R1) 4 L.D F14,-24(R1) 5 ADD.D F4,F0,F2 6 ADD.D F8,F6,F2 7 ADD.D F12,F10,F2 8 ADD.D F16,F14,F2 9 S.D F4,0(R1) 10 S.D F8,-8(R1) 11 DADDUI R1,R1,#-32 12 S.D F12,16(R1) 13 BNE R1,R2,LOOP 14 S.D F16,8(R1) ; 8-32 = -24 14 clock cycles, or 3.5 per original iteration (result) (unrolled four times) No stalls in code above: CPI = 1 (ignoring initial pipeline fill cycles) Latency: L.D to ADD.D: 1 Cycle ADD.D to S.D: 2 Cycles Unrolled and scheduled loop from loop unrolling example in lecture # 3 (slide 10) #14 lec # 6 Fall 2005 10-4-2005

Loop Unrolling in 2-way 2 Superscalar Pipeline: (1 Integer, 1 FP/Cycle) Integer instruction FP instruction Clock cycle Loop: L.D F0,0(R1) Empty or wasted 1 L.D F6,-8(R1) issue slot 2 L.D F10,-16(R1) ADD.D F4,F0,F2 3 L.D F14,-24(R1) ADD.D F8,F6,F2 4 L.D F18,-32(R1) ADD.D F12,F10,F2 5 S.D F4,0(R1) ADD.D F16,F14,F2 6 S.D F8,-8(R1) ADD.D F20,F18,F2 7 S.D F12,-16(R1) 8 DADDUI R1,R1,#-40 9 S.D F16,-24(R1) 10 BNE R1,R2,LOOP 11 SD -32(R1),F20 12 Unrolled 5 times to avoid delays and expose more ILP (unrolled one more time) 12 cycles, or 12/5 = 2.4 cycles per iteration (3.5/2.4= 1.5X faster than scalar) CPI = 12/ 17 =.7 worse than ideal CPI =.5 because 7 issue slots are wasted Recall that loop unrolling exposes more ILP by increasing basic block size #15 lec # 6 Fall 2005 10-4-2005

Loop Unrolling in VLIW Pipeline (2 Memory, 2 FP, 1 Integer / Cycle) 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) Empty or wasted 1 L.D F10,-16(R1) L.D F14,-24(R1) issue slot 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 F4,0(R1) S.D F8, -8(R1) ADD.D F28,F26,F2 6 S.D F12, -16(R1) S.D F16,-24(R1) DADDUI R1,R1,#-56 7 S.D F20, 24(R1) S.D F24,16(R1) 8 S.D F28, 8(R1) BNE R1,R2,LOOP 9 Unrolled 7 times to avoid delays and expose more ILP 7 results in 9 cycles, or 1.3 cycles per iteration (2.4/1.3 =1.8X faster than 2-issue superscalar, 3.5/1.3 = 2.7X faster than scalar) Average: about 23/9 = 2.55 IPC (instructions per clock cycle) Ideal IPC =5, CPI =.39 Ideal CPI =.2 thus about 50% efficiency, 22 issue slots are wasted Note: Needs more registers in VLIW (15 vs. 6 in Superscalar) (In chapter 4.3 pages 317-318) #16 lec # 6 Fall 2005 10-4-2005

Superscalar Dynamic Scheduling The Tomasulo dynamic scheduling algorithm is extended to issue more than one instruction per cycle. However the restriction that instructions must issue in program order still holds to avoid violating instruction dependencies (construct correct dependency graph dynamically). The result of issuing multiple instructions in one cycle should be the same as if they were singleissued, one instruction per cycle. How to issue two instructions and keep in-order instruction issue for Tomasulo? Simplest Method: Restrict Type of Instructions Issued Per Cycle To simplify the issue logic, issue one one integer + one floating-point instruction per cycle (for a 2-way superscalar). 1 Tomasulo control for integer, 1 for floating point. FP loads/stores might cause a dependency between integer and FP issue: Replace load reservation stations with a load queue; operands must be read in the order they are fetched (program order). Replace store reservation stations with a store queue; operands must be written in the order they are fetched. Load checks addresses in Store Queue to avoid RAW violation (get load value from store queue if memory address matches) Store checks addresses in Load Queue to avoid WAR, and checks Store Queue to avoid WAW. (the above load/store queue checking is also applicable to single-issue Tomasulo to take care of memory RAW, WAR, WAW). More on this next.. #17 lec # 6 Fall 2005 10-4-2005

Data Memory Dependency Checking/Handling In Dynamically Scheduled Processors Renaming in Tomasolu-based dynamically scheduled processors eliminates name dependence for register access but not for data memory access Thus both true data dependencies and name dependencies must be detected to ensure correct ordering of data memory accesses for correct execution. One possible solution: For Loads: Check store queue/buffers to ensure no data dependence violation (RAW hazard) For Stores: Check store queue/buffers to ensure no output name dependence violation (WAW hazard) Check load queue/buffers to ensure no anti-dependence violation (WAR hazard) Store Queue/ Buffers From CPU.. Check Store Queue for possible output dependence (WAW hazard) In case of address match ensure this store will occur last For Store Instructions Load Queue/ Buffers Check Store Queue for possible anti-dependence (WAR hazard) In case of an address match delay the current store until all pending loads are completed To CPU.. To Data Memory Check Store Queue for possible true data dependence (RAW hazard) In case of an address match get the value of the that store For Load Instructions (Related discussion in textbook page 195) Note: Since instructions issue in program order, all pending load/store instructions in load/store queues are before the current load/store instruction in program order. From Data Memory #18 lec # 6 Fall 2005 10-4-2005

Superscalar Dynamic Scheduling Three techniques can be used to support multiple instruction issue in Tomasulo without putting restrictions on the type of instructions issued per cycle: 1 Issue at a higher clock rate so that issue remains in order. For example for a 2-Issue supercalar issue at 2X Clock Rate. Issue First Instruction Issue Second Instruction One Cycle 2 Widen the issue logic to handle multiple instruction issue All possible dependencies between instructions to be issues are detected at once and the result of the multiple issue matches in-order issue Check Instruction Dependencies One Cycle Issue Both Instructions 2-Issue superscalar 0, 1 or 2 instructions issued per cycle for either method For correct dynamic construction of dependency graph: The result of issuing multiple instructions in one cycle should be the same as if they were single-issued, one instruction per cycle. #19 lec # 6 Fall 2005 10-4-2005

Superscalar Dynamic Scheduling 3 To avoid increasing the CPU clock cycle time in the last two approaches, multiple instruction issue can be spilt into two pipelined issue stages: Issue Stage One: Decide how many instructions can issue simultaneously checking dependencies within the group of instructions to be issued + available RSs, ignoring instructions already issued. Issue Stage Two: Examine dependencies among the selected instructions from the group and the those already issued. This approach is usually used in dynamically-scheduled wide superscalars that can issue four or more instructions per cycle. Splitting the issue into two pipelined staged increases the CPU pipeline depth and increases branch penalties This increases the importance of accurate dynamic branch prediction methods. Further pipelining of issue stages beyond two stages may be necessary as CPU clock rates are increased. The dynamic scheduling/issue control logic for superscalars is generally very complex growing at least quadratically with issue width. e.g 4 wide superscalar -> 4x4 = 16 times complexity of single issue CPU #20 lec # 6 Fall 2005 10-4-2005

Assumptions: Multiple Instruction Issue with Dynamic Scheduling Example Restricted 2-way superscalar: 1 integer, 1 FP Issue Per Cycle A sufficient number of reservation stations is available. Total two integer units available: One integer unit (for ALU, effective address) One integer unit for branch condition 2 CDBs Execution cycles: Integer: 1 cycle Load: 2 cycles (1 ex + 1 mem) FP add: 3 cycles Any instruction following a branch cannot start execution until after branch condition is evaluated in EX (resolved) Branches are single issued, no delayed branch, perfect branch prediction Example on page 221 #21 lec # 6 Fall 2005 10-4-2005

Multiple Instruction Issue with Dynamic Scheduling Example #22 lec # 6 Fall 2005 10-4-2005

Three Loop Iterations on Restricted 2-way Superscalar Tomasulo (Start) Only one CDB is actually needed in this case. FP ADD has 3 execution cycles Branches single issue #23 lec # 6 Fall 2005 10-4-2005

Resource Usage Table for Example: Only one CDB is actually needed in this case. #24 lec # 6 Fall 2005 10-4-2005

Multiple Instruction Issue with Dynamic Scheduling Example Assumptions: The same loop in previous example On restricted 2-way superscalar: 1 integer, 1 FP Issue Per Cycle A sufficient number of reservation stations is available. Total three integer units one for ALU, one for effective address One integer unit for branch condition 2 CDBs Execution cycles: Integer: 1 cycle Load: 2 cycles (1 ex + 1 mem) FP add: 3 cycles Any instruction following a branch cannot start execution until after branch condition is evaluated Branches are single issued, no delayed branch, perfect branch prediction Example on page 223 Previous example repeated with one more integer ALU (3 total) #25 lec # 6 Fall 2005 10-4-2005

Same three loop Iterations on Restricted 2-way Superscalar Tomasulo but with Three integer units (one for ALU, one for effective address calculation, one for branch condition) (Start) (page 224) For instructions after a branch: Execution starts after branch is resolved #26 lec # 6 Fall 2005 10-4-2005

Resource Usage Table for Example: (page 225) #27 lec # 6 Fall 2005 10-4-2005

Multiple Instruction Issue Challenges While a two-issue single Integer/FP split is simple in hardware, we get a CPI of 0.5 only for programs with: Exactly 50% FP operations No hazards of any type. If more instructions issue at the same time, greater difficulty of decode and issue operations arise: Even for a 2-issue superscalar machine, we have to examine 2 opcodes, 6 register specifiers, and decide if 0, 1 or 2 instructions can issue. VLIW: tradeoff instruction space for simple decoding The long instruction word has room for many operations. By definition, all the operations the compiler puts in the long instruction word are independent => execute in parallel E.g. 2 integer operations, 2 FP ops, 2 Memory refs, 1 branch 16 to 24 bits per field => 7*16 or 112 bits to 7*24 or 168 bits wide Need compiling/hardware techniques that schedule before branches are resolved (speculation). #28 lec # 6 Fall 2005 10-4-2005

Limits to Multiple Instruction Issue Machines Inherent limitations of ILP: If 1 branch exist for every 5 instruction : How to keep a 5-way superscalar/vliw processor busy? Latencies of unit adds complexity to the many operations that must be scheduled every cycle. For maximum performance multiple instruction issue requires about: Pipeline Depth x No. Functional Units active instructions at any given cycle. Hardware implementation complexities: Duplicate FUs for parallel execution are needed, more CDBs. More instruction bandwidth is essential. Increased number of ports to Register File (datapath bandwidth): VLIW example needs 7 read and 3 write for Int. Reg. & 5 read and 3 write for FP reg Increased ports to memory (to improve memory bandwidth). Superscalar issue/decoding complexity may impact pipeline clock rate, depth. #29 lec # 6 Fall 2005 10-4-2005

Hardware Support for Extracting More Parallelism Compiler ILP techniques (loop-unrolling, software Pipelining etc.) are not effective to uncover maximum ILP when branch behavior is not well known at compile time. Techniques to further reduce the impact of branches on performance: ISA Support Needed Conditional or Predicted Instructions: An extension to the instruction set with instructions that turn into no-ops if a condition is not valid at run time (e.g. canceling branch delay instruction). Speculation: An instruction is executed before the processor knows that the instruction should execute to avoid control dependence stalls (i.e. branch not resolved yet): Static Speculation by the compiler with hardware support: ISA/Compiler Support Needed No ISA or Compiler Support Needed The compiler labels an instruction as speculative and the hardware helps by ignoring the outcome of incorrectly speculated instructions. Conditional instructions provide limited speculation. Dynamic Hardware-based Speculation: (Ch. 3.7) Uses dynamic branch-prediction to guide the speculation process. Dynamic scheduling and execution continued passed a conditional branch in the predicted branch direction. - (Speculative Tomasulo) #30 lec # 6 Fall 2005 10-4-2005

Conditional or Predicted Instructions Avoid branch prediction by turning branches into conditionally-executed instructions (helps increase average size of basic blocks by reducing the number of branches): if (x) then (A = B op C) else NOP If false, then neither store result nor cause exception: instruction is annulled (turned into NOP). Expanded ISA of Alpha, MIPS, PowerPC, SPARC have conditional move. ISA Based: HP PA-RISC can annul any following instruction. IA-64: 64 1-bit condition fields (flags) selected so conditional execution of any instruction (Predication). Drawbacks of conditional instructions Still takes a clock cycle even if annulled. Must stall if condition is evaluated late. Complex conditions reduce effectiveness; condition becomes known late in pipeline. (Ch. 4.5) ISA/Compiler Support Needed NOP x A = B op C #31 lec # 6 Fall 2005 10-4-2005

ISA Based: Conditional Execution in IA-64 VLIW (Predication) IA-64 Predication Example Predication in IA-64 turns control dependence into data dependence on predication flags Predication Flag evaluated 1 0 Taken Direction Taken Direction Not Taken Direction Not Taken Direction 64 Predication flags in IA-64 Predication: Any instruction can be cancelled (turned into a no-op) based on the value of one of 64 predication flags (qp) #32 lec # 6 Fall 2005 10-4-2005

Dynamic Hardware-Based Speculation Combines: Dynamic hardware-based branch prediction Dynamic Scheduling: issue multiple instructions in order and execute out of order. (Tomasulo) Continue to dynamically issue, and execute instructions passed a conditional branch in the dynamically predicted branch direction, before control dependencies are resolved. This overcomes the ILP limitations of the basic block size. Creates dynamically speculated instructions at run-time with no ISA/compiler support at all. If a branch turns out as mispredicted all such dynamically speculated instructions must be prevented from changing the state of the machine (registers, memory). How? (Ch. 3.7) (Speculative Execution Processors, Speculative Tomasulo) Addition of commit (retire, completion, or re-ordering) stage and forcing instructions to commit in their order in the code (i.e to write results to registers or memory in program order). Precise exceptions are possible since instructions must commit in order. #33 lec # 6 Fall 2005 10-4-2005

Hardware-Based Commit or Retirement Speculation Speculative Execution + Tomasulo s Algorithm Usually implemented as a circular buffer Store Results #34 lec # 6 Fall 2005 10-4-2005

Four Steps of Speculative Tomasulo Algorithm Four Steps of Speculative Tomasulo Algorithm 1. Issue (In-order) Get an instruction from Instruction Queue If a reservation station and a reorder buffer slot are free, issue instruction & send operands & reorder buffer number for destination (this stage is sometimes called dispatch ) 2. Execution (out-of-order) Operate on operands (EX) When both operands are ready then execute; if not ready, watch CDB for result; when both operands are in reservation station, execute; checks RAW (sometimes called issue ) 3. Write result (out-of-order) Finish execution (WB) Write on Common Data Bus (CDB) to all awaiting FUs & reorder buffer; mark reservation station available. 4. Commit (In-order) Update registers, memory with reorder buffer result When an instruction is at head of reorder buffer & the result is present, update register with result (or store to memory) and remove instruction from reorder buffer. A mispredicted branch at the head of the reorder buffer flushes the reorder buffer (cancels speculated instructions after the branch) Instructions issue in order, execute (EX), write result (WB) out of order, but must commit in order. #35 lec # 6 Fall 2005 10-4-2005

Hardware-Based Speculation Example Show speculated single-issue Tomasulo status when MUL.D is ready to commit Single-issue speculative Tomasulo Example on page 229 #36 lec # 6 Fall 2005 10-4-2005

Reorder buffer entry # for MUL.D Reorder buffer entry # for DIV.D speculated Tomasulo status when MUL.D is ready to commit (next cycle) No result value For DIV.D (not done executing) Single-issue speculative Tomasulo Example #37 lec # 6 Fall 2005 10-4-2005

Hardware-Based Speculation Example First iteration instructions committed Single-issue speculative Tomasulo Example on page 231 #38 lec # 6 Fall 2005 10-4-2005

L.D. and MUL.D of first iteration have committed, other instructions completed execution Next to commit Single-issue speculative Tomasulo #39 lec # 6 Fall 2005 10-4-2005

Multiple Issue with Speculation Example (2-way superscalar with no restriction on issue instruction type) A sufficient number of reservation stations and reorder (commit) buffer entries are available. Branches still single issue Example on page 235 #40 lec # 6 Fall 2005 10-4-2005

Answer: Without Speculation Branches Still Single Issue For instructions after a branch: Execution starts after branch is resolved #41 lec # 6 Fall 2005 10-4-2005

Answer: 2-way Superscalar Tomasulo With Speculation Branches Still Single Issue Arrows show data dependencies 14 cycles vs. 19 without speculation #42 lec # 6 Fall 2005 10-4-2005

Advantages of Hardware (Tomasulo( Tomasulo) vs. Software (VLIW) Speculation Hardware determines address conflicts. Hardware provides better branch prediction. Hardware maintains precise exception model. Hardware does not execute bookkeeping instructions. Hardware works across multiple implementations Software speculation is much easier for hardware design to support. #43 lec # 6 Fall 2005 10-4-2005

Superscalar Architecture Limitations: Issue Slot Waste Classification Empty or wasted issue slots can be defined as either vertical waste or horizontal waste: Vertical waste is introduced when the processor issues no instructions in a cycle. Horizontal waste occurs when not all issue slots can be filled in a cycle. Example: 4-Issue Superscalar Ideal IPC =4 Ideal CPI =.25 Also applies to VLIW Instructions Per Cycle = IPC = 1/CPI Result of issue slot waste: Actual Performance << Peak Performance #44 lec # 6 Fall 2005 10-4-2005

Sources of Unused Issue Cycles in an 8-issue Superscalar Processor. (wasted) Ideal Instructions Per Cycle, IPC = 8 Here real IPC about 1.5 (CPI = 1/8) (18.75 % of ideal IPC) Real IPC << Ideal IPC 1.5 << 8 ~ 81% of issue slots wasted Source: Simultaneous Multithreading: Maximizing On-Chip Parallelism Dean Tullsen et al., Proceedings of the 22rd Annual International Symposium on Computer Architecture, June 1995, pages 392-403. Processor busy represents the utilized issue slots; all others represent wasted issue slots. 61% of the wasted cycles are vertical waste, the remainder are horizontal waste. Workload: SPEC92 benchmark suite. #45 lec # 6 Fall 2005 10-4-2005

Superscalar Architecture Limitations : All possible causes of wasted issue slots, and latency-hiding or latency reducing techniques that can reduce the number of cycles wasted by each cause. Main Issue: One Thread leads to limited ILP (cannot fill issue slots) Possible Solution: Exploit Thread Level Parallelism (TLP) within a single physical processor: - Simultaneous Multithreaded (SMT) Processor: The processor issues and executes instructions from a number of threads creating a number of logical processors within a single physical processor e.g. Intel s HyperThreading (HT), each physical processor executes instructions from two threads Source: Simultaneous Multithreading: Maximizing On-Chip Parallelism Dean Tullsen et al., Proceedings of the 22rd Annual International Symposium on Computer Architecture, June 1995, pages 392-403. #46 lec # 6 Fall 2005 10-4-2005