Exercises — VLIW architectures
5.3.13 · D4· Hardware › Advanced Microarchitecture › VLIW architectures
Shuru karne se pehle, ek picture hai jo poori page mein reuse hone wali vocabulary fix kar deti hai. Yeh poori page ke liye hai, lekin Level 1 mein sabse directly reference hoti hai.

Upar ki figure kya dikhati hai (Level 1 mein use hoti hai): ek row mein chaar boxes hain — ek VLIW instruction word ke chaar slots — jiske upar ek bracket hai jisme likha hai "one instruction word = one cycle." Memory slot (Slot 2) red mein drawn hai kyunki yahi woh single port hai jo almost har problem mein bottleneck ban jaata hai. Jab bhi solution kehta hai "only one memory op per cycle," yahi picture dimag mein rakho: red box mein zyada se zyada ek load ya store dala ja sakta hai har row mein.
Levels 2–5 kuch loop-scheduling terms par rely karti hain. Hum unhe sabko ek baar, yahan, plain words mein define karte hain, kisi bhi problem mein use hone se pehle.
Level 1 — Recognition
L1-Q1
Ek superscalar aur ek VLIW processor dono 4 operations per cycle issue karte hain. Kaunsa hardware contain karta hai jo runtime par discover karta hai ki kaunse operations independent hain?
Recall Solution
Superscalar. Uska out-of-order engine (wakeup/select, reservation stations, register renaming) har cycle mein hardware mein parallelism dhundta hai. VLIW us kaam ko compiler par push karta hai, isliye VLIW hardware sirf pre-packed word execute karta hai bina runtime dependency checking ke.
L1-Q2
Humare 4-slot machine mein, ek single instruction word mein kitne memory (load/store) operations ho sakte hain? Kyun?
Recall Solution
Exactly ek. Ek hi memory port hai (Slot 2). Ek cycle mein do loads ke liye do ports chahiye hote jo hardware ke paas nahi hain, isliye compiler unhe saath pack karne se forbidden hai. (Yeh exactly page ke top par figure mein red box hai.)
L1-Q3
Blank fill karo: VLIW mein, agar compiler kisi slot ke liye parallel kaam nahi dhundh pata, toh use wahan NOP rakhna padta hai.
Recall Solution
Ek NOP. Slot fixed-width word mein exist karta rehta hai, isliye idle slots explicitly spell out kiye jaate hain. Yahi wajah hai ki low-parallelism code bits waste karta hai.
Level 2 — Application
L2-Q1
Humare 4-slot machine par parent note ka dependent Fibonacci-style body run hota hai, 3 instruction words mein 3 real operations ke saath scheduled. Slot utilisation compute karo.
Recall Solution
Total slots used .
Real operations .
Chain temp = fib, fib = fib + prev, prev = temp fully serial hai, isliye har row mein sirf ek slot kabhi busy ho sakta hai.
L2-Q2
Ek loop body ko 6 memory operations chahiye aur machine mein 1 memory port hai. Recurrences ignore karte hue, resource-constrained minimum initiation interval kya hai? (Vocabulary box se yaad karo: = uses per iteration, = copies of resource, aur .)
Recall Solution
Yahan busy resource sirf memory hai, isliye (chhe memory ops per iteration) aur (ek port): Ek port se chhe memory operations simply chhe cycles lete hain, chahe ALU slots kitne bhi idle kyun na baithe hon.
L2-Q3
Ek VLIW word 128 bits ka hai (4 slots × 32 bits). Ek 100-operation program aise VLIW words mein compile hota hai jo average 40% full hain — matlab har word average mein real operations carry karta hai, jahan average number of real (non-NOP) operations packed per instruction word hai (toh ). Kitne VLIW instruction words emit hote hain, aur kitne bits of NOP waste hote hain?
Recall Solution
real operations per word ke saath, words needed words. Total slots ; real ops ; NOP slots . Wasted bits bits. Emitted code ka aadha se zyada NOP hai — classic VLIW code-bloat penalty.
Level 3 — Analysis
L3-Q1
Humare loop body mein issue hote hain: 4 memory ops, 5 integer ALU ops, 1 branch. Machine: 1 memory port (), 2 integer ALUs (), 1 branch/FP unit (). dhundho aur bottleneck resource ka naam batao.
Recall Solution
Har resource ke liye evaluate karo ( = uses per iteration, = copies available):
- Memory:
- Integer ALU:
- Branch/FP: Memory port bottleneck hai. Chahe ALU ops total mein zyada hain, do ALUs load share karte hain, jabki ek port ko charon accesses serialise karne padte hain.
L3-Q2
Isi loop mein ek dependency cycle hai: ek store-to-load recurrence jiska total latency cycles hai aur iterations span karta hai — matlab is iteration ka ek load ek aisi value chahiye hai jo ek store ne do iterations pehle produce ki thi, isliye feedback 2 iterations tak jaati hai. L3-Q1 ke saath combine karke true nikalo.
Recall Solution
Recurrence bound (vocabulary box se: = feedback loop mein ek baar ghoomne ke cycles, = kitni iterations peeche jaata hai): Intuition: 6 cycles ka kaam 2 iterations mein spread hota hai, matlab kam se kam 3 cycles har iteration start ke beech hone chahiye. Overall, apply karte hue: Resources abhi bhi dominate karte hain; recurrence, 3 par, binding constraint nahi hai yahan.
Do floors aur woh kaise compete karte hain neeche dikhaya gaya hai (yeh figure L3-Q2 ko support karta hai).

Upar ki figure kya dikhati hai (L3-Q2 mein use hoti hai): teen bars — memory ResMII (4), ALU ResMII (3), aur RecMII (3) — cycles per iteration mein measured. Sabse tall bar (memory, red mein) wahi hai jo set karta hai, exactly kyunki sabhi floors ka max hai. Pedagogically yeh poora Level-3 idea ek nazar mein hai: average mat karo, add mat karo — sabse tall bar dhundho. Red arrow us winning bar ki taraf point karta hai yeh hammer home karne ke liye ki kaunsi constraint binding hai.
L3-Q3
L3-Q1/Q2 ke loop ke liye, agar hum ek second memory port add karein ( 1 se 2 ho jaaye), toh new kya hoga? Yeh kya reveal karta hai?
Recall Solution
New memory bound: . Recompute:
- Memory: , ALU: , Branch: → new .
- unchanged . Port add karne se improvement sirf 4 se 3 tak aayi. Ab ALU aur recurrence tie karte hain as new limits — dono se neeche nahi ja sakte bina dono zyada ALUs aur shorter dependency cycle ke. Yeh analyst ka lesson hai: ek bottleneck relieve karo aur agla wala appear ho jaata hai.
Level 4 — Synthesis
L4-Q1
Is loop body ko 4-slot machine (1 mem, 2 ALU, 1 br/FP) par schedule karo. Maano ki sabhi latencies 1 cycle hain aur koi cross-iteration recurrence nahi hai:
L1: r1 = LD a[i]
L2: r2 = LD b[i]
A1: r3 = r1 + r2 (needs L1, L2)
A2: r4 = r3 * 2 (needs A1)
S1: ST c[i] = r4 (needs A2)
Ek legal single-iteration VLIW schedule produce karo aur uska cycle count do.
Recall Solution
Constraints: ek memory op per cycle (isliye L1, L2, S1 ek cycle share nahi kar sakte); ek RAW (Read After Write) chain — true data dependencies ki ek string jahan har op woh read karta hai jo pichle ne likha — yaani L1,L2 → A1 → A2 → S1.
Slot layout: [ ALU1 | ALU2 | MEMORY | BR/FP ]
Cycle 1: [ NOP | NOP | LD r1,a | NOP ]
Cycle 2: [ NOP | NOP | LD r2,b | NOP ]
Cycle 3: [ ADD r3,r1,r2| NOP | NOP | NOP ]
Cycle 4: [ MUL r4,r3,2 | NOP | NOP | NOP ]
Cycle 5: [ NOP | NOP | ST c,r4 | NOP ]
5 cycles. Do loads single port ki wajah se serialise hone chahiye; ADD dono ka wait karta hai; MUL ADD ka wait karta hai; store MUL ka wait karta hai. Utilisation — serial chain wide issue se benefit nahi uthata.
L4-Q2
Ab L4-Q1 loop ko iterations ke across software-pipeline karo taaki throughput badhao. Recurrence-free body mein (2 loads + 1 store) aur hai. Steady-state kya hai — pipelined loop ke repeating middle mein II, fill ke baad aur drain se pehle (vocabulary box dekho) — aur ise kya limit karta hai?
Recall Solution
Formula box ke do floors apply karo: Koi recurrence nahi hai, isliye . Therefore: Toh steady state mein har 3 cycles mein ek nayi iteration launch hoti hai. Chahe ek iteration standalone 5 cycles leti hai (L4-Q1 se), pipelining memory port ko per iteration 3 accesses back-to-back stream karne deta hai jabki earlier iterations ka ALU work gaps mein chhup jaata hai. Throughput se iterations per cycle ho jaata hai. Single memory port ise limit karta hai.
L4-Q3
L4-Q2 se use karte hue, full 100-iteration loop kitne cycles lega, agar pipeline prologue (fill) steady state se pehle 4 extra fixed cycles add karta hai?
Recall Solution
Steady-state cost cycles. Prologue add karo: cycles. (Formally, total large ke liye; prologue 100 iterations mein nearly nothing tak amortise ho jaata hai.)
Level 5 — Mastery
L5-Q1
Ek DSP kernel mein yeh dependency cycle hai: acc = acc + (x[i] * h) jahan multiply-add khud ko har iteration feed karta hai. Multiply-add ki latency 3 cycles hai, aur recurrence 1 iteration span karta hai ( — is iteration ke acc ko immediately pichle wale ki zaroorat hai). Kernel har iteration mein 1-port machine par 2 memory loads bhi issue karta hai. nikalo, aur explain karo kaunsa bound jeetta hai aur kyun hardware add karne se use beat nahi kiya ja sakta.
Recall Solution
- (memory port).
- . Recurrence jeetta hai. Crucially, memory ports ya ALUs add karne se drop hoga lekin nahi lower kar sakta: iteration ka accumulator genuinely iteration ki value chahiye, jise produce hone mein 3 cycles lagte hain. Yeh ek algorithmic limit hai, resource limit nahi — koi bhi extra silicon ek true data dependence nahi hata sakta. (Sirf algorithm restructuring se — jaise partial sums mein split karna — cycle short ho sakta hai.)
L5-Q2
Ek hi loop ke do schedules compare karo jinka hai: Schedule A achieves ; Schedule B achieves kyunki compiler ek register rename karne mein fail raha, ek false WAW dependency ek cycle mein create kar raha. 300 iterations mein throughput loss quantify karo, aur ek-line fix batao.
Recall Solution
- Schedule A: cycles.
- Schedule B: cycles.
- Loss: cycles, yaani Schedule B slower hai. Fix: compiler ko register rename karna hoga taaki WAW (write-after-write) independent ho jaaye. WAW aur WAR false dependencies hain (data-dependence definition box dekho) — woh register names reuse karne se arise karte hain, real data flow se nahi — aur VLIW mein compiler (hardware nahi) ko unhe eliminate karna padta hai. Renaming restore kar deta hai.
L5-Q3 (capstone)
Design decision: Tumhare paas ek loop hai jisme , , aur ek recurrence hai jisme , hai. Tumhare baseline machine mein 1 memory port aur 2 ALUs hain. Tum exactly ek add kar sakte ho: (a) ek second memory port, ya (b) ek third ALU. Kaunsa upgrade zyada lower karta hai, aur kitna?
Recall Solution
Baseline:
- Memory: ; ALU: ; toh .
- .
- .
(a) Second memory port: memory ; ALU ; ; ⇒ .
(b) Third ALU: memory (unchanged!); ALU ; ; ⇒ .
Answer: Second memory port (a) ko 6 se 3 tak cut karta hai — ek 2× speedup. Third ALU kuch nahi badalta kyunki ALU kabhi bottleneck nahi tha (woh 2 par baitha tha jabki memory 6 par tha). Hamesha hardware binding resource par spend karo.
Upgrade decision exactly yeh "attack the tallest bar" logic hai (yeh figure L5-Q3 ko support karta hai):

Upar ki figure kya dikhati hai (L5-Q3 mein use hoti hai): har resource ke liye bars ka ek pair — baseline bound (left, black) aur second memory port add karne ke baad bound (right). Sirf memory bar move karta hai, 6 se (red mein, kyunki woh binding tallest bar tha) 3 tak girta hai; ALU aur recurrence bars khade rehte hain. Yeh capstone lesson visual banata hai: ek non-tallest bar (third ALU) par kharchaa kiya hua paisa red bar ko — aur isliye ko — bilkul unchanged chhod deta. Tum loop ko sirf tabhi speed up karte ho jab jo abhi tallest hai use shrink karo.