29 May - COA - Pipelining Part - 3

Duration: 1 hr 17 min

This video lesson is available to enrolled students.

Enroll to watch — GATE Guidance by Sanchit Sir

AI Summary

An AI-generated summary of this video lecture.

This lecture focuses on data hazards in pipelined processors, specifically analyzing Read-After-Write (RAW) dependencies and their impact on execution time. The instructor uses a series of GATE exam problems (2007, 2010, 2015, 2021) to demonstrate how to construct pipeline diagrams, identify stalls caused by data dependencies, and calculate total clock cycles. Key concepts include operand forwarding, stage latencies for different instruction types (ADD, SUB, MUL, DIV), and the calculation of speedup when comparing execution with and without forwarding mechanisms.

Chapters

  1. 0:00 2:00 00:00-02:00

    The video begins with a title card for 'Sanchit Jain' before transitioning to a slide titled 'Data Hazards'. The slide defines data hazards as occurring when instructions with data dependence modify data in different pipeline stages, causing delays. An example sequence of four instructions (I0: MUL, I1: DIV, I2: ADD, I3: SUB) is presented to illustrate these dependencies.

  2. 2:00 5:00 02:00-05:00

    The instructor analyzes the example instructions to identify data dependencies. He underlines registers to show that I0 writes to R2, I1 reads R3/R4 and writes R5, I2 reads R5/R2 and writes R2, and I3 reads R2/R6 and writes R5. This highlights that I2 depends on results from both I0 and I1, while I3 depends on results from I2 and I1, creating potential RAW hazards.

  3. 5:00 10:00 05:00-10:00

    A problem from Gate 2010 is introduced. It describes a 5-stage pipelined processor (IF, ID, OF, PO, WO). The problem specifies that IF, ID, OF, and WO stages take 1 clock cycle each. The PO stage takes 1 cycle for ADD/SUB, 3 for MUL, and 6 for DIV. Operand forwarding is used. The goal is to find the total clock cycles for the instruction sequence.

  4. 10:00 15:00 10:00-15:00

    The instructor begins drawing the pipeline diagram for the Gate 2010 problem. He fills in the stages for the first instruction (I0: MUL), placing IF at cycle 1, ID at 2, OF at 3, PO at cycles 4-6, and WO at 7. He then starts the second instruction (I1: DIV), placing IF at 2, ID at 3, and OF at 4.

  5. 15:00 20:00 15:00-20:00

    Continuing the Gate 2010 solution, the instructor fills the PO stage for I1 (DIV) across cycles 5-10 and WO at 11. He then starts I2 (ADD) at IF cycle 3. He identifies that I2 needs R5 (from I1) and R2 (from I0). Since I1 produces R5 at the end of PO (cycle 10) and I2 needs it at OF (cycle 5), he considers forwarding.

  6. 20:00 25:00 20:00-25:00

    The instructor calculates stalls for I2 and I3 in the Gate 2010 problem. He marks 'X' for stalls where forwarding is not sufficient or needed. He determines that I2 can forward R5 from I1's PO stage. He fills the table for I3 (SUB) and calculates the total cycles required to complete the sequence, arriving at the answer 17.

  7. 25:00 30:00 25:00-30:00

    A new problem from Gate 2015 is presented. It involves a 4-stage pipeline (IF, OF, PO, WB). Latencies are: IF, OF, WB take 1 cycle. PO takes 1 for ADD/SUB, 3 for MUL, and 5 for DIV. Operand forwarding is from PO to OF. The instruction sequence is MUL, DIV, ADD, SUB.

  8. 30:00 35:00 30:00-35:00

    The instructor draws the pipeline for the Gate 2015 problem. He places I0 (MUL) in IF(1), OF(2), PO(3-5), WB(6). He places I1 (DIV) in IF(2), OF(3), PO(4-8), WB(9). He notes that I1 reads R0, which is written by I0.

  9. 35:00 40:00 35:00-40:00

    Analyzing dependencies for Gate 2015, the instructor notes that I1 needs R0 from I0. I0 produces R0 at the end of PO (cycle 5). I1 needs it at OF (cycle 3). Since forwarding is from PO to OF, he checks if the data is available. He marks stalls where necessary to resolve the hazard.

  10. 40:00 45:00 40:00-45:00

    The instructor completes the pipeline diagram for Gate 2015. He fills in I2 (ADD) and I3 (SUB), accounting for dependencies on previous results. He calculates the total cycles required, determining the answer is 13. He emphasizes the role of operand forwarding in reducing stalls.

  11. 45:00 50:00 45:00-50:00

    The lecture moves to a Gate 2007 problem. The processor has 4 stages: IF, ID (Instruction Decode and Operand Fetch), EX (Execute), WB (Write Back). Latencies: IF, ID, WB take 1 cycle. EX takes 1 for ADD/SUB and 3 for MUL. Operand forwarding is used.

  12. 50:00 55:00 50:00-55:00

    The instructor draws the pipeline for Gate 2007. I0 (ADD) is placed in IF(1), ID(2), EX(3), WB(4). I1 (MUL) is placed in IF(2), ID(3), EX(4-6), WB(7). He identifies that I1 reads R0, which is written by I0.

  13. 55:00 60:00 55:00-60:00

    For Gate 2007, the instructor analyzes the dependency between I0 and I1. I0 writes R0 at the end of EX (cycle 3). I1 needs R0 at ID (cycle 3). Since forwarding is from EX to ID, the data is available immediately. He marks the pipeline without stalls for this dependency.

  14. 60:00 65:00 60:00-65:00

    The instructor completes the Gate 2007 solution by filling in I2 (SUB). He calculates the total cycles required to execute the sequence. He determines the answer is 10, highlighting how efficient forwarding can minimize pipeline bubbles.

  15. 65:00 70:00 65:00-70:00

    A Gate 2021 problem is introduced. It involves a 5-stage pipeline (IF, ID, EX, MEM, WB). Latencies: IF, ID, MEM, WB take 1 cycle. EX takes 1 for ADD and 2 for MUL. Operand forwarding is used. The instruction sequence is ADD, MUL, ADD, MUL, ADD, MUL, ADD, MUL.

  16. 70:00 75:00 70:00-75:00

    The instructor calculates the execution time without operand forwarding. He draws the pipeline, inserting stalls (bubbles) wherever a data dependency exists and forwarding is not available. He counts the total cycles for this scenario.

  17. 75:00 77:07 75:00-77:07

    Finally, the instructor calculates the execution time with operand forwarding. He redraws the pipeline, removing the stalls that were previously necessary due to forwarding. He computes the speedup as the ratio of execution time without forwarding to execution time with forwarding, arriving at the final answer.

The lecture systematically builds understanding of pipeline hazards by progressing through increasingly complex GATE problems. It starts with a theoretical definition of data hazards, then applies this to specific instruction sequences. The instructor demonstrates how to map instructions to pipeline stages, accounting for varying latencies of the Perform Operation (PO) or Execute (EX) stage. A critical theme is the impact of operand forwarding; by forwarding results from the execution stage to the operand fetch stage, the instructor shows how stalls can be eliminated, significantly reducing total execution time. The final problem reinforces this by explicitly calculating speedup, comparing the performance with and without forwarding mechanisms.