1 Seoul National University Pipelined Implementation : Part I.

Slides:



Advertisements
Similar presentations
Randal E. Bryant Carnegie Mellon University CS:APP CS:APP Chapter 4 Computer Architecture PipelinedImplementation Part II CS:APP Chapter 4 Computer Architecture.
Advertisements

University of Amsterdam Computer Systems – the processor architecture Arnoud Visser 1 Computer Systems The processor architecture.
Lecture 4: CPU Performance
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
Pipelining I Topics Pipelining principles Pipeline overheads Pipeline registers and stages Systems I.
Review: Pipelining. Pipelining Laundry Example Ann, Brian, Cathy, Dave each have one load of clothes to wash, dry, and fold Washer takes 30 minutes Dryer.
Pipelining Hwanmo Sung CS147 Presentation Professor Sin-Min Lee.
1 Seoul National University Wrap-Up. 2 Overview Seoul National University Wrap-Up of PIPE Design  Exception conditions  Performance analysis Modern.
Real-World Pipelines: Car Washes Idea  Divide process into independent stages  Move objects through stages in sequence  At any instant, multiple objects.
PipelinedImplementation Part I PipelinedImplementation.
Instructor: Erol Sahin
– 1 – Chapter 4 Processor Architecture Pipelined Implementation Chapter 4 Processor Architecture Pipelined Implementation Instructor: Dr. Hyunyoung Lee.
PipelinedImplementation Part I CSC 333. – 2 – Overview General Principles of Pipelining Goal Difficulties Creating a Pipelined Y86 Processor Rearranging.
Pipelining II Andreas Klappenecker CPSC321 Computer Architecture.
1 Recap (Pipelining). 2 What is Pipelining? A way of speeding up execution of tasks Key idea : overlap execution of multiple taks.
Chapter 12 Pipelining Strategies Performance Hazards.
Pipelining Andreas Klappenecker CPSC321 Computer Architecture.
L17 – Pipeline Issues 1 Comp 411 – Fall /1308 CPU Pipelining Issues Finishing up Chapter 6 This pipe stuff makes my head hurt! What have you been.
Pipelined Processor II CPSC 321 Andreas Klappenecker.
7/2/ _23 1 Pipelining ECE-445 Computer Organization Dr. Ron Hayne Electrical and Computer Engineering.
Appendix A Pipelining: Basic and Intermediate Concepts
Pipelining. Overview Pipelining is widely used in modern processors. Pipelining improves system performance in terms of throughput. Pipelined organization.
Datapath Design II Topics Control flow instructions Hardware for sequential machine (SEQ) Systems I.
Pipelining III Topics Hazard mitigation through pipeline forwarding Hardware support for forwarding Forwarding to mitigate control (branch) hazards Systems.
David O’Hallaron Carnegie Mellon University Processor Architecture PIPE: Pipelined Implementation Part I Processor Architecture PIPE: Pipelined Implementation.
1 Naïve Pipelined Implementation. 2 Outline General Principles of Pipelining –Goal –Difficulties Naïve PIPE Implementation Suggested Reading 4.4, 4.5.
Pipelining (I). Pipelining Example  Laundry Example  Four students have one load of clothes each to wash, dry, fold, and put away  Washer takes 30.
Randal E. Bryant Carnegie Mellon University CS:APP CS:APP Chapter 4 Computer Architecture SequentialImplementation CS:APP Chapter 4 Computer Architecture.
Datapath Design I Topics Sequential instruction execution cycle Instruction mapping to hardware Instruction decoding Systems I.
Computer Architecture: Wrap-up CENG331 - Computer Organization Instructors: Murat Manguoglu(Section 1) Erol Sahin (Section 2 & 3) Adapted from slides of.
1 Sequential CPU Implementation. 2 Outline Logic design Organizing Processing into Stages SEQ timing Suggested Reading 4.2,4.3.1 ~
Pipeline Architecture I Slides from: Bryant & O’ Hallaron
PipelinedImplementation Part II PipelinedImplementation.
Computer Architecture: Pipelined Implementation - I
Computer Architecture adapted by Jason Fritts
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
1 Seoul National University Pipelining Basics. 2 Sequential Processing Seoul National University.
11 Pipelining Kosarev Nikolay MIPT Oct, Pipelining Implementation technique whereby multiple instructions are overlapped in execution Each pipeline.
1 SEQ CPU Implementation. 2 Outline SEQ Implementation Suggested Reading 4.3.1,
Randal E. Bryant Carnegie Mellon University CS:APP2e CS:APP Chapter 4 Computer Architecture PipelinedImplementation Part II CS:APP Chapter 4 Computer Architecture.
Basic Pipelining September 19, 2001 Topics Objective Instruction formats Instruction processing Principles of pipelining Inserting pipe registers.
Real-World Pipelines Idea –Divide process into independent stages –Move objects through stages in sequence –At any given times, multiple objects being.
1 Pipelined Implementation. 2 Outline Handle Control Hazard Handle Exception Performance Analysis Suggested Reading 4.5.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
CPSC 121: Models of Computation
Real-World Pipelines Idea Divide process into independent stages
CPSC 121: Models of Computation
Systems I Pipelining IV
Lecture 14 Y86-64: PIPE – pipelined implementation
Pipelined Implementation : Part I
Seoul National University
Seoul National University
Instruction Decoding Optional icode ifun valC Instruction Format
Pipelined Implementation : Part II
Systems I Pipelining III
Computer Architecture adapted by Jason Fritts
Systems I Pipelining II
Pipelined Implementation : Part I
Seoul National University
Systems I Pipelining I Topics Pipelining principles Pipeline overheads
Pipeline Architecture I Slides from: Bryant & O’ Hallaron
Pipelined Implementation : Part I
Pipeline Principle A non-pipelined system of combination circuits (A, B, C) that computation requires total of 300 picoseconds. Comb. logic.
Pipelined Implementation
Systems I Pipelining II
Chapter 4 Processor Architecture
Systems I Pipelining II
Pipelined Implementation
Real-World Pipelines: Car Washes
Sequential Design תרגול 10.
Presentation transcript:

1 Seoul National University Pipelined Implementation : Part I

2 Overview Seoul National University General Principles of Pipelining  Goal  Difficulties Creating a Pipelined Y86 Processor  Rearranging SEQ  Inserting pipeline registers  Problems with data and control hazards

3 Real-World Pipelines: Car Washes Seoul National University Idea  Divide process into independent stages  Move objects through stages in sequence  At any given times, multiple objects being processed SequentialParallel Pipelined

4 Computational Example Seoul National University System  Computation requires total of 300 picoseconds  Additional 20 picoseconds to save result in register  Must have clock cycle of at least 320 ps Combinational logic RegReg 300 ps20 ps Clock Delay = 320 ps Throughput = 3.12 GIPS

5 3-Way Pipelined Version Seoul National University System  Divide combinational logic into 3 blocks of 100 ps each  Can begin new operation as soon as previous one passes through stage A.  Begin new operation every 120 ps  Overall latency increases  360 ps from start to finish RegReg Clock Comb. logic A RegReg Comb. logic B RegReg Comb. logic C 100 ps20 ps100 ps20 ps100 ps20 ps Delay = 360 ps Throughput = 8.33 GIPS

6 Pipeline Diagrams Seoul National University Unpipelined  Cannot start new operation until previous one completes 3-Way Pipelined  Up to 3 operations in process simultaneously OP1 Time OP2 OP3 OP1 Time ABC ABC ABC OP2 OP3

7 Operating a Pipeline Seoul National University Time OP1 OP2 OP3 ABC ABC ABC Clock RegReg Comb. logic A RegReg Comb. logic B RegReg Comb. logic C 100 ps20 ps100 ps20 ps100 ps20 ps 239 RegReg Clock Comb. logic A RegReg Comb. logic B RegReg Comb. logic C 100 ps20 ps100 ps20 ps100 ps20 ps 241 RegReg RegReg RegReg 100 ps20 ps100 ps20 ps100 ps20 ps Comb. logic A Comb. logic B Comb. logic C Clock 300 RegReg Clock Comb. logic A RegReg Comb. logic B RegReg Comb. logic C 100 ps20 ps100 ps20 ps100 ps20 ps 359

8 Limitations: Nonuniform Delays Seoul National University  Throughput limited by slowest stage  Other stages sit idle for much of the time  Challenging to partition system into balanced stages RegReg Clock RegReg Comb. logic B RegReg Comb. logic C 50 ps 20 ps150 ps20 ps100 ps20 ps Delay = 510 ps Throughput = 5.88 GIPS Comb. logic A Time OP1 OP2 OP3 ABC ABC ABC

9 Limitations: Register Overhead Seoul National University  As try to deepen pipeline, overhead of loading registers becomes more significant  Percentage of clock cycle spent loading register:  1-stage pipeline: 6.25%  3-stage pipeline: 16.67%  6-stage pipeline: 28.57%  High speeds of modern processor designs obtained through very deep pipelining Delay = 420 ps, Throughput = GIPSClock RegReg Comb. logic 50 ps20 ps RegReg Comb. logic 50 ps20 ps RegReg Comb. logic 50 ps20 ps RegReg Comb. logic 50 ps20 ps RegReg Comb. logic 50 ps20 ps RegReg Comb. logic 50 ps20 ps

10 Data Hazards (Dependencies) in Processors Seoul National University  Result from one instruction used as operand for another  Read-after-write (RAW) dependency  Very common in actual programs  Must make sure our pipeline handles these properly  Get correct results  Minimize performance impact 1 irmovl $50, %eax 2 addl %eax, %ebx 3 mrmovl 100( %ebx ), %edx

11 Adding Pipeline Registers Seoul National University,

12 Pipeline Stages Seoul National University Fetch  Select current PC  Read instruction  Compute incremented PC Decode  Read program registers Execute  Operate ALU Memory  Read or write data memory Write Back  Update register file

13 PIPE- Hardware Seoul National University  Pipeline registers hold intermediate values from instruction execution Forward (Upward) Paths  Same values passed from one stage to next  e.g., icode, valC, etc  Cannot jump over other stages

14 Signal Naming Conventions Seoul National University S_Field  Value of Field held in stage S pipeline register s_Field  Value of Field computed in stage S

15 Feedback Paths Seoul National University Predicted PC  Guess value of next PC Branch information  Jump taken/not-taken  Fall-through or target address Return point  Read from memory Register updates  To register file write ports

16 Predicting the PC Seoul National University  Start fetch of new instruction after current one has completed fetch stage  Not possible to determine the next instruction 100% correctly  Guess which instruction will follow  Recover if prediction was incorrect

17 Our Prediction Strategy Seoul National University Instructions that Don’t Transfer Control  Predict next PC to be valP  Always reliable Call and Unconditional Jumps  Predict next PC to be valC (destination)  Always reliable Conditional Jumps  Predict next PC to be valC (destination)  Only correct if branch is taken  Typically right 60% of time Return Instruction  Don’t try to predict

18 Recovering from PC Misprediction Seoul National University  Mispredicted Jump  Will see branch condition flag once instruction reaches memory stage  Can get fall-through PC from valA (value M_valA)  Return Instruction  Will get return PC when ret reaches write-back stage (W_valM)

19 Pipeline Demonstration Seoul National University irmovl $1,%eax #I FDEM W irmovl $2,%ecx #I2 FDEM W irmovl $3,%edx #I3 FDEMW irmovl $4,%ebx #I4 FDEMW halt #I5 FDEMW Cycle 5 W I1 M I2 E I3 D I4 F I5

20 Data Dependencies: No Nop Seoul National University 0x000:irmovl$10,%edx 0x006:irmovl$3,%eax 0x00c:addl%edx,%eax 0x00e: halt FDEM WFDEM W FDEMW FDEMW E D valA  R[ %edx ]=0 valB  R[ %eax ]=0 D valA  R[ %edx ]=0 valB  R[ %eax ]=0 Cycle 4 Error M M_valE= 10 M_dstE= %edx e_valE  = 3 E_dstE= %eax

21 Data Dependencies: 1 Nop Seoul National University 0x000:irmovl$10,%edx 0x006:irmovl$3,%eax 0x00c:nop 0x00d:addl%edx,%eax 0x00f: halt

22 Data Dependencies: 2 Nop’s Seoul National University FDEMWFDEMW FDEMWFDEMW FDEMWFDEMW FDEMWFDEMW FDEMWFDEMW FDEMWFDEMW 10 0x000:irmovl$10,%edx 0x006:irmovl$3,%eax 0x00c:nop 0x00d:nop 0x00e:addl%edx,%eax 0x010: halt W R[ %eax ]  3 D valA  R[ %edx ]=10 valB  R[ %eax ]=0 W R[ %eax ]  3 W R[ %eax ]  3 D valA  R[ %edx ]=10 valB  R[ %eax ]=0 D valA  R[ %edx ]=10 valB  R[ %eax ]=0 Cycle 6 Error

23 Data Dependencies: 3 Nop’s Seoul National University 0x000:irmovl$10,%edx 0x006:irmovl$3,%eax 0x00c:nop 0x00d:nop 0x00e:nop 0x00f:addl%edx,%eax 0x011: halt FDEMWFDEMW FDEMWFDEMW FDEMWFDEMW FDEMWFDEMW FDEMWFDEMW FDEMWFDEMW 10 W R[ %eax ]  3 W R[ % eax ]  3 D valA  R[ %edx ]=10 valB  R[ %eax ]=3 D valA  R[ % edx ]=10 valB  R[ % eax ]=3 Cycle 6 11 FDEMWFDEMW Cycle 7

24 Branch Misprediction Example Seoul National University 0x000: xorl %eax,%eax 0x002: jne t # Not taken 0x007: irmovl $1, %eax # Fall through 0x00d: nop 0x00e: nop 0x00f: nop 0x010: halt 0x011: t: irmovl $3, %edx # Target (Should not execute) 0x017: irmovl $4, %ecx # Should not execute 0x01d: irmovl $5, %edx # Should not execute

25 Branch Misprediction Trace Seoul National University 0x000:xorl%eax,%eax 0x002:jnet # Not taken 0x011: t:irmovl$3, %edx# Target 0x017:irmovl$4, %ecx# Target+1 0x007:irmovl$1, %eax# Fall Through Incorrectly execute two instructions at branch target...

26 Quick & Dirty Solution Seoul National University 0x000: xorl %eax,%eax 0x002: jne t # Not taken 0x007: irmovl $1, %eax # Fall through 0x00d: nop 0x00e: nop 0x00f: nop 0x010: halt 0x011: t: nop 0x012 nop 0x013 nop 0x014: irmovl $3, %edx # Target (Should not execute) 0x01a: irmovl $4, %ecx # Should not execute 0x020: irmovl $5, %edx # Should not execute

27 Return Example Seoul National University 0x000: irmovl Stack,%esp # Initialize stack pointer 0x006: nop # Avoid hazard on %esp 0x007: nop 0x008: nop 0x009: call p # Procedure call 0x00e: irmovl $5,%esi # Return point 0x014: halt 0x020:.pos 0x20 0x020: p: nop # procedure 0x021: nop 0x022: nop 0x023: ret 0x024: irmovl $1,%eax # Should not be executed 0x02a: irmovl $2,%ecx # Should not be executed 0x030: irmovl $3,%edx # Should not be executed 0x036: irmovl $4,%ebx # Should not be executed 0x100:.pos 0x100 0x100: Stack: # Stack: Stack pointer

28 Incorrect Return Example Seoul National University Incorrectly execute 3 instructions following ret

29 Another Quick & Dirty Solution Seoul National University 0x000: irmovl Stack,%esp # Initialize stack pointer 0x006: nop # Avoid hazard on %esp 0x007: nop 0x008: nop 0x009: call p # Procedure call 0x00e: irmovl $5,%esi # Return point 0x014: halt 0x020:.pos 0x20 0x020: p: nop # procedure 0x021: nop 0x022: nop 0x023: ret 0x024 nop 0x025 nop 0x026 nop 0x027 nop 0x028: irmovl $1,%eax # Should not be executed 0x02e: irmovl $2,%ecx # Should not be executed 0x034: irmovl $3,%edx # Should not be executed 0x03a: irmovl $4,%ebx # Should not be executed 0x100:.pos 0x100 0x100: Stack: # Stack: Stack pointer

30 Pipeline Summary Seoul National University Concept  Break instruction execution into 5 stages  Run instructions through in pipelined mode Limitations  Can’t handle dependencies between instructions when instructions follow too closely  Data dependencies  One instruction writes register, later one reads it  Control dependency  Instruction sets PC in way that pipeline did not predict correctly  Mispredicted branch and return Fixing the Pipeline  We’ll do that next time