Lecture 05 · Vectorized Execution on CPUs

The whole deck on two pages.

Page numbers are the numbers printed on the slides of ../lectures/Lecture_05_Vectorization.pdf (from slide 26 on, PDF page + 1).

SIMD basics

Extension Registers Width fp32 lanes p.
SSE (1999) — 128 bit 4 14
AVX2 16 256 bit 8 15
AVX-512 32 512 bit 16 15
lanes = register bits ÷ element bits

Three ways to vectorize

Option How Catch p.
automatic compiler rewrites simple loops simple loops are rare; aliasing blocks it 18–20
hints restrict (distinct arrays), #pragma ivdep (ignore dependencies) restrict not in C++ standard; ivdep correctness is on you 21–23
intrinsics _mm256_load_ps, _mm256_mul_ps, _mm256_store_ps potentially not portable 24, 26

Dependencies and fixes

Where it pays

2010 (i7-960) 2026 (Ryzen 9 9950X)
Peak fp32 GFLOP/s 102 ~5 100
DRAM bandwidth 32 GB/s ~90 GB/s
Bandwidth needed for peak ~1.2 TB/s ~61 TB/s
DRAM too slow by ~38× ~680×

p.52

Exam-style questions

The deck has no exam-style slide. The lesson's written section has four practice questions.