5.2.11 · HinglishProcessor Datapath & Pipelining

Deep pipelining trade-offs

2,337 words11 min readRead in English

5.2.11 · Hardware › Processor Datapath & Pipelining

Deep Pipelining Kya Hai?

Deep kyun jaate hain?
Frequency jahan sabse slow pipeline stage se determine hoti hai. Ek lambi stage ko do chhoti stages mein split karne se reduce ho sakta hai, boost hoti hai.

Kaam kaise karta hai?

  • Logic blocks ke beech additional pipeline registers insert karo
  • Har stage kam combinational work karti hai → shorter critical path
  • Clock tezi se tick kar sakta hai kyunki har stage pehle complete ho jaati hai

Ideal Speedup Model (Aur Yeh Kyun Toot Ta Hai)

Derivation:

  1. Unpipelined: total delay = (sab logic ek cycle mein)
  2. Pipelined: cycle time = (slowest stage + register overhead)
  3. Speedup =
  4. Jab : agar (evenly split karo), speedup register delay se bounded

Yeh kyun important hai: Register overhead bottleneck ban jaata hai. Agar hai, toh stages 10 se 20 double karne par sirf ~10% speedup milta hai, 2× nahi.

Real Trade-offs

1. Pipeline Register Overhead

Yeh gains kyun khatam kar deta hai?

  • 5 stages par: shayad se 10× bada ho → registers ~10% overhead hain
  • 31 stages par (Pentium 4): bahut chhota hai, dominate karta hai → zyada stages add karne se barely kuch fayda

Optimal depth estimate kaise karein:
set karo. Agar total logic ko stages mein split karein: Toh analytically, "deeper is always better" — lekin yeh hazard costs aur power ko ignore karta hai.

2. Pipeline Hazards Non-linearly Scale Karte Hain

Data hazards:

  • Classic 5-stage: RAW stall = forwarding ke saath 1-2 cycles
  • 31-stage: operand 5-10 stages tak ready nahi ho sakta → complex bypassing ya zyada stalls

Control hazards:

  • Branch misprediction penalty = cycles (baad wale sab instructions flush)
  • 5-stage: 4 cycles waste
  • 20-stage: 19 cycles waste — 5× worse

Real impact:
Chahe double ho, agar stalls triple hote hain, throughput drop ho jaata hai.

3. Power aur Complexity

Clock power:
Clock network ko sets of pipeline registers drive karne padte hain. Pentium 4 ke deeply pipelined design mein clock distribution mein 30-40% power lagti thi.

Complexity:

  • Forwarding paths: deep pipelines mein potential bypasses
  • Control logic: 20+ stages mein dependencies track karna
  • Verification: sab hazard cases validate karna exponentially harder

4. Stage Imbalance

Optimal Pipeline Depth: Sweet Spot

10-15 kyun?

  • Itni depth se unpipelined se 2-3× frequency boost milti hai
  • Hazard penalties achhi prediction (95%+ branch accuracy) ke saath manageable rehti hain
  • Register overhead ~10-20% cycle time (tolerable)
  • Common instruction mixes ke liye stage balance achievable

Modern approach:

  • Shallow, wide pipelines (10-14 stages, 4-8 issue width)
  • Raw frequency ki jagah branch prediction, out-of-order execution, large caches mein invest karo
  • Instruction per watt better hota hai

Deep Pipelining Kab Kaam Karta Hai

Embedded/DSP processors:

  • Predictable workloads (few branches)
  • Streaming data (no data hazards)
  • Fixed-function → stages perfectly balance ho sakte hain
  • Example: 40+ stage video codecs

Graphics pipelines:

  • Pixel shaders independent data process karte hain
  • No control hazards (SIMD execution)
  • Depth latency ko throughput ke liye trade karta hai (frame buffers ke liye theek hai)

Inke liye nahi:

  • General-purpose CPUs (unpredictable branches, varied instruction mix)
  • Interactive workloads (latency-sensitive)
Recall Ek 12-saal ke bacche ko samjhao

Socho tum ek factory mein sandwiches bana rahe ho. Pehle, tum sab kuch khud karte ho: bread lo, peanut butter lagao, jelly lagao, kato, wrap karo. Ek sandwich mein 5 minute lagte hain.

Phir tum split karte ho: Person 1 bread laata hai (1 min), Person 2 PB lagaata hai (1 min), Person 3 jelly lagaata hai (1 min), Person 4 kaata hai (1 min), Person 5 wrap karta hai (1 min). Ab har minute ek complete sandwich nikalti hai! Tum 5× fast ho gaye.

Lekin agar 20 logon mein split karo? Person 1 bread ka bag kholega. Person 2 ek slice nikalega. Person 3 use counter par rakhega. Ab tumhe sandwich 20 logon ke beech pass karni padegi, aur hand-off ka time (jaise tray par rakhna aur "next!" chillana) add up ho jaata hai. Aur agar koi sandwich drop kar de (jaise CPU mein ek mistake, jise "branch misprediction" kehte hain), toh tumhe step 1 se restart karna hoga, aur ab 19 log sirf khade hain kuch nahi karte, sirf 4 ki jagah.

Deep pipelining aisa hi hai: zyada workers (stages) tumhe faster bana sakte hain, lekin ek point tak hi. Uske baad, coordination overhead aur mistakes jo cost aati hai woh gain se zyada ho jaati hai.

Connections

  • Instruction Pipelining Basics — foundation for why we pipeline
  • Pipeline Hazards — data/control/structural hazards amplified in deep pipelines
  • Branch Prediction — critical for deep pipelines; misprediction penalty = depth
  • Superscalar Architectures — modern alternative: go wide (multiple issue) instead of deep
  • Clock Distribution and Skew — deeper pipelines need more careful clock tree design
  • Dynamic Voltage and Frequency Scaling (DVFS) — deep pipelines enable higher , but power becomes limiting factor
  • Pentium 4 vs Core Microarchitecture — case study in "deep vs. wide" design philosophy

#flashcards/hardware

Deep pipelining mein fundamental trade-off kya hai? :: Higher clock frequency (zyada stages = shorter critical path) vs. pipeline registers ka increased overhead, worse hazard penalties, aur diminishing returns kyunki register delay cycle time dominate karne lagti hai.

Pipeline register overhead speedup ko eventually kyun limit karta hai?
Har stage fixed delay (setup + clk-to-Q + skew) add karta hai. Jaise stages badhte hain, logic delay shrink hoti hai lekin constant rehti hai. Eventually ho jaata hai, toh zyada stages add karne se cycle time barely reduce hoti hai — tum sirf data registers se guzaar rahe ho.
Branch misprediction penalty pipeline depth ke saath kaise scale karta hai?
Penalty = cycles (branch ke baad pipeline mein sab instructions flush karo). 5-stage pipeline mein, misprediction 4 cycles cost karti hai. 20-stage pipeline mein, 19 cycles cost karti hai — almost 5× worse, jo frequency advantage erase kar sakta hai agar branches frequent hain aur mispredictions rare nahi hain.
Intel Pentium 4 Prescott ke 31-stage pipeline ki key failure kya thi?
~4 GHz achieve karne ke bawajood (high frequency), deep pipeline ki wajah se: (1) 30-cycle branch misprediction penalty, (2) stalls ki wajah se IPC ~1.5 se ~1.0 drop hua, (3) net performance ≈ shallower designs jaisi, (4) power consumption 115W tak spike hua. Frequency gain CPI increase se cancel ho gayi.
General-purpose CPUs ke liye empirically optimal pipeline depth kya hai?
Around 10-15 stages. Yeh balance karta hai: (1) 2-3× frequency boost ke liye enough depth, (2) good branch prediction ke saath manageable hazard penalties, (3) register overhead ~10-20% of cycle time, (4) diverse instruction mix ke liye achievable stage balance. Modern CPUs (jaise Zen, Core) 12-19 stages use karte hain.
Embedded DSP processors kabhi kabhi 40+ stage pipelines successfully kyun use karte hain?
(1) Predictable workloads jisme few/no branches hain → minimal control hazards, (2) streaming data processing → samples ke beech data dependencies nahi, (3) fixed-function logic → stages perfectly balance ho sakti hain, (4) video encoding jaise applications ke liye throughput > latency. General-purpose CPUs mein yeh properties nahi hote.

Concept Map

inserts more

splits work into

shortens

reduces

adds t_reg overhead

raises

drives

bounds as k grows

limits

increases

erodes

ideal formula

Deep Pipelining

Pipeline Registers

Smaller Stages

Critical Path

Cycle Time

Clock Frequency

Pipeline Speedup

Diminishing Returns

Hazard Complexity

k·tau / tau+t_reg