parallel-computing
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| parallel-computing [June 13, 2026 at 03:13] – external edit 127.0.0.1 | parallel-computing [June 15, 2026 at 15:47] (current) – Ivan Janevski | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| ## Map of parallel computing | ## Map of parallel computing | ||
| + | |||
| + | - [[introduction-to-parallel-computing]] | ||
| + | - [[saxpy]] | ||
| + | - [[synchronization-primitve]] | ||
| + | - [[sync-semaphore]] | ||
| + | - [[sync-mutex]] | ||
| + | - [[sync-monitor]] | ||
| + | - [[sync-linda]] | ||
| + | - [[sync-csp]] | ||
| + | - [[sync-mbox]] | ||
| + | - [[numbers-every-programmer-should-know]] | ||
| + | - [[amdahls-law]] | ||
| + | - [[gustafsons-law]] | ||
| + | - [[cache]] | ||
| + | - [[l1-cache]] | ||
| + | - [[l2-cache]] | ||
| + | - [[l3-cache]] | ||
| + | - [[cache-coherence]] | ||
| + | - [[cache-snoopy-protocols]] | ||
| + | - [[wti]] | ||
| + | - [[msi]] | ||
| + | - [[mesi]] | ||
| + | - [[moesi]] | ||
| + | - [[dragon]] | ||
| + | - [[firefly]] | ||
| + | - [[cache-directory-protocols]] | ||
| + | - [[cuda]] | ||
| - [[openmp]] | - [[openmp]] | ||
| - [[mpi]] | - [[mpi]] | ||
| - | + | - [[queuing-theory]] | |
| - | ## Three paradigms | + | - [[numa]] |
| - | + | - [[false-sharing]] | |
| - | Parallel computing splits into three broad paradigms based on where the parallelism lives. | + | - [[aba-problem]] |
| - | + | - [[trace-monoid]] | |
| - | **Shared-memory parallelism** runs multiple threads on a single machine with a common address space. | + | - [[hazard-pointer]] |
| - | + | | |
| - | **Distributed-memory parallelism** runs processes across separate machines (or separate address spaces on one machine), each with its own private memory. | + | - [[roofline-model]] |
| - | + | - [[numa]] | |
| - | **GPU parallelism** offloads computation to a GPU, which can run thousands of lightweight threads simultaneously. CUDA is NVIDIA' | + | - [[embarrassingly-parallel]] |
| - | + | | |
| - | ## Performance and correctness | + | - [[rcu]] |
| - | + | - [[lock]] | |
| - | Parallel programs introduce failure modes that serial programs don't have: race conditions, deadlocks, false sharing, memory ordering issues. A race condition occurs when two threads read and write shared data without synchronization and the outcome depends on the order of execution. A deadlock occurs when two threads are each waiting for a lock the other holds. False sharing is a subtler hardware-level issue: two threads write to different variables that happen to sit in the same cache line, causing the cache coherence | + | - [[lock-convoy]] |
| - | + | - [[lock-contention]] | |
| - | On the performance side, the [[roofline-model|roofline | + | - [[spinlock]] |
| - | + | - [[smp]] | |
| - | ## Practice | + | - [[flops]] |
| - | + | - [[gflops]] | |
| - | The fastest way to see parallelism pay off is to compile the same program twice — once without threading, once with — and time both. Here is a parallel | + | - [[tflops]] |
| - | + | - [[atomics]] | |
| - | ```c | + | - [[atomic-ops]] |
| - | // compile: gcc -O2 -fopenmp | + | - [[atomic-load-store]] |
| - | // run: OMP_NUM_THREADS=4 ./sum | + | |
| - | // description: | + | - [[atomic-store]] |
| - | + | - [[atomic-read-modify-write]] | |
| - | #include < | + | - [[atomic-test-and-set]] |
| - | #include < | + | |
| - | + | | |
| - | int main(void) { | + | - [[atomic-fetch-modify]] |
| - | long n = 1000000000L, | + | - [[atomic-fetch-arithmetic]] |
| - | | + | - [[atomic-fetch-inc]] |
| - | # | + | - [[atomic-fetch-dec]] |
| - | for (long i = 0; i < n; i++) | + | - [[atomic-fetch-add]] |
| - | sum += i; | + | - [[atomic-fetch-sub]] |
| - | | + | - [[atomic-fetch-bitwise]] |
| - | | + | - [[atomic-fetch-and]] |
| - | } | + | - [[atomic-fetch-or]] |
| - | ``` | + | - [[atomic-fetch-xor]] |
| - | + | - [[atomic-fetch-reduce]] | |
| - | Build and run both versions: | + | - [[atomic-fetch-min]] |
| - | + | - [[atomic-fetch-max]] | |
| - | ```bash | + | - [[atomic-flag]] |
| - | $ gcc -O2 -o sum_serial sum.c | + | - [[atomic-wait-notify]] |
| - | $ gcc -O2 -fopenmp | + | |
| - | $ ./ | + | |
| - | sum=499999999500000000 | + | - [[atomic-notify-all]] |
| - | $ OMP_NUM_THREADS=4 ./ | + | |
| - | sum=499999999500000000 | + | - [[memory-order]] |
| - | ``` | + | - [[memory-order-relaxed]] |
| - | + | - [[memory-order-consume]] | |
| - | The parallel version runs roughly 4× faster on 4 cores. The answer is identical — the `reduction(+: | + | - [[memory-order-acquire]] |
| - | + | - [[memory-order-acq-rel]] | |
| - | ## Concepts | + | - [[memory-order-seq-cst]] |
| - | + | - [[treiber-stack]] | |
| - | 1. [[amdahls-law|Amdahl' | + | - [[michael-scott-queue]] |
| - | 2. [[gustafsons-law|Gustafson' | + | - [[bespoke-algorithm]] |
| - | 3. [[roofline-model|Roofline model]] | + | - [[interconnect]] |
| - | 4. [[openmp|OpenMP]] | + | |
| - | 5. [[mpi|MPI]] | + | - [[rdma]] |
| - | 6. [[saxpy|SAXPY]] | + | |
| - | 7. [[semaphore|Semaphore]] | + | |
| - | 8. [[lock-free-queue|Lock-free queue]] | + | |
| - | 9. [[aba-problem|ABA problem]] | + | |
| - | 10. [[trace-monoid|Trace monoid]] | + | |
| - | 11. [[numbers-every-programmer-should-know|Numbers every programmer should know]] | + | |
| - | + | ||
| - | ## Overview | + | |
| - | + | ||
| - | ### Paradigms | + | |
| - | + | ||
| - | ^ Paradigm ^ Memory model ^ API ^ Typical scale ^ | + | |
| - | | Shared-memory | Common address space | [[openmp|OpenMP]], pthreads | Single node | | + | |
| - | | Distributed-memory | Private per process | [[mpi|MPI]] | Multi-node cluster | | + | |
| - | | GPU | Host + device | CUDA, HIP, OpenCL | Single GPU | | + | |
| - | | Hybrid | Mixed | MPI + OpenMP, MPI + CUDA | Multi-node + GPU | | + | |
| - | + | ||
| - | ### Laws and models | + | |
| - | + | ||
| - | ^ Name ^ Formula ^ What it predicts ^ | + | |
| - | | [[amdahls-law|Amdahl' | + | |
| - | | [[gustafsons-law|Gustafson' | + | |
| - | | [[roofline-model|Roofline model]] | $\min(\pi, | + | |
| - | + | ||
| - | ### Common failure modes | + | |
| - | + | ||
| - | ^ Issue ^ Cause ^ Detection ^ | + | |
| - | | Race condition | Concurrent unsynchronized read/write | Helgrind, ThreadSanitizer | | + | |
| - | | Deadlock | Circular lock dependency | Missing progress; `gdb` `info threads` | | + | |
| - | | False sharing | Two variables in the same cache line | `perf c2c`, cache miss counters | | + | |
| - | | Load imbalance | Unequal work distribution | Per-thread time profile | | + | |
| - | | Memory ordering | Relaxed atomics with wrong assumptions | Litmus tests; address and memory sanitizers | | + | |
parallel-computing.1781320400.txt.gz · Last modified: by 127.0.0.1
