parallel computing

**Parallel computing** is the simultaneous use of multiple compute resources — cores, processors, accelerators, or nodes — to solve a problem faster or at larger scale. Every layer of the modern AI-chip stack, from SIMD vector units inside a single core to thousand-GPU training clusters, is a form of parallelism. ```svg Flynn Taxonomy Single Data Multiple Data Single Instr Multiple Instr SISD 1 instr 1 data stream serial CPU core SIMD 1 instr N data streams AVX / GPU lane MISD rare in practice fault-tolerant pipelines only MIMD N instrs N data streams multi-core, cluster Amdahl’s Law Speedup ≤ 1 / (s + (1−s)/N) s = serial fraction, N = processors s=0.05 → max speedup ≈20× (even ∞ cores) Gustafson: scale problem with N → linear gains Thread · Process · GPU SIMT Process (heavyweight) own address space · OS-scheduled · IPC via pipes/sockets/SHM context switch ~1–10 µs · multiprocessing.Pool, MPI ranks Thread (lightweight) shared heap · OS/user scheduled · sync via mutex/semaphore context switch ~0.1–1 µs · pthreads, OpenMP, std::thread GPU SIMT — 1000s of threads 1 warp = 32 threads, same instruction ×32 divergence: branches mask lanes (↑ waste) occupancy: active warps / max warps per SM H100: 132 SMs × 64 warps × 32 = 270,336 threads hide latency via warp switching, not clock speed shared mem = L1 scratchpad per SM block Parallelism Patterns Data Parallelism same op on different data shards SIMD lanes, GPU warps, PyTorch DDP, MPI allreduce strong scaling: fixed problem, add workers Task Parallelism different tasks on different processors pipeline stages, DAG workers, async I/O weak scaling: bigger problem, add workers Pipeline Parallelism (AI) model layers split across GPU ranks L1–4 L5–8 L9–12 L13–N bubble fill → micro-batch interleaving (GPipe) Tensor Parallelism (Megatron) split weight matrix across GPU ranks col-split A → row-split B → allreduce result needs NVLink for all-reduce bandwidth Synchronization Race condition: unsynchronized shared write Mutex: mutual exclusion, one thread at a time Semaphore: counting gate for N resources Barrier: all threads wait before proceeding Atomic op: read-modify-write in one instruction Lock-free: CAS loops, avoid OS overhead False sharing: cache-line ping-pong (avoid) Memory model: happens-before ordering rules CUDA: __syncthreads() within a block only Interconnects for Parallelism Scale-up: NVLink 4 → 900 GB/s bidirectional NVLink 5 (B200): 1800 GB/s bidi per GPU Scale-out: InfiniBand HDR 200 Gb/s per port Ethernet 400GbE for commodity GPU clusters AllReduce: ring (bandwidth-optimal) or tree NCCL: NVIDIA collective comms library Communication-computation overlap is critical ZeRO: shard optimizer state to cut memory Reduce bus contention: bucket gradients AI Chip Parallelism Stack Instruction-level: OOO, superscalar within core SIMD / tensor core: FP16/INT8 matrix tiles Thread-level: warps on SM, latency hiding Block-level: CTA across SMs, shared mem Data parallel: DDP, replicate model N GPUs Tensor parallel: column/row split (Megatron) Pipeline parallel: stages across GPU ranks Expert parallel: MoE routing across GPUs 3D parallel: DP × TP × PP combined ``` | Paradigm | Granularity | Latency | Examples | |---|---|---|---| | SIMD / Tensor core | 4–128 lanes | sub-ns | AVX-512, cuTENSOR MMA | | GPU warp (SIMT) | 32 threads | ns | CUDA, ROCm, PTX | | Multi-core / SMP | 2–512 cores | ns–µs | OpenMP, pthreads, TBB | | Multi-GPU (NVLink) | 2–8 GPUs | µs | DDP, tensor parallel | | GPU cluster (IB) | 100s–1000s | µs–ms | NCCL, MPI, ZeRO | | Wafer-scale (WSE) | 900K cores | ns on-chip | Cerebras CS-3 | **Flynn taxonomy** classifies parallel architectures by instruction and data multiplicity. SISD is a serial core. SIMD issues one instruction across N data lanes — the model behind CPU AVX, GPU warp lanes, and systolic-array columns. MIMD allows independent instruction streams on independent data, covering multi-core CPUs and GPU thread blocks simultaneously running different warps. MISD (multiple instruction, single data) is rare, appearing only in fault-tolerant redundant pipelines. **Amdahl's Law** defines the hard ceiling on speedup: if fraction *s* of a workload is inherently serial, no amount of parallelism can beat 1/s. At 5% serial fraction the ceiling is 20×, no matter how many cores are added. Gustafson's Law offers the optimistic counterpart — as you scale workers, scale the problem size too, and efficiency holds. AI training is close to Gustafson territory: more GPUs let you process bigger batches, not merely the same batch faster. **GPU SIMT architecture** hides memory latency differently from a CPU: instead of out-of-order execution, an SM switches instantly between warps when one stalls on memory. Occupancy — the ratio of active warps to the maximum the SM can hold — determines how well this latency hiding works. High occupancy requires small register footprint and shared memory usage per thread; this is the central trade-off in GPU kernel optimization. **Data parallelism in AI training** replicates the full model across GPU ranks, each processing a micro-batch shard. Gradients are synchronized via AllReduce (ring or tree) over NVLink or InfiniBand. ZeRO (Zero Redundancy Optimizer) shards optimizer states, gradients, and parameters across ranks, reducing per-GPU memory by up to 8× at the cost of extra communication. Tensor parallelism (Megatron-LM) partitions weight matrices across ranks — column-parallel for the first linear, row-parallel for the second, with a single AllReduce per transformer layer. Pipeline parallelism splits model layers across GPU ranks, using micro-batch interleaving (GPipe, PipeDream) to fill pipeline bubbles. **Communication-computation overlap** is the decisive engineering challenge. At scale, all-reduce communication of gradients must be overlapped with backward-pass computation using bucketed gradient synchronization. NVLink bandwidth (900 GB/s on H100, 1800 GB/s on B200) allows tensor-parallel communication within a node with minimal stall; InfiniBand (200 Gb/s) handles inter-node traffic but imposes latency that limits pipeline-parallel throughput. Read parallel computing through a **decomposition-and-synchronization-cost lens rather than a core-count lens**: the speedup you get depends entirely on how much of the work can be made independent and how cheaply independent pieces can be recombined — not on how many processors you can throw at it.

Go deeper with CFSGPT

Get AI-powered deep-dives, save terms, and run advanced simulations — free account.

Create Free Account