Title | Lesson 3Notes Pipelining |
---|---|
Course | High Perform Comput Arch |
Institution | Georgia Institute of Technology |
Pages | 2 |
File Size | 60.5 KB |
File Type | |
Total Downloads | 74 |
Total Views | 182 |
333...
Pipelining Pipeliningiscrucialtoimprovingperformanceinprocessors;itincreasesthroughputand reducescycletime.Thedownsideofpipelinesaretheincreaseinhazards,bothcontroland data. PipelininginaProcessor Fivestagesinabasicpipeline: Fetch,Read/Decode,ALU,MemoryAccess,WritetheRegisters Pipeliningtheinstructionstakesthesameamountoftime,butthroughputisimproved. PipeliningCPI Ifthereaninstructionhastowaitatapipelinestage,alltheinstructionsaheadofitproceed throughthepipeline,alltheinstructionsbehinditarealsostalled.Thisiscalledadelayinthe pipeline.Thepipelineaheadofthedelaywillnothaveinstructionstoexecuteasthepipeline emptiesandtheinstructionsbehindthedelaywillbestalled. Asthenumberofdelaysincreasethroughthepipeline,theCPIwillincrease. PipelineStallsandFlushes PipelineFlush:Branchescancausebubbleswhentheincorrectbranchistaken.Whenthis happensalltheincorrectinstructionsthatwerefetchedmustbeflushedfromthepipelineand replacedwithNOPs.Thenthecorrectinstructionsmustbefetched. ControlDependencies Controldependencies:Whenaninstructionisdependentontheoutcomeofabranchdecision, theseinstructionsaresaidtohaveacontroldependence. 20%ofinstructionsarebranchesandjumps 50%ofbranchandjumpinstructionsaretaken OverallCPI=CPIofprogram+%ofinstructionsmispredicted*penaltyformisprediction DataDependencies Datadependence:Whenaninstructionneedsdatafromanotherinstructionthatiscalledadata dependence. Typeofdatadependencies: 1.RAWreadafterwrite.AlsocalledFlow,TrueDependence. ThefollowingdependenciesareFalseorNamedependencies. 2.WAWwriteafterwrite.AlsocalledOutputDependence. 3.WARwriteafterread.AlsocalledAntiDependence RARreadafterreadisnotadependence.
DependenciesandHazards Dependenciesarecausedbytheprogram,notthepipeline. Somedependenceswillnotcauseproblems,butsome,likeRAW,cancauseproblemsin pipelines. Hazardsaretruedependenciesthatresultinincorrectexecutionoftheprogram,butnotalltrue dependencieswillresultinahazard.Hazardsarecausedbyboththeprogramandthepipeline. HandlingofHazards Firststeptohandlinghazards:Detectonlythosedependenciesthatwillcausehazards. SecondSteptohandlinghazards:Removethehazard. Optionsforremovinghazardsare: 1.Flushdependentinstructionsoutofthepipeline. Thismethodisusedwithcontroldependencies.Sincethe wrongvalueisinthepipelineitneedstobeflushed. 2.Stalldependentinstructionsinthepipeline. Thismethodisusedfordatadependencies.Thiswillgivethe datatimetogetwrittentoregistersbeforeitisneededbyalater instruction. 3.Fixthevaluesreadbydependentinstructions. Thismethodisalsousedfordatadependencies.Insteadof stallingtheinstructionuntilthecorrectvaluesareintheregisters, thepipelinecanforwardtherequiredvalues.Thevaluesfroman ALUforexamplecanbeusedassoonastheycomputed,rather thanwaiting. Thismethoddoesnotalwayswork. HowManyStages EverypipelineshouldbeachievingtherequiredCPI,itisdifferentforeverypipeline. Whenmorestagesareaddedtoapipeline: 1.Therearemorehazardsintroducedintothepipeline. 2.Thepenaltyforhazardsincreases. 3.Thereislessworkforeachstage,sothecycletimecanbesmaller. TheIronLawofPerformancesays: ThenumberofstagesmustbebalancedbetweentheCPIandthecycletime. Ifonlyperformanceisconsidered,3040stagesisideal.Butifpowerconsumptionisalso considered,theidealpipelineis1015stages. ...