pipeline: overlapping stages of different instructions; throughput: how much work finishes in a given time
55-minute lesson sequence
0–5 · Retrieve CU.
5–15 · Model CPU/GPU task division and the first two pipeline rows.
15–25 · Guide the cycle axes and ask students to place the third instruction.
25–45 · Complete the timing comparison and the two workload choices independently.
45–50 · Discuss one dependency and one transfer cost.
50–55 · Collect the pipeline versus cores explanation; assign homework.
See it
Each instruction still passes through all four stages. The saving comes from overlap: a new instruction starts every cycle while earlier ones are still moving through.
Watch
Watch the sections on pipelining and multiple cores, and listen for why dependencies and branches slow a pipeline down.
Advanced CPU Designs: Crash Course Computer Science #9CrashCourse
The video is on YouTube, which needs a VPN on most networks in mainland China. It is extra: the lesson works without it.
Try before notes
Which part coordinates CPU operations?
Build the idea
Pipelining overlaps stages of different instructions. It improves the rate at which instructions finish when stages can stay busy. It does not mean each instruction skips stages or becomes instantaneous.
For k equal-length stages and n independent instructions, an ideal filled pipeline takes k+n−1 cycles. This assumes no stalls, no hazards and one new instruction starting each cycle. A non-overlapped model takes k×n.
A GPU suits many similar operations that can run in parallel. A CPU suits flexible control and mixed work. Data transfer, dependencies and branching can reduce the advantage of parallel hardware.
cycle: 1 2 3 4 5 6
I1: F D E W
I2: F D E W
I3: F D E W
See the method
A CPU is designed for flexible general work and low-latency control. A GPU offers many execution lanes for suitable parallel work. They often divide a task and move data between their memories. In an ideal four-stage pipeline F,D,E,W, instruction 1 uses cycles 1–4. Instruction 2 starts F at cycle 2 and finishes W at cycle 5. W means write-back.
Predict then reveal
Three independent instructions use four stages. How many ideal cycles, and how many without overlap?
Reveal reasoning
The last instruction starts at cycle 3 and finishes at cycle 6. Ideal total=4+3−1=6 cycles. Without overlap=4×3=12. Each instruction still uses four stages.
A pipeline has empty stages because instruction 2 needs a result not ready from instruction 1. Why not claim the ideal total?
Reveal reasoning
The dependency may cause a stall unless the architecture resolves it in time. A stall adds cycles. The ideal formula assumes no such delays, so it is a lower-bound model for this situation, not a measured guarantee.
Work one step together
Read the first task. Each learner predicts the first step privately. Compare the method, then complete one intermediate row or one code iteration together. Do not display a finished workbook answer.
Practice
Draw four rows for four independent instructions. Place F,D,E,W across clock cycles. How many cycles finish all four in the ideal pipeline? Compare with a non-overlapped four-cycle-per-instruction model.
Your turn
Complete the remaining steps of task 1 alone, then the next tasks. Predict before running code. Save your own evidence before comparing.
Practice
Draw four rows for four independent instructions. Place F,D,E,W across clock cycles. How many cycles finish all four in the ideal pipeline? Compare with a non-overlapped four-cycle-per-instruction model.
Choose CPU, GPU or both for a branch-heavy control app and for applying the same operation to a million image pixels. Explain data transfer, workload and power-efficiency limits.
Check and explain
Pipelining overlaps stages; multiple cores provide separate execution resources. They are not the same mechanism.
Point to the first step, row, condition or requirement that supports your answer. If results differ, find the first different state and repair one cause.
Show what you know
How is pipelining different from adding more cores?
HL challenge when ready
If instruction 2 needs instruction 1’s result, why can the ideal schedule fail?
Week 3 homework
Show working. Keep code and output. Stop at 25 minutes and mark where you reached.
In the toy machine PC=4. Memory 4 contains LOAD 20 and memory 20 holds 9. Trace the fetch and execute.
Explain why cache, RAM and SSD are not interchangeable. Use one job for each.
Six independent instructions use F,D,E,W with no stalls. Find the ideal cycles and compare with no overlap. Write ideal_cycles(n) in Python for n >= 1. Test n = 1, 4 and 6.
Retrieve logic: simplify (A AND B) OR (A AND NOT B). Give one proof step.
Spend about 3 minutes on each during practice time. Predict, run, change one thing, then explain. These prompts do not add homework.
A starter is runnable code to explore or complete. If the playground restores your saved code, the linked starter is selected in Example: use Load example when ready. Download your work before confirming replacement.
Prompt 1
Compare a sequential timing model with an ideal three-stage pipeline.
No imports needed.
Hint and starter code
A pipeline overlaps stages of different items. This ideal model assumes equal stage times and no stalls.
# A pipeline overlaps stages of different items.
items, stages, stage_time = 5, 3, 1
print(items * stages * stage_time)
print((stages + items - 1) * stage_time)
Apply the same operation to each pixel value. Explain why independent items can suit parallel processing.
No imports needed.
Hint and starter code
This Python loop is sequential; it illustrates independent work, not actual GPU execution.
# This Python loop is sequential; it illustrates independent work, not actual GPU execution.
pixels = [20, 80, 200]
for value in pixels:
print(min(255, value + 10))