Parallel & Distributed Systems
Mid-Sem CAT-1 revision reference for Chapters 1 & 2. Every syllabus topic below is broken down concept-first, then tagged to the exact 3 / 6 / 6 / 10 question pattern via Bloom's levels. Formulas and definitions are boxed and enlarged — scan for the gold and blue blocks.
Introduction to Parallel Computing
Flynn's taxonomy · parallel computer types · system characteristics · computing models · interconnection networks · dataflow · parallel algorithms · MapReduce & Spark
Flynn's Taxonomy & Levels of Parallelism
High-yield · 10Concept
A serial uniprocessor reads one instruction and acts on one datum at a time. To go faster we replicate processing components. In 1966 Michael Flynn classified all architectures by how many instruction streams and data streams run concurrently. Everything builds on the Von Neumann architecture — Memory, Control Unit, ALU, I/O — with instructions and data stored together (stored-program).
| Class | Meaning | Nature | Examples |
|---|---|---|---|
| SISD | Single Instr, Single Data | Serial uniprocessor, deterministic | Single-core PC, old mainframes |
| SIMD | Single Instr, Multiple Data | Lockstep, one control unit → many PUs | GPUs, vector/array processors, ILLIAC IV |
| MISD | Multiple Instr, Single Data | Mostly theoretical, no real commercial HW | Fault-tolerant filters; debated: pipelines |
| MIMD | Multiple Instr, Multiple Data | Autonomous procs, sync or async | Multi-core CPUs, clusters, supercomputers |
MIMD sub-classification
Split by memory organization (Global vs Distributed) × communication (Shared Variables vs Message Passing):
| Code | Memory | Comm. | Common name |
|---|---|---|---|
GMSV | Global | Shared vars | Shared-Memory Multiprocessor (SMP) |
GMMP | Global | Msg passing | Rare in practice |
DMSV | Distributed | Shared vars | Distributed Shared Memory (DSM) |
DMMP | Distributed | Msg passing | Multicomputers / Clusters |
Four levels of parallelism (grain: large → fine)
- Task-level (large grain) — distinct threads/processes on MIMD processors.
- Data-level (medium) — identical op on distinct data chunks, via SIMD.
- Instruction-level (ILP) (fine) — overlap independent instructions, e.g. pipelining.
- Bit-level (very fine) — wider words (32/64-bit) so all bits process in one cycle.
Types of Parallel Computers
High-yield · 10Concept
MIMD machines split by how memory is accessed. Shared memory multiprocessors share one global address space — any CPU reads/writes any location directly. Distributed memory multicomputers give every CPU private memory; they communicate only by explicit messages over a network.
UMA (SMP) NUMA (DSM) DISTRIBUTED (Cluster) CPU CPU CPU CPU [CPU|Local Mem]<=QPI=>[CPU|Local Mem] [CPU|Mem]<=net=>[CPU|Mem] | | | | fast local, slow remote no shared address space == SHARED BUS == Send()/Receive() only Main Memory
| Aspect | Shared Memory | Distributed Memory |
|---|---|---|
| Address space | Single global | Disjoint private per node |
| Communication | Implicit via shared vars | Explicit Send()/Receive() |
| Scalability | Low–moderate (bus contention, coherence) | Very high (1000s of nodes) |
| Programming | Easier | Harder (partition + manage msgs) |
| Standard | OpenMP / Pthreads | MPI |
Characteristics of Parallel Systems
High-yield · 10Concept
Four metrics describe how tightly processors are bound and how efficiently they cooperate: Coupling, Speedup, Concurrency, Granularity.
T(1) = 1-processor time · T(n) = n-processor timecoarse-grained · low ratio → fine-grainedParallel Computing Models — RAM · PRAM · BSP · LogP
High-yield · 10Concept
A computing model is a hardware-independent blueprint for reasoning about algorithms. RAM = ideal sequential machine (1 op / unit time). PRAM = ideal parallel machine: p synchronous processors share one memory, any location in O(1). Because PRAM ignores real wires/caches, bridging models BSP and LogP add realism.
BSP — Bulk Synchronous Parallel
Executes in supersteps: (1) local computation → (2) communication via an h-relation → (3) global barrier synchronization.
w local work · h max msgs · g gap/word · l barrier latency · p procsLogP
Asynchronous distributed model — no barrier. Four params: L latency · o overhead (CPU busy per msg) · g gap between msgs · P processors.
60 + (3×20) + 12 = 60 + 60 + 12 = 13210 + 2(2) + (20−1)×3 = 10 + 4 + 57 = 71Why PRAM is unrealistic
- Unit-time memory access ignores wire delay & distance.
- No cache hierarchy (no L1/L2/L3, no locality).
- Assumes a strict global clock (no drift).
- Ignores bus/network contention.
Interconnection Networks & Switching
High-yield · 10Concept
The interconnection network is the "highway system" linking processors/memory, modeled as graph G=(V,E). Topologies define wiring layout; switching strategies define how data moves along it.
Static networks = fixed wiring (Linear, Mesh, Torus, Hypercube, CCC, Butterfly). Dynamic = switch-established on the fly (Bus, Crossbar, Multistage/Omega).
| Topology | Diameter | Degree | Bisection | Cost |
|---|---|---|---|---|
| Completely Connected | 1 | p−1 | p²/4 | p(p−1)/2 |
| 2D Mesh | 2(√p−1) | 4 | √p | 2(p−√p) |
| 2D Torus | 2⌊√p/2⌋ | 4 | 2√p | 2p |
| k-D Hypercube | log₂p | log₂p | p/2 | (p·log₂p)/2 |
| CCC (k≥3) | O(log p) | 3 | p/2k | 3p/2 |
| Butterfly | 2k | 4 | p/2k | 2p |
Switching strategies
- Circuit switching — reserve full path end-to-end via probe before sending (like a phone call).
- Store-and-Forward — each switch buffers the whole packet before forwarding → high latency.
- Cut-through / Wormhole — forward as soon as header is parsed; wormhole splits packets into flits, buffering across preceding switches if blocked → minimal switch memory.
10⁶ m / 2×10⁸ = 5 ms10⁶ / 12.5×10⁶ = 80 msDataflow Model & Stream Processing
High-yield · 10Concept
Von Neumann is control-driven — a program counter steps through instructions regardless of data readiness. Dataflow is data-driven: an instruction fires the instant all its input operands (tokens) arrive — no program counter. Stream processors / GPUs apply this to data-parallel workloads, explicitly staging data on-chip and overlapping compute with memory transfer.
| Static Dataflow | Dynamic Dataflow | |
|---|---|---|
| Fire when | Input tokens present AND output arcs empty | Input tokens with matching tags present |
| Mechanism | Acknowledgment flags (0/1) | Token tagging + tag-matching unit |
| Tokens/arc | One at a time | Multiple concurrent |
| Enables | Basic parallelism | Loop & recursion parallelism |
Stream processing architecture
- Scalar Unit — top-level controller running stream-control programs.
- Stream Unit — runs compute kernels on clusters + manages bulk memory transfers.
- Kernel — small code block applied repeatedly across a stream, e.g.
C[i]=A[i]+B[i]. - Storage hierarchy: LRF (local register files, nearest ALUs) → SRF (stream register files, on-chip staging) → SLS (stream load/store, bulk async DRAM transfers).
Parallel accelerators: GPGPUs use SIMD/SIMT across Stream Multiprocessors (SMs); Intel Xeon Phi uses MIMD. Execution: Host→Device transfer over PCIe → kernel execution → Device→Host result (CUDA/OpenCL).
Parallel Algorithms & Load Balancing
High-yield · 10Concept
Three questions: which problems can be sped up? how do we divide work? how do we assign tasks so no processor idles?
Five types of parallelization
- Functional (task) — split into distinct heterogeneous tasks per processor.
- Data — partition data; identical op on each chunk (SIMD-style).
- Recursive — divide-and-conquer sub-problems (parallel quicksort/mergesort).
- Exploratory — search a state space in parallel (game trees, maze/pathfinding).
- Speculative — run multiple branch paths before the condition resolves; discard unused.
| Feature | Static Load Balancing | Dynamic Load Balancing |
|---|---|---|
| Mapping | Compile-time, pre-execution | Runtime (work-stealing / task queues) |
| Overhead | Zero runtime overhead | Monitoring + migration overhead |
| Workload fit | Regular, predictable (dense matrix) | Irregular, non-deterministic (graphs) |
| Hardware | Homogeneous | Handles heterogeneous speeds |
MapReduce & Spark
Syllabus-only · verify PPTConcept
MapReduce is a programming model for processing huge datasets across a distributed cluster in two phases. Spark is a faster successor that keeps data in memory.
(key, value) pairs. Shuffle & Sort: group all values by key. Reduce: aggregate values per key → final output. Canonical example: word count.Parallel Computing Architecture
Shared memory paradigm & hierarchy · cache coherence & MSI · memory consistency models · shared memory vs message passing · routing & Kafka
Shared Memory Paradigm & Memory Hierarchy
High-yield · 10Concept
All cores share one global address space; caches sit next to each core to avoid slow DRAM trips. Three design axes: core arrangement, cache mapping, write policy.
| Paradigm | Structure | Memory |
|---|---|---|
| Classic Multicore | Identical cores, private L1/L2, shared L3 | UMA (uniform) |
| Multi-Socket (NUMA) | Multiple sockets, local + remote nodes via QPI/HT | Non-uniform |
| Asymmetric (AMC) | Fast + simple cores, DVFS | Amdahl-optimized |
Cache mapping
| Scheme | Placement | HW cost | Thrashing |
|---|---|---|---|
| Direct-mapped | Exactly 1 fixed line | Low | High |
| Set-associative | Any line within a set | Moderate | Low–moderate |
| Fully associative | Any line (parallel search) | High | Lowest |
Cache Coherence & MSI Snooping Protocol
High-yield · 10Concept
Each core caches shared variable X privately. If core A modifies X, core B's copy is stale — the cache coherence problem. Fixed in hardware: cache controllers snoop the shared bus and invalidate/update copies on every write.
Invalidate vs Update
- Write-Invalidate — broadcast one invalidation signal → other copies marked Invalid; writer gains exclusive access, later writes need no bus traffic. Low bandwidth · most used.
- Write-Update — broadcast every new data word to all caches live. High bandwidth · rarely used.
CPU Read / BusRd CPU Write / BusRdX
(I) ───────────────────► (S) ───────────────────► (M)
▲ │ CPU Write/Invalidate │
│ Bus Write/Invalidate │◄────────────────────────┘
└────────────────────────┘ Bus Read → write-back → S
Bus Write → write-back → I
| Step | Action | Bus | P1 | P2 | Mem X |
|---|---|---|---|---|---|
| 1 | P1 reads X | BusRd | S | I | 0 clean |
| 2 | P2 reads X | BusRd | S | S | 0 clean |
| 3 | P1 writes 100 | BusRdX/Inval | M | I | 0 stale |
| 4 | P2 reads X | BusRd | S* | S | 100 updated |
Memory Consistency Models
High-yield · 10Concept
Coherence governs one address; consistency governs the ordering & visibility of reads/writes across multiple addresses. HW optimizations (write buffers, out-of-order, speculation) reorder memory ops for speed — the consistency model is the contract specifying what a read may legally return.
Canonical 2-processor example (X=0, Y=0)
P1: (1) Write X=1 P2: (3) Write Y=1
(2) Read Y (4) Read X
Under SC → forbidden result: (X=0, Y=0)
Under Relaxed → (X=0, Y=0) is possible (write buffers)
Why SC forbids (0,0): program order forces P1's Write X before its Read Y; if Read Y returns 0 then Write Y hasn't happened, so Write X already has → P2's Read X must return 1. At least one processor must read 1.
| Feature | Sequential Consistency | Relaxed |
|---|---|---|
| Program order | Strictly enforced | Relaxed for independent ops |
| (0,0) result | Forbidden | Allowed (unless fenced) |
| Performance | Lower (stalls) | Higher (buffers, OoO) |
| Programming | Intuitive | Harder (manual fences) |
Shared Memory vs Message Passing — Emulation & Primitives
High-yield · 10Concept
Two communication models: shared memory (write→read a shared location) vs message passing (explicit Send()/Receive() across private spaces). Either can emulate the other in software.
Primitives — two independent axes
| Synchronous | Asynchronous | |
|---|---|---|
| Blocking | Sender blocks until receiver gets data + acks | Sender blocks until data copied to kernel buffer |
| Non-blocking | Returns handle immediately; poll until ack | Returns handle immediately; poll until buffer safe to reuse |
| Aspect | Shared Memory | Message Passing |
|---|---|---|
| Address space | Global unified | Disjoint private |
| Comm. | Implicit shared vars | Explicit Send/Receive |
| Sync | Locks, semaphores, monitors | Acks, barriers |
| Fit | Multicore, SMPs | Clusters, NOWs |