1 / 21

Introduction to Pipelining

Introduction to Pipelining. Adapted from the lecture notes of Dr. John Kubiatowicz (UC Berkeley). A. B. C. D. Pipelining is Natural!. Laundry Example Ann, Brian, Cathy, Dave each have one load of clothes to wash, dry, and fold Washer takes 30 minutes Dryer takes 40 minutes

dianne
Download Presentation

Introduction to Pipelining

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Pipelining Adapted from the lecture notes of Dr. John Kubiatowicz (UC Berkeley)

  2. A B C D Pipelining is Natural! • Laundry Example • Ann, Brian, Cathy, Dave each have one load of clothes to wash, dry, and fold • Washer takes 30 minutes • Dryer takes 40 minutes • “Folder” takes 20 minutes

  3. A B C D Sequential Laundry 6 PM Midnight 7 8 9 11 10 Time • Sequential laundry takes 6 hours for 4 loads 30 40 20 30 40 20 30 40 20 30 40 20 T a s k O r d e r

  4. 30 40 40 40 40 20 A B C D Pipelined Laundry: Start work ASAP 6 PM Midnight 7 8 9 11 10 Time • Pipelined laundry takes 3.5 hours for 4 loads T a s k O r d e r

  5. 30 40 40 40 40 20 A B C D Pipelining Lessons • Latency vs. Throughput • Question • What is the latency in both cases ? • What is the throughput in both cases ? Pipelining doesn’t help latency of single task, it helps throughput of entire workload

  6. 30 40 40 40 40 20 A B C D Pipelining Lessons [contd…] • Question • What is the fastest operation in the example ? • What is the slowest operation in the example Pipeline rate limited by slowest pipeline stage

  7. 30 40 40 40 40 20 A B C D Pipelining Lessons [contd…] Multiple tasks operating simultaneously using different resources

  8. 30 40 40 40 40 20 A B C D Pipelining Lessons [contd…] • Question • Would the speedup increase if we had more steps ? Potential Speedup = Number of pipe stages

  9. Pipelining Lessons [contd…] • Washer takes 30 minutes • Dryer takes 40 minutes • “Folder” takes 20 minutes • Question • Will it affect if “Folder” also took 40 minutes Unbalanced lengths of pipe stages reduces speedup

  10. 30 40 40 40 40 20 A B C D Pipelining Lessons [contd…] Time to “fill” pipeline and time to “drain” it reduces speedup

  11. Ifetch Reg/Dec Exec Mem Wr Five Stages of an Instruction Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 • Ifetch: Instruction Fetch • Fetch the instruction from the Instruction Memory • Reg/Dec: Registers Fetch and Instruction Decode • Exec: Calculate the memory address • Mem: Read the data from the Data Memory • Wr: Write the data back to the register file Load

  12. IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB Conventional Pipelined Execution Representation Time Program Flow

  13. Example

  14. Example [contd…] • Timepipeline = Timenon-pipeline / Pipe stages • Assumptions • Stages are perfectly balanced • Ideal conditions

  15. performance(x) = 1 execution_time(x) Performance(X) Execution_time(Y) n = = Performance(Y) Execution_time(X) Definitions • Performance is in units of things per sec • bigger is better • If we are primarily concerned with response time " X is n times faster than Y" means

  16. Example [contd…] • Speedup in this case = 24/14 = 1.7 • Lets add 1000 more instructions • Time (non-pipelined) = 1000 x 8 + 24 ns = 8000 ns • Time (pipelined) = 1000 x 2 + 14 ns = 2014 ns • Speedup = 8000 / 2014 = 3.98 = 4 (approx) = 8/2 Instruction throughput is important metric (as opposed to individual instruction) as real programs execute billions of instructions in practical case !!!

  17. IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB IFetch Dcd Exec Mem WB Pipeline Hazards • Structural Hazard Program Flow

  18. Pipeline Hazard [contd…] • Control Hazard • Example • add $4, $5, $6 • beq $1, $2, 40 • lw $3, 300($0)

  19. Pipleline Hazard [contd…] • Data Hazards • Example • add $s0, $t0, $t1 • sub $t2, $s0, $t3

  20. 30 40 40 40 40 20 A B C D Summary Pipelining Lessons 6 PM 7 8 9 • Pipelining doesn’t help latency of single task, it helps throughput of entire workload • Pipeline rate limited by slowest pipeline stage • Multiple tasks operating simultaneously using different resources • Potential speedup = Number pipe stages • Unbalanced lengths of pipe stages reduces speedup • Time to “fill” pipeline and time to “drain” it reduces speedup • Stall for Dependences Time T a s k O r d e r

  21. Summary of Pipeline Hazards • Structural Hazards • Hardware design • Control Hazard • Decision based on results • Data Hazard • Data Dependency

More Related