5.3.13 · HinglishAdvanced Microarchitecture

VLIW architectures

3,176 words14 min readRead in English

5.3.13 · Hardware › Advanced Microarchitecture

VLIW Kya Hai?

VLIW Kyun? Design Philosophy

Traditional superscalar processors complex hardware logic use karte hain:

  • Out-of-order execution engines jo runtime pe parallelism dhundhe
  • Register renaming logic jo false dependencies eliminate kare
  • Reservation stations aur reorder buffers jo in-flight instructions track kare
  • Wakeup/select logic jo significant power aur area consume kare

VLIW kehta hai: "Kya ho agar hum yeh saari complexity compiler mein shift kar dein?"

YEH trade-off kyun sense karta hai:

  1. Compile-time analysis ke paas unlimited time aur global code visibility hoti hai
  2. Hardware complexity issue width ke saath super-linearly badhti hai (bahut saari structures ke liye O(n²))
  3. Dynamic scheduling hardware ki power consumption substantial hoti hai
  4. Simple hardware → lower power, higher clock speeds, aasaan verification

VLIW Instruction Format

Fixed slots kyun? Hardware operations ko functional units tak simple combinational logic se decode aur route kar sakta hai—koi complex dependency matrices ya dynamic dispatch logic ki zaroorat nahi.

Code Density Impact Derive Karna

Agar hamare paas ek VLIW machine hai jisme operation slots per instruction hain:

Best case (full parallelism): operations per instruction word Worst case (no parallelism): 1 real operation + NOPs per instruction word

Sequential RISC ke comparison mein code density efficiency:

Jahan:

  • = average operations per VLIW instruction (1 ≤ k ≤ n)
  • = bits per RISC instruction (~32 bits)
  • = bits per VLIW instruction (, typically 128-512 bits)

Yeh kyun matter karta hai: Agar parallelism kam hai, toh tum NOPs ka code size cost toh pay karte ho lekin sequential performance milti hai. VLIW ka success poori tarah compiler ki parallelism dhundhne ki ability pe depend karta hai.

Compiler Ki Role: Static Scheduling

VLIW compiler ko sophisticated analysis perform karni padti hai:

1. Dependency Analysis

Data dependencies:

  • RAW (Read After Write): True dependency, order preserve karna zaroori hai
  • WAR (Write After Read): Anti-dependency, register renaming se eliminate ho sakti hai
  • WAW (Write After Write): Output dependency, register renaming se eliminate ho sakti hai

Compiler yeh kyun handle karta hai: Superscalar processors mein, hardware register renaming WAR/WAW eliminate karta hai. VLIW mein, compiler ko scheduling ke dauran khud registers rename karne padte hain.

2. Software Pipelining (Modulo Scheduling)

VLIW loop performance ke liye sabse powerful technique:

Traditional loop execution (sequential):

Iteration 1: [Load A] → [Compute] → [Store]
Iteration 2:                          [Load A] → [Compute] → [Store]  
Iteration 3:                                [Load A] → ...

Software pipelined (overlapped):

Prologue:    [Load A for iter 1]
Steady:      [Load A for iter 2] [Compute iter 1] [Store iter 0]
             [Load A for iter 3] [Compute iter 2] [Store iter 1]
             [Load A for iter 4] [Compute iter 3] [Store iter 2]
Epilogue:                [Compute iter n] [Store iter n-1]
                                [Store iter n]

Yeh kyun kaam karta hai: Alag iterations ek hi instruction cycle ke andar alag pipeline stages occupy karti hain, functional unit utilization maximize hoti hai.

3. Predication

VLIW architectures branches eliminate karne ke liye heavily predication (conditional execution) use karte hain:

Iske bajaaye:

if (x > 0)
    a = b + c;
else
    a = b - c;

VLIW with predication:

cmp.gt p1,p2 = x,0           // p1 = (x>0), p2 = !(x>0)
(p1) add a = b, c            // execute if p1 is true
(p2) sub a = b, c            // execute if p2 is true

Predication VLIW ke liye kyun critical hai:

  • Branches software pipelining rokti hain (conditional boundaries ke across iterations overlap nahi ho sakti)
  • Branch mispredictions expensive hain (koi speculative execution hardware nahi)
  • Predication control dependencies ko data dependencies mein convert karta hai, zyada parallelism enable karta hai

VLIW vs. Superscalar: Trade-offs

Aspect VLIW Superscalar
Parallelism discovery Compile-time (static) Run-time (dynamic)
Hardware complexity Kam (simple dispatch) Zyada (OoO engines)
Power efficiency Better (no speculation) Worse (speculation overhead)
Code portability Poor (ISA tied to # units) Good (HW adapts)
Code size Bada (NOPs when low ILP) Chhota (dense encoding)
Performance on irregular code Poor Better (dynamic adaptation)
Compiler burden Extreme Moderate

VLIW general-purpose CPUs mein kyun struggle kiya: "VLIW dilemma": Future performance ke liye zyada functional units add karne ke liye ISA change karna padta hai (zyada operation slots), backward compatibility break hoti hai. Intel Itanium ne explicit parallelism bits aur predication se isko solve karne ki koshish ki, lekin compiler technology general-purpose code mein consistently enough ILP nahi dhundh paaya.

VLIW kahaan succeed kiya:

  • DSPs (Texas Instruments C6x): Signal processing mein abundant data parallelism hoti hai
  • Embedded media processors: Jahan code ek specific processor ke liye ek baar compile hota hai
  • Kuch GPU shader cores (historical, jaise AMD TeraScale VLIW5/VLIW4): In early GPUs ne genuinely VLIW bundles mein independent operations pack kiye. Note: modern GPUs largely VLIW se door ja chuke hain aur scalar SIMT designs mein shift ho gaye hain (neeche mistake dekho).

Memory Disambiguation: The Achilles Heel

Socho:

for (i = 0; i < N; i++) {
    a[i] = b[i] + c[i];
    d[i] = e[i] * f[i];
}

Compiler do independent statements dekhta hai aur parallel execute karna chahta hai. Lekin kya ho agar a aur e memory mein overlap karein? a[i] ko store karna e[i] se load ko affect kar sakta hai.

Superscalar mein: Hardware runtime pe memory disambiguation perform karta hai, dynamically aliasing detect karta hai.

VLIW mein: Compiler ko ya toh:

  1. Static analysis ke through independence prove karna hoga (pointers ke saath often impossible)
  2. Runtime checks insert karne honge (simplicity advantage khatam)
  3. Independence assume karni hogi aur incorrect execution ka risk lena hoga

Yeh VLIW ko kyun limit karta hai: Memory aliasing general mein undecidable hai. Conservative assumptions parallelism khatam karte hain; aggressive assumptions bugs ka risk rakhte hain.

Recall Feynman Explan

Concept Map

motivates shift to

delegates scheduling to

performs

produces

packed into

each targets

padded with

allows

advance via

yields

Superscalar complexity

VLIW architecture

Compiler

Static scheduling

Explicit parallelism

Operation slots per word

Multiple functional units

NOP fills empty slots

No hardware interlocks

Lock-step execution

Simpler HW, lower power, higher clock