4.1.24 · D1Computer Architecture (Deep)

Foundations — SIMD — vector instructions, SSE - AVX

1,659 words8 min readBack to topic

Before you can read the parent note, you must be able to look at a symbol like ymm0, _mm256_add_ps, or and see a picture. This page builds every one of those from nothing.


1. A bit, a byte, and "width"

Why the topic needs this: SIMD is entirely about how wide a register is. Every number in this chapter — 128, 256, 512 — is a bit count, a length measured in lightbulbs.

Figure — SIMD — vector instructions, SSE - AVX

2. A register, and why "wide" matters

Now the key move. A vector register is a register that is deliberately much wider than one number so several numbers can sit inside it at once.

Why the topic needs this: SSE/AVX/AVX-512 are just three widths of these boxes. The parent's names xmm (128), ymm (256), zmm (512) are the labels of these wide boxes.


3. Packing, elements, and lanes

This is the heart of every formula on the parent page, so we go slow.

Figure — SIMD — vector instructions, SSE - AVX

4. Float vs double — what ps and pd mean

The parent page's suffixes come from how a number is stored in bits. See Floating Point Representation for the full story; here is only what you need.

Why the topic needs this: in the lane formula comes from the suffix. Same register, different element size, different lane count: A double is twice as wide, so you fit half as many. That single fact explains why pd code is "half as parallel" as ps code.


5. What an "instruction" is, and the SIMD promise


6. Intrinsics — reading _mm256_add_ps

You never write raw SIMD by hand; you use intrinsics — C functions that map 1-to-1 to a machine instruction. Decode the name in pieces:

Why the topic needs this: the whole "HOW a vector add executes" section on the parent is just these decoded names. Once you can read the name, the code reads itself.


7. The two ceilings: lanes, Amdahl, bandwidth

Two symbols on the parent page describe why you never actually get lanes× speedup.

Figure — SIMD — vector instructions, SSE - AVX

How these foundations feed the topic

bit and byte

register width W

vector register xmm ymm zmm

element size e

packing and lanes

float vs double suffix ps pd

lanes = W over e

instruction fetch decode overhead

data level parallelism

SIMD one instruction many lanes

fraction f Amdahl

real speedup ceiling

memory bandwidth

The map reads left-to-right: raw bits build the register, element size cuts it into lanes, the overhead argument motivates why one instruction should drive them all, and the two ceilings ( and bandwidth) explain why reality falls short of lanes.


Equipment checklist

Cover the right side and answer each:

A bit vs a byte
A bit is one 0/1 switch; a byte is 8 bits.
256 bits is how many bytes?
32 bytes.
What is a register (vs RAM)?
A tiny bit-box inside the CPU, read/written instantly, far faster than RAM.
What does "packed" mean?
Several elements laid end-to-end in one wide register, no gaps.
What is a lane?
One element-sized slot in a vector register; each fires its own adder in parallel.
Formula for lane count?
lanes = W / e (register width bits ÷ element size bits).
Element size of f32 vs f64?
32 bits vs 64 bits.
What do the suffixes ps and pd mean?
packed single (f32) and packed double (f64).
Why does one SIMD instruction beat a scalar loop?
Fetch+decode overhead is paid once for many elements instead of once per element.
What does the _mm256 in an intrinsic name tell you?
256-bit register width → the AVX / ymm register.
What is in Amdahl's law?
The fraction of runtime that is vectorizable.
Why is real speedup below lanes×?
Non-vectorizable fraction (Amdahl) plus the memory-bandwidth ceiling.

Recall Quick self-test: AVX register holding doubles — how many lanes, and why not more?

lanes. A double is 64 bits, so only 4 fit end-to-end in a 256-bit box — half of what f32 gives.

Once every line above feels obvious, the parent note SIMD — vector instructions, SSE - AVX will read as pictures, not symbols.