5.4.7 · D3 · HinglishMemory Hierarchy & Caches

Worked examplesWrite-allocate vs no-allocate

2,720 words12 min read↑ Read in English

5.4.7 · D3 · Hardware › Memory Hierarchy & Caches › Write-allocate vs no-allocate

Yeh page Write-allocate vs no-allocate ki practice ground hai. Parent note ne idea explain kiya; yahan hum har us situation ko grind karte hain jo ek write miss create kar sakta hai aur har baar memory traffic count karte hain.

Kuch bhi karne se pehle, in words ko pin down karte hain taaki koi symbol bina wajah use na ho.

Figure — Write-allocate vs no-allocate

Scenario matrix

Har write-miss situation jo yeh topic aap par throw kar sakta hai, in cells mein se ek mein aati hai. Jo examples follow karte hain woh sab us cell ke saath tagged hain jo wo cover karte hain, aur mil kar yeh sab ko hit karte hain.

# Case class Kya special hai Policy jo shine kare Example
A Single isolated write, jald reuse hoga temporal locality present write-allocate + write-back Ex 1
B Single isolated write, kabhi reuse nahi zero temporal locality no-allocate + write-through Ex 2
C Ek block par writes ka cluster, phir read spatial locality write-allocate Ex 3
D Kai blocks mein streaming writes data cache se bada no-allocate / Streaming Stores Ex 4
E Degenerate: same address par do baar write kya 2nd hit hai? dono — hit logic test karta hai Ex 5
F Boundary: block edge par straddling write offset line size ke paas block granularity reveal karta hai Ex 6
G Eviction / dirty writeback line already dirty, conflict write-back cost accounting Ex 7
H Word-problem (real workload) ek policy choose karo & justify karo decision framework Ex 8
I Exam twist: forbidden combo write-back + no-allocate dikhata hai yeh illegal kyun hai Ex 9

Jab tak alag na bataya jaaye, poore note mein yeh cache use hogi: 4 lines, 8 bytes/line, direct-mapped, shuruaat mein khaali.


Cell A — isolated write, jald reuse hoga


Cell B — isolated write, kabhi reuse nahi hoga


Cell C — ek block par cluster, phir read (spatial locality)

Figure — Write-allocate vs no-allocate

Cell D — kai blocks mein streaming


Cell E — degenerate: same address par do baar write


Cell F — boundary: block edge par straddling write


Cell G — dirty line ki eviction


Cell H — real-world word problem


Cell I — exam twist: forbidden combination


Recap

Recall Pure streaming writes ke liye kaun sa cell jeet ta hai?

No-allocate — zero reuse ka matlab hai allocation sirf fetch + eviction cost add karta hai. (Cell D / Ex 4)

Recall Ex 3 mein write-allocate 1 nahi, 2 reads kyun cost hua?

0x1000x10C do blocks (0x20 aur 0x21) par span karta tha, har ek ek baar fetch hua.

Prior allocation ke baad write-allocate hit ka traffic count
Zero — block already valid hai, toh ek repeated write sirf dirty bit flip karta hai.
Dirty line eviction par extra cost kyun aati hai
Ise memory mein write back karna hota hai apna slot reuse hone se pehle, jo ek memory write add karta hai.