Instruction Level Parallelism in Your C++ Program
summary
Modern CPUs expose instruction-level parallelism (ILP) but code, not hardware, limits it: short dependency chains (e.g., elementwise add) run in ~7 cycles, while a reduction or linked‑list walk costs ~n+3 cycles or ~3n cycles because loads add latency. Interleaving independent chains can nearly double throughput (runtime ratio → 2), unrolling/splitting accumulators increases ILP, and converting trees/lists to arrays or unrolled nodes removes chain latency (array lookups win past ~256k). Use llvm-mca to inspect latency vs throughput and apply interleaving or breaking chains.
AI-written summary · about
chapters (20)
- 0:00Introduction to CPUs
- 0:28Executing instructions
- 1:31Instruction dependencies
- 2:45Impact of dependencies
- 3:45Loop performance quiz
- 6:44Loop carry dependencies
- 8:18Linked list performance
- 10:20ILP and code quality
- 12:33Throughput vs latency
- 16:47Techniques to increase ILP
- 19:47Interleaving technique
- 22:45Parallel tree lookups
- 29:03Interleaving tradeoffs
- 35:03Shortening dependencies
- 39:03Data structures and ILP
- 43:57Reducing algorithm passes
- 45:16Breaking dependencies
- 48:13Array-based trees
- 50:12In-order processor constraints
- 55:54Performance analysis tools
