6.1.7 · HinglishParallelism & Multicore

NUMA architectures

2,995 words14 min readRead in English

6.1.7 · Hardware › Parallelism & Multicore

Figure — NUMA architectures

Woh Problem Jo NUMA Solve Karta Hai

UMA scale par kyun fail karta hai:

  1. Single point of contention: Saare memory requests ek controller se serialize hote hain
  2. Bus saturation: Electrical bus physically ~4-8 processors se zyada scale nahi kar sakta
  3. Cache coherence traffic: Zyada cores ke saath, coherence messages interconnect ko flood kar dete hain
  4. Latency insensitivity: Har access same cost pay karta hai, koi locality optimization nahi

NUMA Kaise Kaam Karta Hai

Derivation: Access Time Alag Kyun Hoti Hai

Physical topology se shuru karte hain. UMA mein:

Saare paths symmetric hain, isliye constant hai.

nodes wale NUMA mein:

  • Local access (processor0 → memory0): Koi shared bus nahi, koi arbitration queue nahi. Yeh baseline hai.

  • Remote access (processor 0 → memory 1):

    t_{remote} &= t_{processor\_0 \to interconnect} \\ &\quad + t_{interconnect\_hop} \times h\\ &\quad + t_{node\_1controller} \\ &\quad + t_{DRAM\_access} \\ &\quad + t_{data\_return} \end{align}$$ Jahan $h$ interconnect topology mein hops ki number hai (direct link ke liye 1, mesh/torus ke liye zyada).

Yeh kyun matter karta hai: Agar 50 ns hai aur 80 ns hai, toh 130-180 ns ho sakta hai. Yeh 2x penalty matlab hai ki algorithms ko data local rakhne ke liye NUMA-aware hona chahiye.

NUMA Node Structure

Har node effectively ek mini-SMP hai:

  • Node ke andar multiple cores L3 cache aur memory controller share karte hain
  • Ek node ke andar ke cores us node ki memory ko uniform latency se dekhte hain
  • Node ID physical address space partitioning ka hissa hota hai

Range-based prefer kyun hota hai: OS ek first-touch policy implement kar sakta hai—jab ek thread pehli baar ek page mein write karta hai, use thread ke node se allocate karo. Yeh temporal locality exploit karta hai.

NUMA Mein Cache Coherence (ccNUMA)

Coherence Overhead Derivation

Ek cache line consider karo jise alag nodes par processors access karte hain. Ek directory-based protocol mein:

  • Har cache line ka ek home node hota hai (jahan memory rehti hai)
  • Directory track karta hai ki kaunse nodes ne copies cache ki hain

Remote read miss ki cost:

Agar line kahin aur (node 2 par) modified hai:

Yeh 3-hop protocol 200-400 ns le sakta hai—local L3 miss (~30 ns) se kaafi bura. Key insight: false sharing (alag nodes par do threads same cache line mein alag words write karte hain) causes ping-ponging with coherence messages per write.

Performance Model: NUMA Factor

80/20 insight: Agar (80% local) aur , toh: 80% locality achieve karna 1.67x speedup deta hai. 95% local tak push karo () aur x. Remote accesses ka last 5% abhi bhi 10% performance cost karta hai.

OS aur Runtime Support

Kab kaun sa use karein:

  • First-touch + thread pinning: Static partitioning wale data-parallel workloads (HPC, databases).
  • Interleaving: Uniformly access ki jaane wali read-only shared data (large lookup tables).
  • Explicit allocation: Jab tumhe access pattern pata ho (graph partitioning, NUMA-aware allocators).

Common Mistakes

Connections

  • 6.1.04-cache-coherence-protocols: NUMA coherence ko nodes ke across extend karta hai; directory protocols scalability ke liye essential hain.
  • 6.1.05-memory-consistencymodels: NUMA consistency model nahi badalta (still TSO/SC), lekin reordering remote accesses ko zyada visible bana sakta hai.
  • 6.1.06-multicore-synchronization: NUMA par lock contention worse hoti hai—nodes ke across bounce karne wala ek lock cache line har acquire par 2-3x penalty pay karta hai.
  • 6.2.03-thread-scheduling: OS scheduler ko NUMA-aware hona chahiye taaki threads nodes ke across migrate na ho.
  • 6.3.01-parallel-algorithms: Algorithms ko scale karne ke liye NUMA node ke anusaar data partition karna chahiye (jaise per-node hash tables, partitioned queues).

Recall Ek 12-Saal Ke Bacche Ko Samjhao

Jaante ho jab tum ghar par hote ho, toh apne room se apne toys super fast grab kar sakte ho? Lekin agar tumhe apne dost ka toy chahiye jo saamne wale ghar mein hai, toh tumhe wahan jaana padega, maangna padega, aur wapas aana padega—kaafi zyada time lagta hai.

Computers ke liye NUMA waisa hi hai. Har processor ka apna "room" hota hai jisme uske paas apni memory (RAM) hoti hai. Agar use apni memory se data chahiye, toh super fast hota hai—jaise apni shelf se toy uthana. Lekin agar use doosre processor ki memory se data chahiye, toh use ek special wire (interconnect) ke zariye message bhejna padta hai, doosre processor ke find karne ka wait karna padta hai, phir wapas bhejana padta hai. Woh 2-3 times zyada time leta hai.

Toh trick yeh hai: apna data apne "room" mein rakhho. Agar tum kuch numbers ke saath math kar rahe ho, toh woh numbers us memory mein store karo jo tumhare sabse paas hai. Agar sab aisa karein, toh poora computer kaafi faster chalata hai, kyunki koi bhi door se kuch aane ka wait nahi kar raha. Lekin agar tum dhyan nahi rakhte aur tumhara data galti se kisi aur ke room mein chala jaata hai, toh achanak sab kuch slow ho jaata hai.

Flashcards

#flashcards/hardware

NUMA ka full form kya hai aur key property kya hai? :: Non-Uniform Memory Access. Memory access time processor ke relative memory ki physical location par depend karta hai—local memory remote memory se faster hoti hai.

UMA (Uniform Memory Access) ~8-16 cores se zyada scale kyun fail karta hai?
Saare cores ek single memory controller aur bus share karte hain, bandwidth bottleneck create karta hai. Effective bandwidth per core drop hoti hai ke saath, aur coherence traffic interconnect ko saturate kar deti hai.
NUMA system mein remote aur local memory latency ka typical ratio kya hai?
Typically x se x slower. For example, local = 80 ns, remote = 140-240 ns depending on hops.
NUMA mein first-touch policy kya hai?
Jab ek thread pehli baar kisi memory page mein write karta hai (page fault), OS us page ko us memory node se allocate karta hai jahan thread currently run kar raha hai, locality exploit karta hai.

NUMA mein fraction remote accesses ke saath average memory access time derive karo :: jahan .

ccNUMA kya hai?
Cache-coherent NUMA—hardware directory-based MESI jaise protocols use karke NUMA nodes ke across cache coherence maintain karta hai, ek single shared address space provide karta hai.
False sharing NUMA par UMA se worse performance kyun cause karta hai?
False sharing cache line ping-ponging cause karta hai. NUMA par, har transfer remote latency incur karta hai (2-3x local), aur coherence messages interconnect traverse karte hain, cost multiply hoti hai.
NUMA mein remote memory accesses reduce karne ke liye do strategies kya hain?
(1) Thread affinity: threads ko specific nodes par pin karo. (2) Memory affinity: memory us node se allocate karo jahan thread run karta hai (first-touch ya explicit allocation).
NUMA par interleaved memory allocation kab use karni chahiye?
Read-only ya read-mostly shared data ke liye jo sabhi cores uniformly access karte hain, saare memory controllers mein load spread karke aggregate bandwidth maximize karne ke liye.

Concept Map

bottleneck at scale

B_eff to 0 as N grows

contention + saturation

solves

partitions memory into

each has

linked by

gives

adds hops

non-uniform access time

non-uniform access time

exploit via

restores

UMA / SMP single bus

Bandwidth bottleneck

Processors wait not compute

NUMA architecture

Nodes

Local memory bank + controller

Interconnect QPI, Infinity Fabric

t_local fast baseline

t_remote 1.3x to 3x slower

Access time depends on location

Keep most accesses local 80/20