Pipeline Review - University Of Washington

3y ago
37 Views
2 Downloads
232.35 KB
11 Pages
Last View : 7d ago
Last Download : 3m ago
Upload by : Gannon Casey
Transcription

Pipeline BWBAddPCAddShiftleft moryReadregister 1Readdata 1Readregister 2Readdata 2ALU0WriteregisterWritedataInstr [15 - MemRead0Instr [20 - 16]0Instr [15 - 11]11Our examples are too simpleHere is the example instruction sequence used toillustrate pipelining on the previous pagelwsubandoradd 8, 4( 29) 2, 4, 5 9, 10, 11 16, 17, 18 13, 14, 0The instructions in this example are independent Each instruction reads and writes completely differentregisters Our datapath handles this sequence easilyBut most sequences of instructions are notindependent!21

An example with dependencesRead after Write dependencessubandoraddsw 2, 1, 3 12, 2, 5 13, 6, 2 14, 2, 2 15, 100( 2)Dependences are a property of how thecomputation is expressed3An example with dependencessubandoraddsw 2, 1, 3 12, 2, 5 13, 6, 2 14, 2, 2 15, 100( 2)There are several dependences in this code fragment The first instruction, SUB, stores a value into 2 That register is used as a source in the rest of the instructionsThis is no problem for 1-cycle and multicycle datapaths Each instruction executes completely before the next begins This ensures that instructions 2 through 5 above use the newvalue of 2 (the sub result), just as we expect.How would this code sequence fare in our pipelineddatapath?42

Data hazards in the pipeline diagramsub 2, 1, 32IFIDEX MEM WBIFIDEX MEM WBIFIDEX MEM WBIFIDEX MEM WBIFIDand 12, 2, 5or 13, 6, 23Clock cycle4561add 14, 2, 2sw 15, 100( 2)789EX MEM WBThe SUB does not write to register 2 until clock cycle 5causeing 2 data hazards in our pipelined datapath The AND reads register 2 in cycle 3. Since SUB hasn’tmodified the register yet, this is the old value of 2 Similarly, the OR instruction uses register 2 in cycle 4, again5before it’s actually updated by SUBThings that are okaysub 2, 1, 3and 12, 2, 5or 13, 6, 2add 14, 2, 2sw 15, 100( 2)3Clock cycle4561278IFIDEX MEM WBIFIDEX MEM WBIFIDEX MEM WBIFIDEX MEM WBIFID9EX MEM WBThe ADD is okay, because of the register file design Registers are written at the beginning of a clock cycle The new value will be available by the end of that cycleThe SW is no problem at all, since it reads 2 after theSUB finishes63

One Solution To Data Hazardssubandoraddswsubsllsllandoraddsw 2, 1, 3 12, 2, 5 13, 6, 2 14, 2, 2 15, 100( 2) 2, 1, 3 0, 0, 0 0, 0, 0 12, 2, 5 13, 6, 2 14, 2, 2 15, 100( 2)Since it takes two instruction cycles to get the value stored,one solution is for the assembler to insert no-ops or forcompilers to reorder instructions to do useful work whilethe pipeline proceedsA software solution to data hazards7A fancier pipeline diagram1sub 2, 1, 3and 12, 2, 5or 13, 6, 2add 14, 2, 2sw 15, 100( 2)2IM34RegIMClock Reg84

ForwardingSince the pipeline registers already contain the ALUresult, we could just forward the value to laterinstructions, to prevent data hazards In clock cycle 4, the AND instruction can get the value of 1 3 from the EX/MEM pipeline register used by SUB Then in cycle 5, the OR can get that same result from the MEM/WB pipeline register being used by SUB1sub 2, 1, 3and 12, 2, 5or 13, 6, 22IM3Clock cycle4RegIMDMRegIM56RegDMReg7RegDMReg9Forwarding ImplementationForwarding requires (a) Recognizing when a potential data hazardexists, and(b) Revising the pipeline to introduceforwarding paths We’ll do those revisions next time105

What about stores?Two “easy” cases:add 1, 2, 3sw2IMReg3IMReg123IMReg 4, 0( 1)add 1, 2, 3sw1IM 1, 0( 4)45DMReg6DMReg456DMRegRegDMReg11What about stores?A harder case:lw 1, 0( 2)sw 1, 0( 4)12IMRegIM3Reg45DMRegDM6RegIn what cycle is: The load value available? The store value needed?What do we have to add to the datapath?126

Load/Store Bypassing: Extends Datapath#By cycling the result of Read databack to be the value for Writedata, the combinationSequence :lw 1, 0( 2)sw 1, 0( 4)can operate at normal pipelinespeeds until there is a cachemiss!EX/MEMMEM/WBAddress10DatamemoryWrite Readdata data10ForwardC13Stalls and flushesWe have seen data hazards can occur in pipelined CPUswhen instructions depend upon others still executing Many hazards can be resolved by forwarding data from thepipeline registers, instead of waiting for the writeback stage The pipeline continues running at full speed, with oneinstruction beginning on every clock cycleNow, we’ll see some real limitations of pipelining Forwarding may not work for data hazards from loadinstructions Branches affect the instruction fetch for the next clock cycleIn both of these cases we may need to slow down, orstall, the pipeline147

What about loads?Imagine if the first instruction in the example was LWinstead of SUB The load data doesn’t come from memory until the end ofcycle 4 But the AND needs that value at the beginning of the samecycle!This is a “true” data hazard—the data is simply notavailable when its neededlw 2, 20( 3)12IMRegClock cycle34DMIMand 12, 2, 556RegRegDMReg15StallingThe easiest solution is to stall the pipelineWe can delay the AND instruction by introducing a 1cycle delay in the pipeline, often called a bubble1lw 2, 20( 3)and 12, 2, 52IM3Clock cycle45RegIMDMReg67RegDMRegNotice that we’re still using forwarding in cycle 5, to getdata from the MEM/WB pipeline register to the ALU168

Stalling and forwardingWithout forwarding, we’d have to stall for two cycles towait for the LW instruction’s writeback stage.lw 2, 20( 3)12IMReg3Clock cycle45DMIMand 12, 2, 5678RegRegDMRegIn general, you can always stall to avoid hazards—butdependencies are very common in real code, andstalling will often reduce performance significantly17Stalling delays the entire pipelineIf we delay the 2nd instruction, we must delay the 3rd too This is necessary to make forwarding work between AND andOR It also prevents problems such as two instructions trying towrite to the same register in the same cycle.lw 2, 20( 3)and 12, 2, 5or 13, 12, 212IMRegIM3Clock cycle45DM78RegRegIM6DMRegRegDMReg189

Implementing stallsTo implement a stall we force the two instructions afterLW to remain in their ID & IF stages for 1 extra cyclelw 2, 20( 3)12IMRegIMand 12, 2, 5or 13, 12, 23Clock cycle45DMRegRegIMIM678RegDMRegRegDMRegThis is easily accomplished Don’t update the IF/ID register, so the ID stage is repeated Don’t update the PC, so the current IF stage is repeated19What about EXE, MEM, WBBut what about the ALU during cycle 4, the datamemory in cycle 5, and the register file write in cycleClock cycle6?lw 2, 20( 3)and 12, 2, 5or 13, 12, 212IMRegIM345DMRegRegRegIMIM6DMReg78RegDMRegThose units aren’t used in those cycles because of thestall, so we can set the EX, MEM and WB controlsignals to all 0s the bubble “bubbles” through 2010

Stall Nop conversionlw 2, 20( 3)and - nopand 12, 2, 512IMRegIM3Clock cycle45DMRegIM78RegDMRegIMor6RegDMRegRegDMReg 13, 12, 2The effect of a load stall is to insert an empty ornop instruction into the pipeline2111

Pipeline Review 0 1 Read address Instruction memory Instruction [31-0] Address Write data Data memory Read data MemWrite MemRead 1 0 MemToReg 4 Shift left 2 Add ALUSrc . dependencies are very common in real code, and stalling will often reduce performance significantly IM Reg DM Reg IM Reg DM Reg lw 2, 20( 3) and 12, 2, 5 .

Related Documents:

Pipeline device hardware, Pipeline network, the Pipeline host hardware, the Pipeline application software and the Pipeline media disk storage systems. Each of these components is described below. Pipeline device hardware Pipeline device hardware has up to four independent channels with SDI I/O for capture and play out. The SDI

Page 2 of 22 ODNR‐DSWR Pipeline Standard 12‐3‐13 Pipeline ‐ The pipeline and its related appurtenances. Pipeline Company ‐ The entity responsible for installing the pipeline, its successors, and assigns, on its own behalf and as operator of the company. Right‐of‐Way ‐ Includes the permanent and temporary easements that the pipeline company acquires

Page 2 of 22 ODNR‐DSWR Pipeline Standard 12‐3‐13 Pipeline ‐ The pipeline and its related appurtenances. Pipeline Company ‐ The entity responsible for installing the pipeline, its successors, and assigns, on its own behalf and as operator of the company. Right‐of‐Way ‐ Includes the permanent and temporary easements that the pipeline company acquires

and Hazardous Liquid pipeline risk models. Operators establish risk models to address risk and improve safety within their respective pipeline systems. Pipeline risk models are a foundational part of the assessment of operational pipeline risk. Federal pipeline safety integrity management (IM) regulations require pipeline operators to use risk

Pipeline Conventions DEFINITION: a K-Stage Pipeline(“K-pipeline”) is an acyclic circuit having exactly K registers on everypath from an input to an output. a COMBINATIONAL CIRCUIT is thus an 0-stage pipeline. CONVENTION: Every pipeline stage, hence every K-Stage pipeline, has a register on its OUTPUT(not on its input). ALWAYS:

ONEOK NGL Pipeline, L.L.C. ONEOK Rockies Midstream, LLC Phillips 66 Pipelines LLC Plains Pipeline – Belfield Pipeline Silver Creek Midstream TC Energy / Bison Pipeline Pipeline LLC TC Energy / Northern Border Pipeline Company WBI Energy Midstream WBI Energy Transmission Pipelin

Reauthorized the Pipeline Safety, Regulatory Certainty, and Jobs Creation Act of 2011; reaffirmed mandates of the 2011 act; and established new mandates. Pipeline Safety Improvement Act of 2002 (CFR 192 Subpart O, Pipeline Integrity Management) Strengthened federal pipeline safety programs, state oversight of pipeline operators, and public .

pipeline - it will rise once the pipe starts going up. Page 7 Lesson 4: Pipe Basics - Pipeline Pumps Pump P u m p Pipeline Pump Mk.2 50 m Head Lift (max. 55 m) Pipeline Pump Mk.1 20 m Head Lift (max. 22 m) Pipeline Pumps are attachments that increase the Pressure inside a Pipeline. They don't increase Flow Rate and are not needed on pipelines that