DOC PREVIEW
Princeton COS 217 - Pipelining

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1PipeliningCS217InstructionProcessingSteps• Instructionfetch: Fetchanddecodeinstruction,retrieveoperandsfromregisters• Execute: Executearithmeticinstruction,computebranchtargetaddress,computeload/storememoryaddress• Memoryaccess: Accessmemoryforloadorstore,Fetchinstructionattargetofbranch• Storeresults: Writeinstructionresultstoregisters2PipeliningFetch Execute Memory StoreFetch Execute Memory StoreFetch Execute Memory StoreFetch Execute Memory Storeadd%i1,%i1,%o1add%i1,%o1,%o1sub%o1,3,%o1add%o1,%i2,%o112162024PC nPC1216162020242428PipelinedLoadInstructions• Problem:loadfollowedbyuseld[%o0],%o1F E M WF E M WF E M Wadd%o1,%o2,%o2ld[%o0],%o1F E M WF E M Wadd%o1,%o2,%o2loaddelayslotLoaddelayslotsareinsertedautomatically3PipelinedBranchInstructions• Problem:instructionafterbranchcmp%o0,%o1F E M WF E M WF E M WbleL1mov%o0,%o1L1:add%o0,%o0,%o0F E M WF E M WF E M WbranchdelayslotF E M Wcmp%o0,%o1bleL1mov%o0,%o1L1:add%o0,%o0,%o0F E M WUpdatingtheProgramCounter• FetchinstructionataddressstoredinnPCMostinstructions: nPC =PC+4Branchinstructions: nPC iscomputedinexecutestage• ExecuteinstructionataddressstoredinPCAfterexecute:PC=nPCPC nPC12161620203636404044cmp a,bble L1nopmov a,cba L2nopL1: mov b,cL2:...12162024283236404DelaySlots• Oneoption:usenop inalldelayslotsfor(i=0;i<n;i++)...#definei%l0#definen%l1clr iL1: cmp i,nbge L2; nop...inciba L1; nopDelaySlots• Optimizingcompilerstrytoavoiddelayslotsfor(i=0;i<n;i++)...#definei%l0#definen%l1clr iL1: cmp i,nbge L2; nop...inciba L1; nop#definei%l0#definen%l1clr iba L2;nopL1:...inciL2: cmp i,nbl L1; nop5DelaySlots• Optimizingcompilerstrytofilldelayslotsif(a>b)c=a;elsec=b;cmp a,b cmp a,bble L1;bleL1nopmovb,cmov a,c mova,cba L2;L1:…nopL1:movb,cL2:...PipelinedBranchInstructions• Problem:instructionafterbranchcmp%o0,%o1F E M WF E M WF E M WbleL1mov%o0,%o1L1:add%o0,%o0,%o0F E M WF E M WF E M WbranchdelayslotF E M Wcmp%o0,%o1bleL1mov%o0,%o1L1:add%o0,%o0,%o0F E M W6PipelinedBranchInstructions• Problem:instructionafterbranchcmp%o0,%o1F E M WF E M WF E M WbleL1mov%o0,%o1L1:add%o0,%o0,%o0F E M WF E M WF E M WF E M Wcmp%o0,%o1bleL1mov%o0,%o1L1:add%o0,%o0,%o0F E M WProgrammershouldtrytoinsertindependentinstructionsinbranchdelayslotsAnnulBit• Controlstheexecutionofthedelay-slotinstructionbg,aL1mova,cthe,a causesthemov instructiontobeexecutedifthebranchistaken,andnotexecutedifthebranchisnottaken• Exceptionba,aL doesnot executethedelay-slotinstruction7AnnulBit(cont)• Optimizedfor(i=0;i<n;i++)1;2;…;nclri clribaL2 ba,aL2L1:1 L1:22 ......nninciinciL2:cmpi,nL2:cmp i,n bl,aL1blL1 1nopWhile-LoopExamplewhile(...){stmt1:stmtn}test:cmp...bx donenopstmt1:stmtnbatestnopdone:...3instr2instr8While-Loop(cont)• Movetesttoendoflooptest: cmp ...bx donenoploop:stmt1:stmtncmp ...bnx loopnopdone:...• Eliminatefirsttestbatestnoploop:stmt1:stmtntest: cmp ...bnx loopnop...While-Loop(cont)• Eliminatethe nop intheloopbatestnoploop:stmt2:stmtntest: cmp ...bnx,aloopstmt1...now2overheadinstructionsperloop9If-Then-ElseExampleif(...){t-stmt1:t-stmtn}else{e-stmt1:e-stmtm}Howoptimize?cmp ...bnxelsenopt-stmt1:t-stmtnbanextnopelse:e-stmt1e-stmt2:e-stmtmnext:...If-Then-ElseExampleif(...){t-stmt1:t-stmtn}else{e-stmt1:e-stmtm}Howoptimize?cmp ...bnx,a elsee-stmt1t-stmt1:t-stmtnbanextnopelse:e-stmt2:e-stmtmnext:...10If-Then-ElseExampleif(...){t-stmt1:t-stmtn}else{e-stmt1:e-stmtm}Howoptimize?cmp ...bnx,aelsee-stmt1t-stmt1:ba


View Full Document

Princeton COS 217 - Pipelining

Documents in this Course
Summary

Summary

4 pages

Lecture

Lecture

4 pages

Generics

Generics

14 pages

Generics

Generics

16 pages

Lecture

Lecture

20 pages

Debugging

Debugging

35 pages

Types

Types

7 pages

Lecture

Lecture

21 pages

Assembler

Assembler

16 pages

Lecture

Lecture

20 pages

Lecture

Lecture

39 pages

Testing

Testing

44 pages

Pipeline

Pipeline

19 pages

Lecture

Lecture

6 pages

Signals

Signals

67 pages

Building

Building

17 pages

Lecture

Lecture

7 pages

Modules

Modules

12 pages

Generics

Generics

16 pages

Testing

Testing

22 pages

Signals

Signals

34 pages

Lecture

Lecture

19 pages

Load more
Download Pipelining
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Pipelining and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Pipelining 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?