Pipelined Implementation : Part I

Slides:



Advertisements
Similar presentations
University of Amsterdam Computer Systems – the processor architecture Arnoud Visser 1 Computer Systems The processor architecture.
Advertisements

Lecture 4: CPU Performance
Pipelining I Topics Pipelining principles Pipeline overheads Pipeline registers and stages Systems I.
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.
7/2/ _23 1 Pipelining ECE-445 Computer Organization Dr. Ron Hayne Electrical and Computer Engineering.
Appendix A Pipelining: Basic and Intermediate Concepts
Randal E. Bryant CS:APP Chapter 4 Computer Architecture SequentialImplementation CS:APP Chapter 4 Computer Architecture SequentialImplementation Slides.
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 Seoul National University Pipelined Implementation : Part I.
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
Computer Architecture: Pipelined Implementation - I
Computer Architecture adapted by Jason Fritts
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.
Sequential Hardware “God created the integers, all else is the work of man” Leopold Kronecker (He believed in the reduction of all mathematics to arguments.
Rabi Mahapatra CS:APP3e Slides are from Authors: Bryant and O Hallaron.
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.
Real-World Pipelines Idea Divide process into independent stages
Chapter Six.
Computer Organization
Stalling delays the entire pipeline
Lecture 13 Y86-64: SEQ – sequential implementation
Lecture 14 Y86-64: PIPE – pipelined implementation
ELEN 468 Advanced Logic Design
Morgan Kaufmann Publishers The Processor
Course Outline Background Sequential Implementation Pipelining
Sequential Implementation
Samira Khan University of Virginia Feb 14, 2017
Morgan Kaufmann Publishers The Processor
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
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
Pipelined Implementation
Chapter 8. Pipelining.
Computer Architecture
Systems I Pipelining II
Chapter 4 Processor Architecture
Systems I Pipelining II
Seoul National University
Pipelined Implementation
Real-World Pipelines: Car Washes
Sequential CPU Implementation
A relevant question Assuming you’ve got: One washer (takes 30 minutes)
Sequential Design תרגול 10.
Pipelining Hazards.
Presentation transcript:

Pipelined Implementation : Part I Seoul National University Pipelined Implementation : Part I

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

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

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

3-Way Pipelined Version Seoul National University 3-Way Pipelined Version R e g Clock Comb. logic A B C 100 ps 20 ps Delay = 360 ps Throughput = 8.33 GIPS 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

Pipeline Diagrams Unpipelined 3-Way Pipelined Seoul National University Pipeline Diagrams 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 A B C OP2 OP3

Operating a Pipeline Clock Comb. logic A B C 100 ps 20 ps 359 100 ps Seoul National University Operating a Pipeline R e g Clock Comb. logic A B C 100 ps 20 ps 359 R e g 100 ps 20 ps Comb. logic A B C Clock 300 R e g Clock Comb. logic A B C 100 ps 20 ps 239 R e g Clock Comb. logic A B C 100 ps 20 ps 241 Time OP1 OP2 OP3 A B C 120 240 360 480 640 Clock

Limitations: Nonuniform Delays Seoul National University Limitations: Nonuniform Delays R e g Clock Comb. logic B C 50 ps 20 ps 150 ps 100 ps Delay = 510 ps Throughput = 5.88 GIPS A Time OP1 OP2 OP3 A B C Throughput limited by slowest stage Other stages sit idle for much of the time Challenging to partition system into balanced stages

Limitations: Register Overhead Seoul National University Limitations: Register Overhead Delay = 420 ps, Throughput = 14.29 GIPS Clock R e g Comb. logic 50 ps 20 ps 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

Data Hazards (Dependencies) in Processors Seoul National University Data Hazards (Dependencies) in Processors 1 irmovq $50, %rax 2 addq %rax , %rbx 3 mrmovq 100( %rbx ), %rdx 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

Adding Pipeline Registers Seoul National University Adding Pipeline Registers Instruction memory PC increment CC ALU Data Fetch Decode Execute Memory Write back icode ifun rA , rB valC Register file A B M E valP srcA srcB dstA dstB valA valB aluA aluB Cnd valE Addr , Data valM newPC ,

Pipeline Stages Fetch Decode Execute Memory Write Back Seoul National University Pipeline Stages 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

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

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

Feedback Paths Predicted PC Branch information Return point Seoul National University Feedback Paths 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

Seoul National University Predicting the PC 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

Our Prediction Strategy Seoul National University Our Prediction Strategy 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) Conditional Jumps Only correct if branch is taken Typically right 60% of time Return Instruction Don’t try to predict

Recovering from PC Misprediction Seoul National University Recovering from PC Misprediction 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)

Pipeline Demonstration Seoul National University Pipeline Demonstration 1 2 3 4 5 6 7 8 9 irmovq $1,%rax #I1 F D E M W irmovq $2,%rcx #I2 F D E M W irmovq $3,%rdx #I3 F D E M W irmovq $4,%rbx #I4 F D E M W halt #I5 F D E M W Cycle 5 W I1 M I2 E I3 D I4 F I5

Data Dependencies: 3 Nop’s Seoul National University Data Dependencies: 3 Nop’s

Data Dependencies: 2 Nop’s Seoul National University Data Dependencies: 2 Nop’s

Data Dependencies: 1 Nop Seoul National University Data Dependencies: 1 Nop

Data Dependencies: No Nop Seoul National University Data Dependencies: No Nop

Branch Misprediction Example Seoul National University Branch Misprediction Example 0x000: xorq %rax,%rax 0x002: jne t # Not taken 0x00b: irmovq $1, %rax # Fall through 0x015: nop 0x016: nop 0x017: nop 0x018: halt 0x019: t: irmovq $3, %rdx # Target (Should not execute) 0x023: irmovq $4, %rcx # Should not execute 0x02d: irmovq $5, %rdx # Should not execute Should only execute first 8 instructions

Branch Misprediction Trace Seoul National University Branch Misprediction Trace b

Return Example Require lots of nops to avoid data hazards Seoul National University Return Example 0x000: irmovq Stack,%rsp # Initialize stack pointer 0x00a: nop # Avoid hazard on %rsp 0x00b: nop 0x00c: nop 0x00d: call p # Procedure call 0x016: irmovq $5,%rsi # Return point … 0x020: p: nop # procedure 0x021: nop 0x022: nop 0x023: ret 0x024: irmovq $1,%rax # Should not be executed 0x02e: irmovq $2,%rcx # Should not be executed 0x038: irmovq $3,%rdx # Should not be executed 0x042: irmovq $4,%rbx # Should not be executed 0x100: .pos 0x100 0x100: Stack: # Initial stack pointer Require lots of nops to avoid data hazards

Incorrect Return Example Seoul National University Incorrect Return Example 0x023 0x024 0x02e 0x038 0x016 Incorrectly execute 3 instructions following ret

Pipeline Summary Concept Limitations Fixing the Pipeline Seoul National University Pipeline Summary 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