---
title: Final exam
heading: "Final exam: computer architecture"
eyebrow: S4 · Final exam
type: problems
---

::: hook
Twelve problems from the whole course: performance and power, instruction sets and pipelines, front ends, prediction and out-of-order execution, threads and caches, virtual memory, DRAM and NUMA, vectors and GPUs, rooflines, coherence and synchronization, security, data centers, accelerators, dependability, storage and evaluation. Give yourself three hours and work without the lessons open. "Another set" deals a different exam.
:::

::: pool
pick: 12

::: check
kind: parts
given: N = 3 | 8; C = 1.2 | 1.8; f = 2.5 | 4; F = 0.92 | 0.98; P = 32 | 128

## A program of {N} billion instructions at CPI {C} on a {f} GHz core, {F} of it parallel.

::: part
answer: N*C/f
unit: s
tolerance: 0.5%

### Time on one core?

::: misses
- [any] IC × CPI / f.
:::
:::

::: part
answer: N*C/f*((1 - F) + F/P)
unit: s
tolerance: 0.5%

### Time on {P} cores (Amdahl)?

::: misses
- [any] Serial part plus parallel part ÷ P.
:::
:::
:::

::: check
kind: parts
given: f = 2.8 | 3.4; P = 80 | 120; Q = 150 | 200; v = 0.8 | 0.95; n = 4

## A core at {f} GHz on {P} W (power ∝ $f^3$); generations at √2 scale voltage by {v} with a fixed clock.

::: part
answer: f*(Q/P)^(1/3)
unit: GHz
tolerance: 0.5%

### Clock at {Q} W?

::: misses
- [any] $f(Q/P)^{1/3}$.
:::
:::

::: part
answer: (sqrt(2)*v^2)^(-n)
tolerance: 0.5%

### Usable fraction after {n} generations?

::: misses
- [any] $(Sv^2)^{-n}$.
:::
:::
:::

::: check
kind: parts
given: R = 32 | 128; k = 7 | 9; c = 0.4 | 0.6; f = 0.15 | 0.25; C = 1.2; d = 2.5; t = 1.1

## A 32-bit ISA with {R} registers and a {k}-bit I-type opcode; {c} of instructions compressible to 16 bits; {f} of instructions are loads fusable with their consumer (fused CPI {d}, base CPI {C}, clock {t}× slower).

::: part
answer: 32 - 2*ceil(log(R - 0.5)/log(2)) - k
tolerance: 0

### I-type immediate bits?

::: misses
- [any] 32 minus two register fields and the opcode.
:::
:::

::: part
answer: 100*(1 - c/2)
unit: %
tolerance: 0.5%

### Compressed code size?

::: misses
- [any] $1 - c/2$.
:::
:::

::: part
answer: ((1 - 2*f)*C + f*d)*t/C
tolerance: 0.5%

### Fused version's relative time?

::: misses
- [any] Cycles per original instruction × period ratio.
:::
:::
:::

::: check
kind: parts
given: t = 90 | 150; o = 3 | 5; b = 0.03 | 0.06; N = 8 | 30

## {t} FO4 of logic, {o} FO4 of overhead per stage, {b} stalls per instruction per stage; a loop of {N} iterations runs repeatedly.

::: part
answer: sqrt(t/(o*b))
tolerance: 1%

### Optimal depth?

::: misses
- [any] $\sqrt{t/(ob)}$.
:::
:::

::: part
answer: 100*2/N
unit: %
tolerance: 0.5%

### 1-bit predictor misprediction rate on the loop?

::: misses
- [any] Two per run.
:::
:::
:::

::: check
kind: parts
given: c = 0.5 | 0.8; f = 0.2; a = 0.9 | 0.95; b = 0.97 | 0.99; P = 15 | 25; n = 12 | 14; B = 2000 | 8000

## A core with base CPI {c}, {f} branches and a {P}-cycle penalty; a predictor of $2^{\given{n}}$ counters shared by {B} branches.

::: part
answer: (c + f*(1 - a)*P)/(c + f*(1 - b)*P)
tolerance: 0.5%

### Speedup from accuracy {a} to {b}?

::: misses
- [any] Ratio of total CPI.
:::
:::

::: part
answer: 1 - (1 - 2^(-n))^(B - 1)
tolerance: 0.5%

### Aliasing probability?

::: misses
- [any] $1 - (1 - 2^{-n})^{B-1}$.
:::
:::
:::

::: check
kind: parts
given: w = 4 | 8; L = 30 | 60; W = 192 | 512; a = 0.96 | 0.99; g = 0.2; A = 64; r = 0.8

## A {w}-wide core averaging {L} cycles in flight, a {W}-entry window, branches every 5 instructions at {a}, {A} architectural registers, {r} of instructions writing one.

::: part
answer: (w + W/L - abs(w - W/L))/2
tolerance: 0.5%

### Sustainable IPC?

::: misses
- [any] min(w, W/L).
:::
:::

::: part
answer: (1 - a^(g*W))/(g*(1 - a))
tolerance: 0.5%

### Useful instructions in a full window?

::: misses
- [any] $\frac{1}{f}\frac{1 - a^{fW}}{1 - a}$.
:::
:::

::: part
answer: A + W*r
tolerance: 0.5%

### Physical registers?

::: misses
- [any] $A + Wr$.
:::
:::
:::

::: check
kind: parts
given: N = 36 | 60; C = 9 | 12; R = 15 | 30; L = 250 | 500; C2 = 6

## A block of {N} instructions with a {C}-long chain; threads running {R} cycles between {L}-cycle misses, coarse switching costing {C2} cycles.

::: part
answer: N/C
tolerance: 0.5%

### Dataflow IPC?

::: misses
- [any] N/C.
:::
:::

::: part
answer: (R + L)/R
tolerance: 0.5%

### Fine-grained threads to saturate?

::: misses
- [any] $(R + L)/R$.
:::
:::

::: part
answer: 100*R/(R + C2)
unit: %
tolerance: 0.5%

### Coarse-grained ceiling?

::: misses
- [any] $R/(R + C)$.
:::
:::
:::

::: check
kind: parts
given: h = 1 | 3; m = 0.04 | 0.07; k = 10 | 14; n = 0.3 | 0.45; M = 180 | 300; d = 16000 | 24000; F = 10000 | 13000; c = 3000 | 5000

## L1 {h} / {m}, L2 {k} / {n} local, memory {M} cycles; a program with {d} direct-mapped, {F} fully associative and {c} infinite-cache misses.

::: part
answer: h + m*(k + n*M)
tolerance: 0.5%

### AMAT?

::: misses
- [any] Nest the levels.
:::
:::

::: part
answer: d - F
tolerance: 0

### Conflict misses?

::: misses
- [any] DM − FA.
:::
:::
:::

::: check
kind: parts
given: N = 1024 | 2048; B = 32 | 64; L = 150 | 300; t = 25 | 50; T = 1 | 2; Mm = 100; hh = 0.97 | 0.99; Lv = 4

## A matrix multiply blocked by {B} on {N} × {N} matrices; a prefetching loop at {t} cycles per iteration with {L}-cycle latency; translation with a {T} ns TLB, {Mm} ns memory, {hh} TLB hit rate and {Lv}-level walks.

::: part
answer: (2*N^3 + N^2)/(2*N^3/B + N^2)
tolerance: 0.5%

### Traffic reduction?

::: misses
- [any] Ratio of traffic counts.
:::
:::

::: part
answer: ceil(L/t - 0.0001)
tolerance: 0

### Prefetch distance?

::: misses
- [any] $\lceil L/t \rceil$.
:::
:::

::: part
answer: T + Mm + (1 - hh)*Lv*Mm
unit: ns
tolerance: 0.5%

### Average translated access time?

::: misses
- [any] $t_T + t_M + (1 - h)Lt_M$.
:::
:::
:::

::: check
kind: parts
given: M = 4800 | 6400; c = 2 | 8; h = 0.4 | 0.7; Cl = 14 | 16; Rc = 14 | 16; Rp = 14 | 16

## {c} channels of {M} MT/s DRAM; row hit rate {h} with $t_{CL}$ {Cl}, $t_{RCD}$ {Rc}, $t_{RP}$ {Rp} ns (misses are conflicts).

::: part
answer: M*8*c/1000
unit: GB/s
tolerance: 0.5%

### Peak bandwidth?

::: misses
- [any] MT/s × 8 × channels.
:::
:::

::: part
answer: h*Cl + (1 - h)*(Rp + Rc + Cl)
unit: ns
tolerance: 0.5%

### Average latency?

::: misses
- [any] Weighted hit and conflict times.
:::
:::
:::

::: check
kind: parts
given: n = 500 | 3000; Mv = 64 | 128; Lp = 15; S = 50; Ch = 3; k = 8 | 24; A = 12 | 30; B = 6 | 20

## A vector loop of {n} elements (MVL {Mv}, {Lp} + {S} cycles per strip, {Ch} chimes); a GPU warp with {k} lanes on {A} instructions and the rest on {B}.

::: part
answer: (ceil(n/Mv - 0.0001)*(Lp + S) + n*Ch)/n
tolerance: 0.5%

### Vector cycles per element?

::: misses
- [any] Strips × per-strip cost + n × chimes, over n.
:::
:::

::: part
answer: 100*(k*A + (32 - k)*B)/(32*(A + B))
unit: %
tolerance: 0.5%

### Lane efficiency?

::: misses
- [any] Useful over issued lane-slots.
:::
:::
:::

::: check
kind: parts
given: F = 1000 | 4000; B = 100 | 800; I = 0.1 | 2 | 30

## A {F} GFLOPS, {B} GB/s machine and a kernel of intensity {I}.

::: part
answer: F/B
tolerance: 0.5%

### Ridge point?

::: misses
- [any] F/B.
:::
:::

::: part
answer: (F + B*I - abs(F - B*I))/2
unit: GFLOPS
tolerance: 0.5%

### Attainable?

::: misses
- [any] min(F, B·I).
:::
:::
:::

::: check
kind: parts
given: f = 3; m = 0.004 | 0.01; B = 64; W = 64 | 256; n = 500 | 5000; p = 0.5 | 0.85; N = 8 | 24

## Cores at {f} GHz with {m} bus misses per instruction on a {W} GB/s bus; a thread reading then writing {n} lines, {p} unshared, under MESI; {N} cores contending for a test-and-test-and-set lock.

::: part
answer: W/(f*m*B)
tolerance: 0.5%

### Cores at bus saturation?

::: misses
- [any] $W/(fmB)$.
:::
:::

::: part
answer: n + (1 - p)*n
tolerance: 0.5%

### MESI transactions?

::: misses
- [any] Reads plus upgrades for shared lines.
:::
:::

::: part
answer: N*(N - 1)
tolerance: 0

### Lock transactions until all have held it?

::: misses
- [any] $N(N - 1)$.
:::
:::
:::

::: check
kind: parts
given: N = 64 | 512; Bl = 64 | 128; k = 8 | 16; b = 32 | 64

## A {N}-core directory machine with {Bl}-byte lines, connected by a {k} × {k} torus of {b} GB/s links.

::: part
answer: 100*N/(8*Bl)
unit: %
tolerance: 0.5%

### Bit-vector overhead?

::: misses
- [any] $N/8B$.
:::
:::

::: part
answer: 2*k*b
unit: GB/s
tolerance: 0.5%

### Bisection bandwidth?

::: misses
- [any] 2k links.
:::
:::
:::

::: check
kind: parts
given: N = 30000 | 90000; p = 250 | 350; i = 0.3 | 0.5; u = 0.2 | 0.35; E = 1.1 | 1.25; Mt = 4 | 6; s = 0.01; k = 30 | 100

## {N} servers ({p} W peak, idle at {i}, running at {u}) with PUE {E} and an MTTF of {Mt} years; requests fan out to {k} servers each slow with probability {s}.

::: part
answer: N*(p*i + (p - p*i)*u)*E/1e6
unit: MW
tolerance: 0.5%

### Facility power?

::: misses
- [any] Servers × average power × PUE.
:::
:::

::: part
answer: N*24/(Mt*8760)
tolerance: 0.5%

### Failures per day?

::: misses
- [any] N × 24 / MTTF in hours.
:::
:::

::: part
answer: 100*(1 - (1 - s)^k)
unit: %
tolerance: 0.5%

### Slow requests?

::: misses
- [any] $1 - (1 - p)^k$.
:::
:::
:::

::: check
kind: parts
given: n = 128 | 256; B = 512 | 4096; S = 3 | 6; l = 60 | 120; Dk = 6 | 10; Md = 1000000; Rr = 24 | 48

## A {n} × {n} systolic array streaming {B} vectors per pass; a disk queue with {S} ms service and {l} requests per second; a RAID 5 of {Dk} disks (MTTF {Md} h, {Rr} h rebuild).

::: part
answer: 100*B/(B + 2*(n - 1))
unit: %
tolerance: 0.5%

### Array utilization?

::: misses
- [any] $B/(B + 2(n - 1))$.
:::
:::

::: part
answer: S/(1 - l*S/1000)
unit: ms
tolerance: 0.5%

### Mean response time?

::: misses
- [any] $S/(1 - \rho)$.
:::
:::

::: part
answer: Md^2/(Dk*(Dk - 1)*Rr)/8766
unit: yr
tolerance: 0.5%

### MTTDL?

::: misses
- [any] $M^2/(N(N - 1)R)$.
:::
:::
:::

::: check
kind: parts
given: w = 6 | 8; t = 7 | 12; b = 1 | 2; h = 0.8 | 0.9

## An {w}-wide front end meets a taken branch every {t} instructions with {b} bubble(s) each; its µop cache hits {h} of µops at {w} a cycle, and the decoders give 4.

::: part
answer: t/(ceil(t/w - 1e-9) + b)
tolerance: 0.5%

### What fetch rate does the taken-branch limit allow?

::: misses
- [any] $t/(\lceil t/w\rceil + b)$.
:::
:::

::: part
answer: 1/(h/w + (1 - h)/4)
tolerance: 0.5%

### What delivery rate does the µop cache mix allow?

::: misses
- [any] Harmonic combination.
:::
:::
:::

::: check
kind: parts
given: B = 200 | 400; L = 90 | 110; a = 90; b = 140 | 180; r = 0.25 | 0.5

## A socket's memory gives {B} GB/s at {L} ns in 64-byte lines; remote memory takes {b} ns against 90 locally, and {r} of accesses go remote.

::: part
answer: B*L/64
unit: lines
tolerance: 0.5%

### How many misses must be in flight for full bandwidth?

::: misses
- [any] Little's law.
:::
:::

::: part
answer: (1 - r)*90 + r*b
unit: ns
tolerance: 0.5%

### What is the average latency?

::: misses
- [any] Weighted average.
:::
:::
:::

::: check
kind: parts
given: t = 45 | 50; W = 32 | 64; n = 30000 | 80000

## DRAM rows cycle in {t} ns with a {W} ms refresh window; cells flip after {n} neighbor activations.

::: part
answer: W*1e-3/(t*1e-9)
tolerance: 0.5%

### How many activations fit in one window?

::: misses
- [any] $W/t_{RC}$.
:::
:::

::: part
answer: n*t*1e-6
unit: ms
tolerance: 0.5%

### How long does an attack take to reach the threshold?

::: misses
- [any] Activations × row cycle time.
:::
:::
:::
:::
