Chapter 4 The Processor (Part 4)

Similar documents
Processor (IV) - advanced ILP. Hwansoo Han

The Processor: Instruction-Level Parallelism

Advanced Instruction-Level Parallelism

Advanced d Instruction Level Parallelism. Computer Systems Laboratory Sungkyunkwan University

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

COMPUTER ORGANIZATION AND DESI

Computer Architecture Computer Science & Engineering. Chapter 4. The Processor BK TP.HCM

Determined by ISA and compiler. We will examine two MIPS implementations. A simplified version A more realistic pipelined version

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: C Multiple Issue Based on P&H

Chapter 4. The Processor

Chapter 4. The Processor

EIE/ENE 334 Microprocessors

Lec 25: Parallel Processors. Announcements

Homework 5. Start date: March 24 Due date: 11:59PM on April 10, Monday night. CSCI 402: Computer Architectures

4. The Processor Computer Architecture COMP SCI 2GA3 / SFWR ENG 2GA3. Emil Sekerinski, McMaster University, Fall Term 2015/16

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

Computer Architecture Computer Science & Engineering. Chapter 4. The Processor BK TP.HCM

Full Datapath. Chapter 4 The Processor 2

Chapter 4. The Processor

Department of Computer and IT Engineering University of Kurdistan. Computer Architecture Pipelining. By: Dr. Alireza Abdollahpouri

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. 5 th. Edition. Chapter 4. The Processor

Adapted from instructor s. Organization and Design, 4th Edition, Patterson & Hennessy, 2008, MK]

CS 61C: Great Ideas in Computer Architecture. Multiple Instruction Issue, Virtual Memory Introduction

Thomas Polzer Institut für Technische Informatik

5 th Edition. The Processor We will examine two MIPS implementations A simplified version A more realistic pipelined version

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 32: Pipeline Parallelism 3

Chapter 4. The Processor. Jiang Jiang

Multicore and Parallel Processing

Multiple Instruction Issue. Superscalars

EN164: Design of Computing Systems Topic 08: Parallel Processor Design (introduction)

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

LECTURE 3: THE PROCESSOR

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Instruction Level Parallelism: Multiple Instruction Issue

LECTURE 10. Pipelining: Advanced ILP

Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University. P & H Chapter 4.10, 1.7, 1.8, 5.10, 6

Chapter 5 Large and Fast: Exploiting Memory Hierarchy (Part 1)

In-order vs. Out-of-order Execution. In-order vs. Out-of-order Execution

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

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

Instruction Level Parallelism. Appendix C and Chapter 3, HP5e

5008: Computer Architecture

COMPUTER ORGANIZATION AND DESIGN

Static, multiple-issue (superscaler) pipelines

Hardware-based Speculation

Chapter 4. The Processor

Lecture 2: Processor and Pipelining 1

Outline. A pipelined datapath Pipelined control Data hazards and forwarding Data hazards and stalls Branch (control) hazards Exception

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

Computer and Information Sciences College / Computer Science Department Enhancing Performance with Pipelining

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

Chapter 4 The Processor (Part 2)

Chapter 4. The Processor

Parallelism, Multicore, and Synchronization

Pipelining. CSC Friday, November 6, 2015

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

The Processor: Improving the performance - Control Hazards

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

Chapter 3: Loaders and Linkers

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

Four Steps of Speculative Tomasulo cycle 0

CS425 Computer Systems Architecture

Chapter 5 Large and Fast: Exploiting Memory Hierarchy (Part 2)

CISC 662 Graduate Computer Architecture Lecture 13 - CPI < 1

Instruction Level Parallelism. ILP, Loop level Parallelism Dependences, Hazards Speculation, Branch prediction

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

DEE 1053 Computer Organization Lecture 6: Pipelining

CSEE 3827: Fundamentals of Computer Systems

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

3/12/2014. Single Cycle (Review) CSE 2021: Computer Organization. Single Cycle with Jump. Multi-Cycle Implementation. Why Multi-Cycle?

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

Static vs. Dynamic Scheduling

Advanced processor designs

Copyright 2012, Elsevier Inc. All rights reserved.

Hardware-Based Speculation

Donn Morrison Department of Computer Science. TDT4255 ILP and speculation

CS3350B Computer Architecture Quiz 3 March 15, 2018

Advanced issues in pipelining

CS252 Graduate Computer Architecture Midterm 1 Solutions

HY425 Lecture 09: Software to exploit ILP

1 Hazards COMP2611 Fall 2015 Pipelined Processor

HY425 Lecture 09: Software to exploit ILP

Handout 2 ILP: Part B

Multi-cycle Instructions in the Pipeline (Floating Point)

CS6303 Computer Architecture Regulation 2013 BE-Computer Science and Engineering III semester 2 MARKS

EN164: Design of Computing Systems Topic 06.b: Superscalar Processor Design

CS152 Computer Architecture and Engineering March 13, 2008 Out of Order Execution and Branch Prediction Assigned March 13 Problem Set #4 Due March 25

Advanced Computer Architecture

Complex Pipelines and Branch Prediction

Chapter 4. The Processor

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

Hardware-Based Speculation

UNIT 8 1. Explain in detail the hardware support for preserving exception behavior during Speculation.

CMSC411 Fall 2013 Midterm 2 Solutions

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

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

Pipelining and Exploiting Instruction-Level Parallelism (ILP)

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

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

Getting CPI under 1: Outline

Chapter 3 Arithmetic for Computers (Part 2)

Transcription:

Department of Electr rical Eng ineering, Chapter 4 The Processor (Part 4) 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Depar rtment of Electr rical Engineering, Feng-Chia Unive ersity Outline 4.9 Exceptions 4.10 Parallelism and Advanced ILP 4.14 Concluding Remarks 2

What is an exception? Unexpected events Change PC Interrupt External, usually I/O devices wish to communicate with CPU Exception Internal or external Exception I1 I2 I3 I4 I5 I6 I7 I9 return taken INT J1 J2 J3.. JR 3 Vector interrupt vs. status register Use a status register to hold exception causes Single entry point: 0x8000_0180 Use vectored interrupt The address to which the control is transferred is determined by the cause of the exception Exception type Exception vector address (in hex) undefined instruction 0x8000_0000 arithmetic overflow 0x8000_0180 4

Additional registers Exception Program Counter (EPC): a 32-bit register used to hold the address of the affected instruction Cause: a register used to record the cause of the exception 0: undefined instruction (can not recognize the opcode) 1: arithmetic overflow 5 Exceptions in a Pipeline Another form of control hazard Consider overflow on add in EX stage Prevent $1 from being clobbered Complete previous instructions Flush add and subsequent instructions Set Cause and EPC register values Transfer control to handler Similar il to mispredicted d branch Use much of the same hardware 40 sub $11, $2, $4 44 and $12, $2, $5 48 or $13, $2, $6 4C add $1, $2, $1 50 slt $15, $6, $7 54 lw $16, 50($7) 6

Depar rtment of Electrical Engineering, Feng-Chia Unive ersity Pipeline with Exceptions 7 Exception Properties Restartable exceptions Pipeline can flush the instruction Handler executes, then returns to the instruction Refetched and executed from scratch PC saved in EPC register Identifies causing instruction Actually PC + 4 is saved Handler must adjust 8

Exception Example Exception on add in 40 sub $11, $2, $4 44 and $12, $2, $5 48 or $13, $2, $6 4C add $1, $2, $1 50 slt $15, $6, $7 54 lw $16, 50($7) Handler 80000180 sw $25, 1000($0) 80000184 sw $26, 1004($0) 9 Depar rtment of Electrical Engineering, Feng-Chia Unive ersity Exception Example

Depar rtment of Electrical Engineering, Feng-Chia Unive ersity Exception Example Multiple Exceptions Pipelining overlaps multiple instructions Could have multiple exceptions at once Simple approach: deal with exception from earliest instruction Flush subsequent instructions Precise exceptions In complex pipelines Multiple instructions issued per cycle Out-of-order completion Maintaining precise exceptions is difficult! 12

Imprecise Exceptions Just stop pipeline and save state Including exception cause(s) Let the handler work out Which instruction(s) had exceptions Which to complete or flush May require manual completion Simplifies hardware, but more complex handler software Not feasible for complex multiple-issue out-of-order pipelines 13 Depar rtment of Electr rical Engineering, Feng-Chia Unive ersity Outline 4.9 Exceptions 4.10 Parallelism and Advanced ILP 4.14 Concluding Remarks 14

Instruction Level Parallelism (ILP) Two methods to increase ILP Increase the pipeline depth More operations being overlapped Multiple issue Static multiple issue: determined at compile time VLIW: Very Long Instruction Word (relies more on compiler technology) EPIC: Explicitly Parallel Instruction Computer Dynamic multiple issue: determined during execution Superscalar All modern processors are superscalar and issue multiple instructions usually with some limitations 15 Depar rtment of Electrical Engineering, Feng-Chia Unive ersity A static two-issue datapath 16

Hazards in the Dual-Issue MIPS More instructions executing in parallel EX data hazard Forwarding avoided stalls with single-issue Now can t use ALU result in load/store in same packet add $t0, $s0, $s1 load $s2, 0($t0) Split into two packets, effectively a stall Load-use hazard Still one cycle use latency, but now two instructions More aggressive scheduling required 17 Scheduling Example Schedule this for dual-issue MIPS Loop: lw $t0, 0($s1) # $t0=array element addu $t0, $t0, $s2 # add scalar in $s2 sw $t0, 0($s1) # store result addi $s1, $s1, 4 # decrement pointer bne $s1, $zero, Loop # branch $s1!=0 ALU/branch Load/store cycle Loop: nop lw $t0, 0($s1) 1 addi $s1, $s1, 4 nop 2 addu $t0, $t0, $s2 nop 3 bne $s1, $zero, Loop sw $t0, 4($s1) 4 IPC = 5/4 = 1.25 (c.f. peak IPC = 2) 18

Loop Unrolling Replicate loop body to expose more parallelism Reduces loop-control overhead Use different registers per replication Called register renaming Avoid loop-carried anti-dependencies Store followed by a load of the same register Aka name dependence - Reuse of a register name 19 Loop Unrolling Example ALU/branch Load/store cycle Loop: addi $s1, $s1, 16 lw $t0, 0($s1) 1 nop lw $t1, 12($s1) 2 addu $t0, $t0, $s2 lw $t2, 8($s1) 3 addu $t1, $t1, $s2 lw $t3, 4($s1) 4 addu $t2, $t2, $s2 sw $t0, 16($s1) 5 addu $t3, $t4, $s2 sw $t1, 12($s1) 6 nop sw $t2, 8($s1) 7 bne $s1, $zero, Loop sw $t3, 4($s1) 8 IPC = 14/8 = 1.75 Closer to 2, but at cost of registers and code size 20

Depar rtment of Electrical Engineering, Feng-Chia Unive ersity Out-of-order order execution Reorder Buffer Branch Prediction Speculation 21 Register Renaming Reservation stations and reorder buffer effectively provide register renaming On instruction issue to reservation station If operand is available in register file or reorder buffer Copied to reservation station No longer required in the register; can be overwritten If operand is not yet available It will be provided to the reservation station by a function unit Register update may not be required 22

Speculation Guess what to do with an instruction Start operation as soon as possible Check whether guess was right If so, complete the operation If not, roll-back and do the right thing Common to static and dynamic multiple issue Examples Speculate on branch outcome Roll back if path taken is different Speculate on load Roll back if location is updated 23 Feng-Chia Unive ersity Compiler/Hardware Speculation Compiler can reorder instructions e.g., move load before branch Can include fix-up instructions to recover from incorrect guess Hardware can look ahead for instructions to execute Buffer results until it determines they are actually needed Flush buffers on incorrect speculation 24

Speculation and Exceptions What if exception occurs on a speculatively executed instruction? e.g., speculative load before null-pointer check Static speculation Can add ISA support for deferring exceptions Dynamic speculation Can buffer exceptions until instruction completion (which may not occur) 25 Speculation Predict branch and continue issuing Don t commit until branch outcome determined Load speculation Avoid load and cache miss delay Predict the effective address Predict loaded value Load before completing outstanding stores Bypass stored values to load unit Don t commit load until speculation cleared 26

Feng-Chia Unive ersity Why Do Dynamic Scheduling? Why not just let the compiler schedule code? Not all stalls are predicable e.g., cache misses Can t always schedule around branches Branch outcome is dynamically y determined Different implementations of an ISA have different latencies and hazards 27 Does Multiple Issue Work? Yes, but not as much as we d like Programs have real dependencies that limit ILP Some dependencies are hard to eliminate e.g., pointer aliasing Some parallelism is hard to expose Limited window size during instruction issue Memory delays and limited bandwidth Hard to keep pipelines full Speculation can help if done well 28

Power Efficiency Complexity of dynamic scheduling and speculations requires power Multiple simpler cores may be better Microprocessor Year Clock Rate Pipeline Stages Issue width Out-of-order/ Speculation Cores Power i486 1989 25MHz 5 1 No 1 5W Pentium 1993 66MHz 5 2 No 1 10W Pentium Pro 1997 200MHz 10 3 Yes 1 29W P4 Willamette 2001 2,000MHz 22 3 Yes 1 75W P4 Prescott 2004 3,600MHz 31 3 Yes 1 103W Core 2006 2,930MHz 14 4 Yes 2 75W UltraSparc III 2003 1,950MHz 14 4 No 1 90W UltraSparc T1 2005 1,200MHz 6 1 No 8 70W 29 Depar rtment of Electr rical Engineering, Feng-Chia Unive ersity The Opteron X4 Microarchitecture 72 physical registers 30

Depar rtment of Electrical Engineering, The Opteron X4 Pipeline Flow For integer operations FP is 5 stages longer Up to 106 RISC-ops in progress Bottlenecks Complex instructions with long dependencies Branch mispredictions Memory access delays 31 Depar rtment of Electr rical Engineering, Feng-Chia Unive ersity Outline 4.9 Exceptions 4.10 Parallelism and Advanced ILP 4.14 Concluding Remarks 32

Concluding Remarks ISA influences design of datapath and control Datapath and control influence design of ISA Pipelining improves instruction throughput using parallelism More instructions completed per second Latency for each instruction not reduced Hazards: structural, data, control Multiple l issue and dynamic scheduling (ILP) Dependencies limit achievable parallelism Complexity leads to the power wall 33 Depar rtment of Electrical Engineering, Feng-Chia Unive ersity Summary Pipelining does not improve latency, but does improve throughput 34