6.1.4 · HinglishParallelism & Multicore

Multicore vs manycore designs

3,002 words14 min readRead in English

6.1.4 · Hardware › Parallelism & Multicore

Core Concept

Modern parallel processors do fundamental architectural philosophies mein aate hain: multicore (thode powerful cores) aur manycore (bahut saare simpler cores). Yeh design choice ek fundamental tradeoff represent karta hai per-thread performance aur throughput capacity ke beech.

Key insight yeh hai: Dono ek saath nahi ho sakte. Transistor budget fixed hota hai. Jo paisa complex out-of-order execution logic, bade caches, aur branch prediction pe lagta hai, woh paisa zyada cores add karne pe nahi lagta.

Detailed Comparison

Figure — Multicore vs manycore designs

Multicore Architecture

Design Philosophy: Single-thread performance maximize karo. Har core complex, irregular code ko unpredictable branches aur memory access patterns ke saath efficiently execute kar sakta hai.

Yeh architecture kyun?

  1. Legacy code optimization: Zyaatar software single-threaded execution ke liye likha jaata hai
  2. Latency-critical tasks: Operating systems, databases, compilers fast sequential execution se fayda uthate hain
  3. Irregular parallelism: Unpredictable control flow wale tasks (web servers, transaction processing)

Jahaan:

  • = code ka woh fraction jo parallelize ho sakta hai
  • = cores ki sankhya
  • = serial fraction (asli villain)

First principles se derivation: Total execution time ke do components hain:

cores ke saath, sirf parallel portion speed up hota hai:

Original time se normalize karke:

Numerator aur denominator dono ko se divide karke:

Critical insight: Agar sirf 5% bhi serial hai (), toh max speedup hai, chahe kitne bhi cores kyun na hon. Isliye multicore har core ko fast rakhne pe focus karta hai.

Manycore Architecture

Design Philosophy: Massive parallelism ke through aggregate throughput maximize karo. Instruction-level tricks ki bajaye thread-level parallelism se latency hide karo.

Yeh architecture kyun?

  1. Data parallelism: Massive datasets par same operation (SIMT - Single Instruction Multiple Threads)
  2. Throughput-oriented: Scientific computing, graphics, machine learning
  3. Latency tolerance: Memory stalls ke dauran doosre thread par switch kar sako (100+ cycles)

Derivation:

  • Har core (instructions per cycle) × (cycles/sec) instructions/second complete karta hai
  • ke saath, raw capacity hai
  • Utilization factor (0-1) thread divergence, memory bottlenecks account karta hai

Key design choice: dramatically badhane ke liye IPC aur per core kam karo.

Example calculation:

  • Multicore: 8 cores × 4 GHz × 4 IPC × 0.9 util = 115.2 GIPS
  • Manycore: 512 cores × 1.5 GHz × 1 IPC × 0.7 util = 537.6 GIPS (4.7× zyada throughput)

Lekin single thread par, multicore faster execute karta hai per clock!

Example 1: Intel Core i9 (Multicore)

  • Architecture: 8-16 high-performance cores
  • Per-core features:
    • 512KB L2 cache per core
    • 6-wide superscalar execution
    • 32MB shared L3 cache
    • Hyper-Threading (2 threads/core)
  • Use case: Gaming, content creation, general computing
  • Yeh kyun kaam karta hai: Games mein complex AI, physics, rendering pipelines hoti hain jo fast sequential execution se fayda uthati hain. 8 threads ke saath bhi, single-thread performance matter karti hai (ek thread aksar bottleneck banta hai).

Step-by-step performance analysis:

  1. Game physics engine mein 30% parallel, 70% serial code hai
  2. 8 cores ke saath: Speedup =
  3. Lekin har core 4.5 GHz par high IPC ke saath chalta hai → absolute performance high hai
  4. Yeh step kyun? Modest parallel speedup bhi acceptable hai jab base performance excellent ho.

Example 2: NVIDIA A100 GPU (Manycore)

  • Architecture: 6912 CUDA cores (108 SMs × 64 cores each)
  • Per-core features:
    • Bahut simple in-order pipeline
    • Tiny caches, massive thread count
    • Hardware thread scheduler (32-wide warps)
  • Use case: Deep learning training, scientific simulation
  • Yeh kyun kaam karta hai: Matrix multiplication 100% parallel hai. Neural network training mein millions of weights independently process hote hain.

Step-by-step performance analysis:

  1. Matrix multiplication: jahaan hain
  2. output elements mein se har ek independently compute hota hai
  3. Har element ko ek thread assign karo: 100% parallel ()
  4. Speedup = (theoretical)
  5. Yeh step kyun? Perfect parallelism ke saath, zyada cores = linear speedup.
  6. Actual: ~4000× memory bandwidth limits ki wajah se, lekin phir bhi multicore se kaafi aage.

Example 3: Database Query (Multicore Wins)

  • Task: 5 tables ke saath complex JOIN, WHERE clauses, aggregations
  • Multicore kyun?
    1. Query planning: sequential logic, unpredictable branches
    2. Index traversals: pointer chasing (manycore ke liye bahut bura)
    3. Lock management: sequential critical sections
    4. Parallel scan ke saath bhi, complexity fast cores ko favor karti hai
Dimension Multicore Manycore
Core count 2-16 100-10,000+
Per-core performance High (4-6 IPC) Low (1-2 IPC)
Clock speed 3-5 GHz 1-1.5 GHz
Cache per core Large (MB) Tiny (KB)
Power per core 15-50W 0.1-1W
Thread switching cost High (1000s cycles) Low (1 cycle, hardware managed)
Best workload Irregular, branchy, latency-sensitive Regular, data-parallel, throughput-oriented
Memory access Latency ke liye optimized Bandwidth ke liye optimized

The Resource Tradeoff

Ek chip ke paas fixed resources hoti hain:

Jahaan:

  • = total die area (process node aur cost se fixed)
  • = har core ke execution units ka area
  • = cache area per core
  • = out-of-order logic, branch prediction, etc.
  • = core communication ke liye network-on-chip

Tradeoff ki derivation: Multicore ke liye: aur BADE hain (core area ka 50-60%) Manycore ke liye: , minimal hai (core area ka 10-15%)

Agar ek complex core area leta hai, aur simple core leta hai:

Yeh kyun matter karta hai: Tum 1 complex core ke badle ~50 simple cores lete ho. Yeh TABHI kaam karta hai jab tumhara workload saare 50 ko efficiently use kar sake.

Memory Access Patterns

Multicore strategy: Complex caching aur out-of-order execution se latency hide karo

  • Bade caches working set ko capture karte hain (temporal locality)
  • Out-of-order execution memory stalls ke dauran independent instructions dhundhta hai
  • Hardware prefetchers access patterns predict karte hain
  • Cost: Bahut zyada silicon area, power

Manycore strategy: Massive thread-level parallelism se latency hide karo

  • Jab thread 1 memory ka wait kare, turant thread 2 par switch karo
  • Core per 100 threads ke saath, hamesha kaam milta hai
  • SIMD/SIMT chahiye (saare threads same instruction execute karein)
  • Cost: Hazaron parallel threads chahiye; irregular code mein help nahi karta

Scenario: DRAM se load karne mein 300 cycles lagte hain

Multicore approach (Intel core):

  1. Load instruction issue karo
  2. Out-of-order engine window mein 100+ independent instructions dhundhta hai
  3. Wait karte waqt woh execute karo
  4. Agar independent work khatam ho jaaye, core stall karta hai (bura!)
  5. Yeh step kyun? Latency hide karne ke liye single thread ke andar ILP exploit karna.

Manycore approach (GPU):

  1. Thread 1 load instruction issue karta hai → context switch (1 cycle)
  2. Thread 2 execute hota hai → context switch
  3. Thread 3 execute hota hai → ...
  4. Thread 32 execute hota hai → wapas thread 1 par, data likely aa chuka hai
  5. Yeh step kyun? Kaafi threads ke saath, kabhi stall nahi; koi na koi hamesha ready hota hai.

Common Misconceptions

Kyun galat hai: Speedup serial fraction (Amdahl's Law) SE AUR communication overhead se limited hota hai.

Fix yeh hai:

jahaan communication/synchronization overhead hai jo ke saath BADHTA hai.

1000 cores ke saath, agar synchronization har core ka 1% time leta hai: → negative speedup!

Example: 1000 cores ke saath 1M numbers sort karna:

  • Data partition karo: kaam, negligible
  • Locally sort karo: - perfect parallelism
  • Results merge karo: - serial bottleneck
  • ke liye, merge time dominate karta hai jab tak enormous na ho

Kyun galat hai: Sirf data-parallel workloads ke liye sach hai. GPUs inn chezon mein bahut bure hain:

  • Branching code (if-else "warp divergence" cause karta hai - cycles waste hote hain)
  • Pointer chasing (linked lists, trees)
  • Chhote datasets (kernels launch karne ka overhead)
  • Irregular memory access

Fix yeh hai: Architecture ko workload pattern se match karo.

Example - Tree traversal:

// GPU par bahut bura
struct Node { int value; Node* left; Node* right; };
int search(Node* root, int target) {
    if (!root) return -1;
    if (root->value == target) return 1;
    return search(root->left, target) || search(root->right, target);
}

GPU kyun fail karta hai:

  1. Har thread alag path follow karta hai (warp divergence)
  2. Pointer chasing: 100% cache misses, latency hide nahi ho sakti
  3. Koi data parallelism nahi: har search dependent hai

Branch prediction + large cache wala CPU 10×+ se jeet jaata hai.

Kyun galat hai: Serial portion ABHI BHI clock speed par chalta hai. Amdahl's Law ke according, serial portion ultimate speedup ceiling determine karta hai.

Fix yeh hai: Balance matter karta hai. Bahut slow cores even parallel code ko hurt karte hain.

Example: Video encoding (90% parallel)

  • Fast cores (4 GHz): Serial 10s leta hai, parallel 90s → 8 cores ke saath:
  • Slow cores (1 GHz): Serial 40s leta hai, parallel 360s → 32 cores ke saath:

4× zyada cores ke bawajood, slow architecture serial bottleneck ki wajah se 2.4× SLOWER hai.

Design Decision Framework

Multicore use karo jab:

Manycore use karo jab:

Formal criteria:

  1. Parallelism availability: Kya tum manycore cores se zyada threads bana sakte ho?
  2. SIMD/SIMT viability: Kya threads same instruction stream execute karte hain?
  3. Memory access pattern: Regular (strided, coalesced) ya irregular (random)?
  4. Latency tolerance: Kya tum 10-100× zyada single-thread latency afford kar sakte ho?

MANYcore: Maximize Agregate, No branches, Yield for latency

Ya socho: BIG·few vs little·many

Connections

  • Amdahl's Law - parallel speedup ko limit karne wale serial bottleneck ko quantify karta hai
  • Thread-Level Parallelism - multi vs manycore se alag tarike se exploit hoti hai
  • Cache Coherence - multicore shared memory ke liye critical, manycore ke liye kam relevant
  • SIMD vs MIMD - manycore SIMT use karta hai (GPU model), multicore MIMD hai
  • Memory Hierarchy - multicore caches emphasize karta hai, manycore bandwidth emphasize karta hai
  • Power Consumption - manycore parallel workloads ke liye performance-per-watt mein jeet jaata hai
  • Heterogeneous Computing - modern systems dono combine karte hain (CPU+GPU)
Recall Ek 12-saal ke bacche ko explain karo

Socho tumhe 1000 math tests grade karne hain.

Multicore aise hai jaise 8 bahut smart teachers hon. Har teacher koi bhi test super fast grade kar sakta hai kyunki woh expert hain. Woh weird questions handle kar sakte hain, kaam check kar sakte hain, partial credit de sakte hain - sab complex kaam. Agar sirf 8 tests hain, bahut achha! Lekin agar 1000 tests hain jo saare same hain (sirf multiple choice), toh woh 8 teachers ka talent waste ho raha hai.

Manycore aise hai jaise 500 fifth-graders ke paas answer keys hon. Har baccha SIRF check kar sakta hai ki answer key se match karta hai ya nahi. Woh individually smart nahi hain, lekin UN MEIN SE BAHUT SAARE HAIN. Agar test saara multiple choice hai (simple, repetitive), woh 1000 tests ko 8 teachers se kaafi jaldi khatam kar denge. Lekin agar ek bhi question mein explanation chahiye, saare 500 bacche stuck ho jaate hain.

Computer chip teri school budget jaisi hai - tum ya toh 8 expert teachers hire kar sakte ho YA 500 simple checkers, dono nahi!


#flashcards/hardware

Multicore aur manycore processors mein key difference kya hai? :: Multicore mein thode (2-16) complex, high-performance cores hote hain jo single-thread speed ke liye optimized hain; manycore mein bahut saare (100s-1000s) simple cores hote hain jo aggregate throughput ke liye optimized hain.

Tum ek hi chip par complex cores AUR bahut saare cores dono nahi bana sakte, kyun?
Fixed transistor budget (die area): complex cores ko bade caches, out-of-order logic, branch prediction chahiye (50-60% overhead); simple cores mein minimal control logic hoti hai (10-15% overhead). Tum 1 complex core ke badle ~50 simple cores lete ho.
Amdahl's Law multicore scaling ke baare mein kya batata hai?
Speedup = 1/((1-P) + P/N) jahaan P parallel fraction hai. Serial portion (1-P) maximum speedup limit karta hai chahe core count N kitna bhi ho. 5% serial code bhi speedup ko 20× tak limit kar deta hai.
Manycore memory latency kaise hide karta hai?
Massive thread-level parallelism: jab ek thread memory ka wait kare (100s of cycles), hardware turant doosre thread par switch karta hai. Core per 100+ threads ke saath, bina stall kiye hamesha kaam milta hai.
Manycore KABB speedup deliver karne mein FAIL karta hai?
Jab workload mein ho: (1) branching/control flow (warp divergence cycles waste karta hai), (2) irregular memory access (pointer chasing, cache thrashing), (3) zyada serial fraction, ya (4) insufficient parallelism (cores se kam threads).
Manycore ke liye throughput formula kya hai?
Throughput = N_cores × f_clock × IPC × Utilization. Manycore low IPC aur clock speed ke badle massive N_cores leta hai, parallel workloads ke liye throughput mein jeet jaata hai.
Ek real-world example do jahaan multicore manycore ko beat kare.
Complex JOINs wali database query: query planning sequential hai, index traversal pointer chasing hai, lock management mein critical sections hain. Large caches aur branch prediction wale fast cores kam cores ke bawajood dominate karte hain.
Warp divergence kya hai aur yeh GPUs ko kyun hurt karta hai?
SIMT execution mein, ek warp (32 threads) ke saare threads same instruction execute karne chahiye. Agar threads alag branches lein (if-else), kuch threads idle rehte hain jab baaki execute karte hain, cycles waste hoti hain. Branching code peak speed ke fraction par chalta hai.
GPUs mein core per itne chhote caches kyun hote hain?
Design tradeoff: bade caches bahut zyada die area lete hain. GPUs woh area zyada cores mein invest karte hain, latency hide karne ke liye caching ki bajaye thread-level parallelism par rely karte hain.
Multicore ya manycore use karna hai yeh kya determine karta hai?
Multicore use karo agar: serial fraction >5%, irregular/branchy code, ya latency-critical ho. Manycore use karo agar: >95% parallel, SIMD-friendly, regular memory access, aur cores se 10-100× zyada threads bana sako.

Concept Map

forces

choice A

choice B

few powerful cores

many simple cores

includes

includes

includes

maximize

suits

suits

speedup modeled by

limited by

Transistor Budget Fixed

Fundamental Tradeoff

Multicore

Manycore

High Per-Thread Performance

High Throughput Capacity

Complex OoO Pipelines

Large Caches

Branch Prediction

Irregular Latency-Critical Code

High-Volume Parallel Tasks

Amdahl's Law

Serial Fraction 1-P