6.1.7 · D3Parallelism & Multicore

Worked examples — NUMA architectures

3,006 words14 min readBack to topic

This page is the drill hall for the NUMA topic note. The parent note built the theory; here we grind through every kind of number a NUMA question can throw at you. Before touching a single formula, we lay out a map of all the cases so you never meet a scenario cold.

Everything we use is already earned in the parent note, but we re-anchor each symbol the first time it appears, so a reader who jumped straight here still starts from zero.

Recall The three tools we reuse (from the parent)

NUMA factor — "how many times slower is far memory than near memory?" It is a plain ratio of two times, so it has no units (nanoseconds cancel nanoseconds). Average access time where is the fraction of accesses that go remote. Speedup vs all-remote . If any of these look strange, read NUMA architectures first — we do not re-derive them, we apply them.


The scenario matrix

Think of every NUMA numeric question as landing in exactly one cell below. Our examples (E1–E9) are placed so that every cell is hit at least once.

Cell Case class What is weird / extreme about it Covered by
C1 Baseline mixed — normal the ordinary 80/20 world E1
C2 Degenerate (all local) remote term vanishes E2
C3 Degenerate (all remote) hits its ceiling E2
C4 Degenerate (UMA) NUMA collapses to uniform E3
C5 Limiting remote is "infinitely" costly E3
C6 Multi-node latency table (per-hop) build from a hop map E4
C7 Address → node mapping (interleave vs range) integer floor/mod, sign of address E5
C8 Coherence 3-hop cost (false sharing) add message times, not ratios E6
C9 Real-world word problem (bandwidth GB/s) translate latency win into throughput E7
C10 Inverse question — solve for required algebra run backwards E8
C11 Exam twist — mixed nodes, weighted itself is a weighted average E9

E1 — Baseline mixed access (cell C1)

Forecast: guess the average — it's mostly local (80%), so expect to sit closer to 80 than to 160. Jot down your guess.

  1. Compute the NUMA factor. Why this step? is the single number that says "remote is slower". Every later formula wants this ratio, not the raw times.

  2. Plug into . Why this step? We are averaging two costs weighted by how often each happens: of the time we pay , of the time we pay .

  3. Compute the speedup over all-remote. Why this step? All-remote would cost ns. Our ns is faster — the speedup is exactly the ratio of the two.

Verify: , matching . Units: came out in ns (good, we multiplied a ns by a dimensionless bracket). is a pure ratio (, no units). Your forecast — was closer to than ? Yes. ✓


E2 — Both degenerate ends: and (cells C2, C3)

Forecast: the two answers should be ns and ns — the extremes the average can never leave.

  1. Set . Why this step? When nothing is remote, the term is switched off. collapses to pure — this is the floor.

  2. Set . Why this step? When everything is remote, the local term vanishes and we pay every time — the ceiling.

  3. Interpret the whole range as a straight line. For any in between, is a straight line rising from ns (at ) up to ns (at ). The figure below makes this concrete.

Figure — NUMA architectures

Verify: the E1 result ns must lie on this line: . ✓ Floor E1 ceiling: . ✓


E3 — Two more degenerate knobs: and (cells C4, C5)

Forecast: (a) if remote costs the same as local, NUMA-awareness should buy nothing. (b) if remote is unboundedly slow, the remote accesses dominate everything → should settle to a finite number, not infinity.

  1. Part (a), set . Why this step? This is the sanity check that NUMA reduces to UMA when far and near cost the same — the cancels entirely, so for every .

  2. Part (b), take the limit with . Divide top and bottom of by : Why this step? Dividing by the growing quantity turns the runaway term into . The message: no matter how slow remote gets, keeping local caps your win at . That remote is the anchor.

Verify: limit is . Cross-check with a large finite value, : , which is . ✓ Part (a): plug : . ✓


E4 — Building from a hop-latency table (cell C6)

Forecast: the "effective remote" time is the average of — around ns — so is a bit under .

  1. Average the three remote latencies. Why this step? "Evenly over nodes 1,2,3" means each remote access is equally likely to hit each — so the representative remote cost is the plain mean of the three.

  2. Form the effective NUMA factor (local is node 0 = ns). Why this step? always compares whatever "remote" means against local. Here remote is the averaged remote.

  3. Average access time with . Why this step? Same weighting as always — local at ns, remote at ns.

Verify: compute the direct way: ns. Matches step 3. ✓ Units: ns throughout. Forecast: , indeed just under 2. ✓


E5 — Address → node mapping: interleave vs range (cell C7)

Forecast: two different schemes, so probably two different node IDs for the same address — that's the whole point of the comparison.

  1. Interleaved: which cache line is this? Why this step? Interleaving assigns whole cache lines round-robin, so first we ask "which line number is in?" The floor throws away the byte offset inside the line (addresses are non-negative, so floor just drops the fraction — no sign trap here).

  2. Interleaved: mod by node count. Why this step? wraps the line number around the 4 nodes: line 0→node0, line1→node1, …, line4→node0. Line 320 is a multiple of 4, so it lands on node 0.

  3. Range-based: divide by node size. Why this step? Range-based gives each node a contiguous block of bytes. is past the first block () but inside the second () → node 1.

  4. Degenerate . Interleaved: . Range: . Both give node 0. Why this step? The lowest address always sits in node 0 under both schemes — a useful anchor to check your arithmetic direction.

Verify: interleaved node , range node — genuinely different, confirming interleave scatters while range keeps locality (why range-based enables first-touch affinity). → node 0 both ways. ✓


E6 — Coherence 3-hop cost from false sharing (cell C8)

Forecast: we are adding message times (not multiplying ratios), so expect a big sum — a few hundred ns — far worse than the ns local miss.

  1. Sum the 3-hop protocol stages. Why this step? Unlike latency ratios, coherence traffic is a chain of sequential events — each must finish before the next starts, so total time is their sum, not a product.

  2. Compare to a local L3 miss. Why this step? This ratio is the true cost of false sharing: the same logical operation is nearly slower because the line ping-pongs across the interconnect.

Verify: . ✓ . ✓ Units: all summands are ns → sum is ns; the slowdown is a pure ratio. Sanity: sum () sits in the " ns" range the parent quotes for 3-hop protocols. ✓


E7 — Real-world word problem: bandwidth from locality (cell C9)

Forecast: is a bit under of , so expect roughly a speedup and a runtime dropping from s to around s.

  1. Bandwidth speedup. Why this step? For a bandwidth-bound kernel, throughput is the performance metric, so the ratio of the two GB/s figures is the speedup directly.

  2. New runtime. A bandwidth-bound job moves a fixed amount of data ; time , so time scales inversely with bandwidth. Why this step? Same data, higher rate → proportionally less time. We multiply by the inverse bandwidth ratio because time and bandwidth are inversely related.

Verify: the bandwidth speedup. ✓ Units: , so time comes out in seconds. Forecast: , s — matches. ✓


E8 — Inverse question: what locality do I need? (cell C10)

Forecast: with remote slower and only a budget, the allowable remote fraction should be small — a rough one-in-eight kind of number.

  1. Write the constraint using . Why this step? We want the average not to exceed local. Divide both sides by (positive, so the inequality direction is safe) to get a pure-number condition.

  2. Simplify the bracket. Why this step? Combine like terms: . The is exactly , the "extra cost per unit of remote traffic".

  3. Solve for . Why this step? Isolate . The answer: no more than of accesses may be remote to stay within the budget.

Verify: plug back: — exactly the ceiling. ✓ Forecast said "one-in-eight" and . ✓


E9 — Exam twist: as a weighted average across phases (cell C11)

Forecast: overall is between and , pulled toward (since phase A weighs more) → guess about .

  1. Combine the two phases into one . Why this step? is "fraction of all accesses that are remote". Since phases contribute accesses in proportion , the overall remote fraction is their access-weighted average — you cannot just average and .

  2. Average access time. Why this step? Once is a single number, the standard formula applies unchanged.

  3. Speedup over all-remote. Why this step? All-remote would be ns; .

Verify: direct check , matches . ✓ Weighted : , and it lies between and , pulled below the midpoint — consistent with phase A's larger weight. ✓ This weighting logic is exactly what NUMA-aware algorithm design optimizes: shrink the big-weight phase's first.


Recall Self-test (cover the answers)

Local ns, remote ns, . Find . ::: Same numbers — find . ::: ns Interleaved: , line , nodes . Node? ::: If with , limiting speedup? :::