---
title: "Problem set 1: performance, power and instruction sets"
heading: "Problem set 1: the iron law, Amdahl's law, power and encoding"
eyebrow: S4 · Problem set 1
type: problems
---

::: hook
These problems cover lessons 1 to 4: execution time and CPI, the memory wall, benchmark means, Amdahl's and Gustafson's laws, multicore sizing, power scaling and budgets, energy per task, and instruction encoding.
:::

::: pool
pick: 12

::: check
kind: parts
given: N = 2 | 6; a = 0.45 | 0.55; b = 0.25 | 0.3; f = 2 | 3.2

## A program of {N} billion instructions: {a} ALU (CPI 1), {b} memory (CPI 2.5), the rest branches (CPI 2), on a {f} GHz core.

::: part
answer: a*1 + b*2.5 + (1 - a - b)*2
tolerance: 0.5%

### CPI?

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

::: part
answer: N*(a*1 + b*2.5 + (1 - a - b)*2)/f
unit: s
tolerance: 0.5%

### Execution time?

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

::: check
kind: parts
given: c = 0.8 | 1.1; m = 0.008 | 0.02; M = 70 | 110; f = 2 | 3

## A core with pipeline CPI {c} at {f} GHz misses {m} times per instruction to a {M} ns memory.

::: part
answer: c + m*M*f
tolerance: 0.5%

### Total CPI?

::: misses
- [any] Add the miss penalty in cycles.
:::
:::

::: part
answer: (c + m*M*f)/(c + m*M*2*f)*2
tolerance: 0.5%

### Speedup from doubling the clock?

::: misses
- [any] Compare time per instruction.
:::
:::
:::

::: check
kind: parts
given: N = 1 | 3; C = 1.4 | 2; f = 2.4 | 3; J = 1.3 | 4; D = 1 | 1.2; g = 2 | 3.6

## Machine A: {N} billion instructions, CPI {C}, {f} GHz. Machine B: {J} billion, CPI {D}, {g} GHz.

::: part
answer: (N*C/f)/(J*D/g)
tolerance: 0.5%

### B's speedup over A?

::: misses
- [any] time_A / time_B.
:::
:::

::: part
answer: (g*1e3/D)/(f*1e3/C)
tolerance: 0.5%

### B's MIPS over A's MIPS?

::: misses
- [any] Ratio of f/CPI.
:::
:::
:::

::: check
kind: parts
given: a = 1.3 | 2.6; b = 0.7 | 1.9; c = 3.2 | 5

## A machine's ratios on three benchmarks are {a}, {b} and {c}.

::: part
answer: (a*b*c)^(1/3)
tolerance: 0.5%

### Geometric mean?

::: misses
- [any] Cube root of the product.
:::
:::

::: part
answer: (a + b + c)/3
tolerance: 0.5%

### Arithmetic mean (for comparison)?

::: misses
- [any] Sum over three.
:::
:::
:::

::: check
kind: parts
given: F = 0.85 | 0.95; N = 8 | 32 | 128

## A program is {F} parallel.

::: part
answer: 1/((1 - F) + F/N)
tolerance: 0.5%

### Amdahl speedup on {N} processors?

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

::: part
answer: 1/(1 - F)
tolerance: 0.5%

### Limit with unlimited processors?

::: misses
- [any] $1/(1 - F)$.
:::
:::

::: part
answer: N - (1 - F)*(N - 1)
tolerance: 0.5%

### Gustafson speedup if {F} is the scaled run's parallel fraction?

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

::: check
kind: parts
given: F = 0.3 | 0.5; S = 5 | 20; G = 0.1 | 0.3; T = 2 | 4; t = 2 | 3

## Two enhancements: {F} of the time sped up {S}×, and a separate {G} sped up {T}×.

::: part
answer: 1/((1 - F - G) + F/S + G/T)
tolerance: 0.5%

### Overall speedup?

::: misses
- [any] Sum the new times.
:::
:::

::: part
answer: (1 - 1/t)/(1 - 1/S)
tolerance: 0.5%

### What fraction of the time would the first enhancement alone have to cover for an overall speedup of {t}?

::: misses
- [any] Solve Amdahl's law for F.
:::
:::
:::

::: check
kind: parts
given: f = 0.95 | 0.99; n = 64 | 256; r = 2 | 8 | 32

## A symmetric chip of {n} base units with cores of {r} units (performance $\sqrt r$), on code that's {f} parallel.

::: part
answer: n/r
tolerance: 0

### Number of cores?

::: misses
- [any] n/r.
:::
:::

::: part
answer: 1/((1 - f)/sqrt(r) + f*r/(sqrt(r)*n))
tolerance: 0.5%

### Speedup?

::: misses
- [any] Serial on one core, parallel on all.
:::
:::
:::

::: check
kind: parts
given: v = 0.8 | 1; g = 1 | 1.1; n = 3 | 6

## Each generation scales dimensions by √2, the voltage by {v} and the clock by {g}.

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

### Power-density growth per generation?

::: misses
- [any] $Sv^2g$.
:::
:::

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

### Fraction usable at full speed after {n} generations?

::: misses
- [any] Inverse of the accumulated growth.
:::
:::
:::

::: check
kind: parts
given: f = 3 | 3.6; P = 90 | 125; Q = 150 | 200; N = 8 | 12; k = 2 | 3

## A core runs at {f} GHz on {P} W (power ∝ $f^3$); a chip has {N} cores sharing one budget.

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

### Clock for a {Q} W budget?

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

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

### Turbo clock with {k} of the {N} cores active (from {f} GHz with all active)?

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

::: check
kind: parts
given: c = 2 | 3; e = 8 | 12; L = 4 | 18; f = 3 | 1.5; V = 1 | 0.8

## A task of {c} billion cycles at {f} GHz and {V} V: {e} nJ per cycle at 1 V (∝ $V^2$), leakage {L} W at 1 V (∝ V).

::: part
answer: c*e*V^2 + L*V*c/f
unit: J
tolerance: 0.5%

### Energy?

::: misses
- [any] Dynamic plus leakage × time.
:::
:::

::: part
answer: (c*e*V^2 + L*V*c/f)*c/f
unit: J*s
tolerance: 0.5%

### Energy-delay product?

::: misses
- [any] Energy × time.
:::
:::
:::

::: check
kind: parts
given: R = 16 | 64; k = 7 | 9; b = 12 | 20; g = 2 | 4

## A 32-bit ISA with {R} registers and a {k}-bit opcode in I-type, and branch offsets of {b} bits in {g}-byte units.

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

### Register bits in an R-type instruction?

::: misses
- [any] Three fields.
:::
:::

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

### I-type immediate bits?

::: misses
- [any] What's left after two fields and the opcode.
:::
:::

::: part
answer: 2^(b - 1)*g
unit: B
tolerance: 0

### Backward branch reach?

::: misses
- [any] $2^{b-1}g$.
:::
:::
:::

::: check
kind: parts
given: c = 0.45 | 0.6; f = 0.2 | 0.3; C = 1.1 | 1.3; d = 2.2 | 3; t = 1 | 1.05

## A program has {c} of its instructions compressible to 16 bits; and {f} of its instructions are loads used only by the next instruction, which a register-memory ISA could fuse (fused CPI {d}, clock period ×{t}, base CPI {C}).

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

### Compressed code size, as a percentage?

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

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

### Fused version's time relative to load-store?

::: misses
- [any] Cycles per original instruction, times the period ratio.
:::
:::
:::

::: check
kind: parts
given: c = 0.8 | 1.2; m = 0.01 | 0.03; t = 60 | 100; f = 2 | 3; g = 2 | 3

## A core with base CPI {c} misses to a {t} ns memory on {m} of its instructions; its clock goes from {f} GHz to {g} times that.

::: part
answer: (c + m*t*f)/f
unit: ns
tolerance: 0.5%

### How long does an instruction take at {f} GHz?

::: misses
- [any] (CPI) ÷ f, with the penalty in cycles = ns × GHz.
:::
:::

::: part
answer: ((c + m*t*f)/f)/((c + m*t*f*g)/(f*g))
tolerance: 0.5%

### How much faster is it at the higher clock?

::: misses
- [g] The memory penalty doesn't shrink with the clock.
- [any] Old time per instruction over new.
:::
:::
:::

::: check
kind: parts
given: a = 0.2 | 0.4; s = 5 | 20; b = 0.1 | 0.3; t = 2 | 4; c = 0.1 | 0.2; u = 1.5 | 3

## Three enhancements speed up disjoint fractions of a program's time: {a} by {s}, {b} by {t}, and {c} by {u}.

::: part
answer: 1/((1 - a - b - c) + a/s + b/t + c/u)
tolerance: 0.5%

### What is the overall speedup?

::: misses
- [any] $1/((1 - \sum F_i) + \sum F_i/S_i)$.
:::
:::

::: part
answer: 1/(1 - a - b - c)
tolerance: 0.5%

### What is the most these three parts could ever give?

::: misses
- [any] Make every enhanced part take no time.
:::
:::
:::

::: check
kind: parts
given: S = 1.4 | 2; v = 0.9 | 1; n = 2 | 4 | 6

## Each generation shrinks dimensions by {S} while voltage scales by only {v} and frequency is held.

::: part
answer: S*v^2
tolerance: 0.5%

### By what factor does power density grow per generation?

::: misses
- [any] $Sv^2g$ with g = 1.
:::
:::

::: part
answer: (S*v^2)^(-n)*100
unit: %
tolerance: 0.5%

### What fraction of the chip can run at full speed after {n} generations?

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