6.1.7 · D3 · HinglishParallelism & Multicore

Worked examplesNUMA architectures

3,187 words14 min read↑ Read in English

6.1.7 · D3 · Hardware › Parallelism & Multicore › NUMA architectures

Yeh page NUMA topic note ka drill hall hai. Parent note ne theory build ki; yahan hum har tarah ke numbers grind karte hain jo ek NUMA question aap par throw kar sakta hai. Koi bhi formula touch karne se pehle, hum saare cases ka ek map lay out karte hain taaki aap koi bhi scenario se kabhi cold na milo.

Jo kuch bhi hum use karte hain woh parent note mein already earn ho chuka hai, lekin hum har symbol ko pehli baar re-anchor karte hain, taaki ek reader jo seedha yahan jump kiya ho woh bhi zero se start kare.

Recall Teen tools jo hum reuse karte hain (parent se)

NUMA factor — "far memory, near memory se kitni times slow hai?" Yeh do times ka plain ratio hai, isliye iska koi unit nahi (nanoseconds cancel ho jaate hain). Average access time jahan un accesses ka fraction hai jo remote jaate hain. Speedup vs all-remote . Agar inme se koi strange lage, pehle NUMA architectures padho — hum inhe re-derive nahi karte, hum inhe apply karte hain.


Scenario matrix

Har NUMA numeric question ko neeche exactly ek cell mein girta hua socho. Hamare examples (E1–E9) is tarah place kiye gaye hain ki har cell kam se kam ek baar hit ho.

Cell Case class Isme kya weird / extreme hai Covered by
C1 Baseline mixed — normal ordinary 80/20 duniya E1
C2 Degenerate (sab local) remote term vanish ho jaata hai E2
C3 Degenerate (sab remote) apni ceiling hit karta hai E2
C4 Degenerate (UMA) NUMA uniform ho jaata hai E3
C5 Limiting remote "infinitely" costly hai E3
C6 Multi-node latency table (per-hop) ek hop map se build karo E4
C7 Address → node mapping (interleave vs range) integer floor/mod, address ka sign E5
C8 Coherence 3-hop cost (false sharing) message times add karo, ratios nahi E6
C9 Real-world word problem (bandwidth GB/s) latency win ko throughput mein translate karo E7
C10 Inverse question — required ke liye solve karo algebra backwards run E8
C11 Exam twist — mixed nodes, weighted khud ek weighted average hai E9

E1 — Baseline mixed access (cell C1)

Forecast: average guess karo — yeh mostly local hai (80%), isliye expect karo 80 ke zyada paas hoga, 160 ke nahi. Apna guess likh lo.

  1. NUMA factor compute karo. Yeh step kyun? woh single number hai jo kehta hai "remote slower hai". Baad ke har formula ko yeh ratio chahiye, raw times nahi.

  2. mein plug karo. Yeh step kyun? Hum do costs ko average kar rahe hain jitni baar each hoti hai: time hum pay karte hain, time hum pay karte hain.

  3. All-remote par speedup compute karo. Yeh step kyun? All-remote ns cost karta. Hamara ns faster hai — speedup exactly dono ka ratio hai.

Verify: , se match. Units: ns mein aaya (sahi, humne ek ns ko ek dimensionless bracket se multiply kiya). ek pure ratio hai (, koi unit nahi). Tumhara forecast — kya ke zyada paas tha ya ke? Haan. ✓


E2 — Dono degenerate ends: aur (cells C2, C3)

Forecast: dono answers ns aur ns honge — woh extremes jinhe average kabhi nahi chhodta.

  1. set karo. Yeh step kyun? Jab kuch bhi remote nahi, term switch off ho jaata hai. pure mein collapse ho jaata hai — yeh floor hai.

  2. set karo. Yeh step kyun? Jab sab kuch remote hai, local term vanish ho jaata hai aur hum har baar pay karte hain — yeh ceiling hai.

  3. Poori range ko ek straight line ki tarah interpret karo. Beech ke kisi bhi ke liye, ek straight line hai jo ns (at ) se ns (at ) tak jaati hai. Neeche ki figure yeh concrete banati hai.

Figure — NUMA architectures

Verify: E1 result ns is line par hona chahiye: . ✓ Floor E1 ceiling: . ✓


E3 — Do aur degenerate knobs: aur (cells C4, C5)

Forecast: (a) agar remote utna hi cost karta hai jitna local, toh NUMA-awareness kuch bhi nahi khareedti → . (b) agar remote unboundedly slow hai, toh remote accesses sab kuch dominate karte hain → ek finite number par settle hona chahiye, infinity nahi.

  1. Part (a), set karo. Yeh step kyun? Yeh sanity check hai ki NUMA UMA mein reduce ho jaata hai jab far aur near same cost karte hain — completely cancel ho jaata hai, isliye har ke liye.

  2. Part (b), ke saath limit lo. ke top aur bottom ko se divide karo: Yeh step kyun? Growing quantity se divide karna runaway term ko mein turn karta hai. Message yeh hai: remote chahe kitना bhi slow ho jaaye, local rakhna tumhara win par cap karta hai. Woh remote anchor hai.

Verify: limit hai. Large finite value se cross-check karo, : , jo hai. ✓ Part (a): plug karo: . ✓


E4 — Hop-latency table se build karna (cell C6)

Forecast: "effective remote" time ka average hai — around ns — isliye thoda se kam hoga.

  1. Teen remote latencies average karo. Yeh step kyun? "Nodes 1,2,3 par evenly" ka matlab hai har remote access equally likely hai har ek ko hit karne ke liye — isliye representative remote cost teen ka plain mean hai.

  2. Effective NUMA factor banao (local node 0 = ns hai). Yeh step kyun? hamesha "remote" ka matlab jo bhi ho usse local se compare karta hai. Yahan remote averaged remote hai.

  3. ke saath average access time. Yeh step kyun? Same weighting jaise hamesha — local at ns, remote at ns.

Verify: direct way se compute karo: ns. Step 3 se match. ✓ Units: poora ns mein. Forecast: , indeed just under 2. ✓


E5 — Address → node mapping: interleave vs range (cell C7)

Forecast: do alag schemes, isliye probably same address ke liye do alag node IDs — yahi comparison ka poora point hai.

  1. Interleaved: yeh kaun si cache line hai? Yeh step kyun? Interleaving poori cache lines round-robin assign karta hai, isliye pehle hum poochte hain " konse line number mein hai?" Floor line ke andar byte offset throw kar deta hai (addresses non-negative hain, isliye floor sirf fraction drop karta hai — yahan koi sign trap nahi).

  2. Interleaved: node count se mod karo. Yeh step kyun? line number ko 4 nodes par wrap karta hai: line 0→node0, line1→node1, …, line4→node0. Line 320 ek multiple of 4 hai, isliye node 0 par land karta hai.

  3. Range-based: node size se divide karo. Yeh step kyun? Range-based har node ko bytes ka ek contiguous block deta hai. pehle block () se past hai lekin doosre mein () → node 1.

  4. Degenerate . Interleaved: . Range: . Dono node 0 dete hain. Yeh step kyun? Lowest address hamesha dono schemes ke under node 0 mein baith ta hai — ek useful anchor apni arithmetic direction check karne ke liye.

Verify: interleaved node , range node — genuinely different, confirming karta hai ki interleave scatter karta hai jabki range locality rakhta hai (isliye range-based first-touch affinity enable karta hai). → dono taraf node 0. ✓


E6 — False sharing se Coherence 3-hop cost (cell C8)

Forecast: hum message times add kar rahe hain (ratios multiply nahi), isliye expect karo ek bada sum — kuch sau ns — ns local miss se kaafi zyada bura.

  1. 3-hop protocol stages sum karo. Yeh step kyun? Latency ratios se alag, coherence traffic sequential events ki ek chain hai — har ek ko agle se pehle khatam hona chahiye, isliye total time unka sum hai, product nahi.

  2. Local L3 miss se compare karo. Yeh step kyun? Yeh ratio false sharing ki true cost hai: same logical operation nearly slower hai kyunki line interconnect par ping-pong karta hai.

Verify: . ✓ . ✓ Units: saare summands ns hain → sum ns hai; slowdown ek pure ratio hai. Sanity: sum () parent ke 3-hop protocols ke liye quote kiye " ns" range mein hai. ✓


E7 — Real-world word problem: locality se bandwidth (cell C9)

Forecast: thoda ke se kam hai, isliye roughly speedup expect karo aur runtime s se s ke around drop hoga.

  1. Bandwidth speedup. Yeh step kyun? Bandwidth-bound kernel ke liye, throughput hi performance metric hai, isliye do GB/s figures ka ratio directly speedup hai.

  2. New runtime. Ek bandwidth-bound job fixed amount of data move karta hai; time , isliye time bandwidth ke inversely scale karta hai. Yeh step kyun? Same data, zyada rate → proportionally kam time. Hum inverse bandwidth ratio se multiply karte hain kyunki time aur bandwidth inversely related hain.

Verify: bandwidth speedup. ✓ Units: , isliye time seconds mein aata hai. Forecast: , s — matches. ✓


E8 — Inverse question: mujhe kaunsi locality chahiye? (cell C10)

Forecast: remote slower hone ke saath aur sirf budget ke saath, allowable remote fraction chhota hona chahiye — roughly one-in-eight jaisa number.

  1. use karke constraint likho. Yeh step kyun? Hum chahte hain average local se zyada na ho. Dono sides ko se divide karo (positive hai, isliye inequality direction safe hai) ek pure-number condition paane ke liye.

  2. Bracket simplify karo. Yeh step kyun? Like terms combine karo: . exactly hai, "remote traffic ki har unit par extra cost".

  3. ke liye solve karo. Yeh step kyun? isolate karo. Answer: budget ke andar rehne ke liye se zyada accesses remote nahi ho sakte.

Verify: back plug karo: — exactly ceiling. ✓ Forecast ne "one-in-eight" kaha tha aur . ✓


E9 — Exam twist: phases par weighted average ke roop mein (cell C11)

Forecast: overall aur ke beech hai, ki taraf pulled (kyunki phase A zyada weigh karta hai) → guess around .

  1. Do phases ko ek mein combine karo. Yeh step kyun? "saare accesses ka woh fraction jo remote hain" hai. Kyunki phases proportion mein accesses contribute karte hain, overall remote fraction unka access-weighted average hai — tum sirf aur average nahi kar sakte.

  2. Average access time. Yeh step kyun? Jab ek single number ho jaata hai, standard formula unchanged apply hota hai.

  3. All-remote par speedup. Yeh step kyun? All-remote ns hota; .

Verify: direct check , se match. ✓ Weighted : , aur yeh aur ke beech hai, midpoint se neeche pulled — phase A ke bade weight ke saath consistent. ✓ Yeh weighting logic exactly wahi hai jo NUMA-aware algorithm design optimize karta hai: bade-weight phase ka pehle shrink karo.


Recall Self-test (answers cover karo)

Local ns, remote ns, . find karo. ::: Same numbers — find karo. ::: ns Interleaved: , line , nodes . Node? ::: Agar with , limiting speedup? :::