---
title: "Problem set 5: memory systems and data parallelism"
heading: "Problem set 5: virtual memory, DRAM, vectors and GPUs"
eyebrow: S4 · Problem set 5
type: problems
---

::: hook
These problems cover lessons 24 to 29: TLB reach, page-table depth and translation cost, nested translation, virtually indexed caches and page faults, DRAM timing, bandwidth and refresh, misses in flight and NUMA, vector strip mining and peak rates, and GPU occupancy, divergence and coalescing.
:::

::: pool
pick: 12

::: check
kind: parts
given: E = 64 | 1024; P = 4 | 2048; V = 48 | 57; p = 12 | 21

## A TLB of {E} entries with {P} KB pages; a {V}-bit address space with $2^{\given{p}}$-byte pages and 8-byte entries.

::: part
answer: E*P
unit: KB
tolerance: 0.5%

### TLB reach?

::: misses
- [any] Entries × page size.
:::
:::

::: part
answer: ceil((V - p)/(p - 3) - 0.0001)
tolerance: 0

### Page-table levels?

::: misses
- [any] $\lceil (V - p)/(p - 3) \rceil$.
:::
:::
:::

::: check
kind: parts
given: T = 0.5 | 1; M = 80 | 120; h = 0.97 | 0.995; L = 4 | 5; P = 4; w = 8 | 12

## Translation: TLB {T} ns, memory {M} ns, TLB hit rate {h}, {L}-level walks. And a {w}-way VIPT L1 with {P} KB pages.

::: part
answer: T + M + (1 - h)*L*M
unit: ns
tolerance: 0.5%

### Average access time?

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

::: part
answer: P*w
unit: KB
tolerance: 0

### Largest alias-free L1?

::: misses
- [any] Page × ways.
:::
:::
:::

::: check
kind: parts
given: V = 39 | 48; p = 12 | 13; e = 8; M = 70 | 100; F = 8 | 15

## A flat page table for a {V}-bit space with $2^{\given{p}}$-byte pages and {e}-byte entries; memory at {M} ns and page faults at {F} ms.

::: part
answer: 2^(V - p)*e/2^30
unit: GB
tolerance: 0.5%

### Flat table size?

::: misses
- [any] One entry per virtual page.
:::
:::

::: part
answer: 0.1*M*1e-9/(F*1e-3)
tolerance: 0.5%

### Largest fault rate for at most 10% slowdown?

::: misses
- [any] $p = 0.1t_M/F$.
:::
:::
:::

::: check
kind: parts
given: M = 3200 | 4800 | 6400; c = 2 | 8; n = 22 | 40; f = 1600 | 2400

## {c} channels of 64-bit DRAM at {M} MT/s, with a timing of {n} cycles at a {f} MHz clock.

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

### Peak bandwidth?

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

::: part
answer: n/f*1000
unit: ns
tolerance: 0.5%

### The timing in nanoseconds?

::: misses
- [any] Cycles ÷ clock.
:::
:::
:::

::: check
kind: parts
given: h = 0.35 | 0.65; C = 13 | 15; R = 14 | 16; P = 14 | 16; F = 300 | 450; I = 3.9 | 7.8

## Row hit rate {h} (misses are conflicts), $t_{CL}$ = {C}, $t_{RCD}$ = {R}, $t_{RP}$ = {P} ns; refresh blocks {F} ns every {I} µs.

::: part
answer: h*C + (1 - h)*(P + R + C)
unit: ns
tolerance: 0.5%

### Average latency to first data?

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

::: part
answer: 100*F/(I*1000)
unit: %
tolerance: 0.5%

### Refresh overhead?

::: misses
- [any] $t_{RFC}/t_{REFI}$.
:::
:::
:::

::: check
kind: parts
given: b = 16 | 32; r = 65536 | 131072; c = 1024; w = 8 | 16; B = 8 | 16; M = 4800 | 6400

## A DRAM chip of {b} banks × {r} rows × {c} columns × {w} bits; bursts of {B} transfers at {M} MT/s.

::: part
answer: b*r*c*w/2^30
unit: Gbit
tolerance: 0.5%

### Capacity?

::: misses
- [any] The product, in $2^{30}$ bits.
:::
:::

::: part
answer: B/(M*1e6)*1e9
unit: ns
tolerance: 0.5%

### Burst time?

::: misses
- [any] Transfers ÷ rate.
:::
:::
:::

::: check
kind: parts
given: n = 300 | 1200; M = 64 | 128; L = 12 | 15; S = 40 | 60; C = 2 | 3

## A vector loop over {n} elements: MVL {M}, {L} cycles of loop overhead and {S} of startup per strip, {C} chimes.

::: part
answer: ceil(n/M - 0.0001)
tolerance: 0

### Strips?

::: misses
- [any] $\lceil n/\text{MVL} \rceil$.
:::
:::

::: part
answer: (ceil(n/M - 0.0001)*(L + S) + n*C)/n
tolerance: 0.5%

### Cycles per element?

::: misses
- [any] Total cycles over n.
:::
:::
:::

::: check
kind: parts
given: c = 12 | 48; f = 2.4 | 3.2; u = 1 | 2; W = 256 | 512; e = 32 | 64

## A chip of {c} cores at {f} GHz, each with {u} FMA unit(s) of {W} bits, on {e}-bit numbers.

::: part
answer: W/e
tolerance: 0

### Lanes?

::: misses
- [any] W/e.
:::
:::

::: part
answer: c*f*u*W/e*2
unit: GFLOPS
tolerance: 0.5%

### Peak rate?

::: misses
- [any] Cores × clock × units × lanes × 2.
:::
:::
:::

::: check
kind: parts
given: b = 16 | 32; s = 2 | 8; m = 3 | 4; n = 128 | 256; L = 4 | 8

## {b} memory banks read at a stride of {s} words; a loop of {m} convoys over {n} elements on {L} lanes.

::: part
answer: b/s
tolerance: 0

### Banks used?

::: misses
- [any] b/s.
:::
:::

::: part
answer: m*n/L
tolerance: 0.5%

### Cycles, ignoring startup?

::: misses
- [any] $mn/L$.
:::
:::
:::

::: check
kind: parts
given: R = 65536; r = 40 | 64 | 100; W = 64; L = 350 | 600; c = 12 | 30

## An SM with {R} registers and room for {W} warps, a kernel using {r} registers per thread, a {L}-cycle memory latency and {c} cycles of work per warp between accesses.

::: part
answer: (W + floor(R/(r*32) + 0.0001) - abs(W - floor(R/(r*32) + 0.0001)))/2
tolerance: 0

### Warps that fit?

::: misses
- [any] min(W, ⌊R/32r⌋).
:::
:::

::: part
answer: L/c
tolerance: 0.5%

### Warps needed to hide the latency?

::: misses
- [any] L/c.
:::
:::
:::

::: check
kind: parts
given: k = 6 | 10 | 26; A = 12 | 24; B = 6 | 18; s = 1 | 4 | 8

## A warp splits with {k} threads on {A} instructions and the rest on {B}; it also loads 4-byte words at a stride of {s}.

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

### Lane efficiency?

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

::: part
answer: (32 + 4*s - abs(32 - 4*s))/2
tolerance: 0

### 32-byte sectors touched?

::: misses
- [any] min(32, 4s).
:::
:::
:::

::: check
kind: parts
given: N = 84 | 144; l = 64 | 128; f = 1.5 | 2; B = 2 | 3.3

## A GPU of {N} SMs × {l} FP32 lanes at {f} GHz, with {B} TB/s of memory bandwidth.

::: part
answer: N*l*2*f/1000
unit: TFLOPS
tolerance: 0.5%

### Peak FP32 rate?

::: misses
- [any] SMs × lanes × 2 × clock.
:::
:::

::: part
answer: N*l*2*f/1000/B
tolerance: 0.5%

### FLOPs per byte needed to keep the arithmetic busy?

::: misses
- [any] Peak rate over bandwidth (TFLOPS per TB/s).
:::
:::
:::

::: check
kind: parts
given: n = 3 | 4 | 5; m = 3 | 4 | 5; a = 15 | 25

## A guest's page tables have {n} levels and the host's {m}; each walk access takes {a} ns.

::: part
answer: ((n + 1)*(m + 1) - 1)*a
unit: ns
tolerance: 0.5%

### How long can a nested TLB miss take?

::: misses
- [any] $((n + 1)(m + 1) - 1)$ accesses.
:::
:::
:::

::: check
kind: parts
given: B = 150 | 400; L = 90 | 130; m = 12 | 20

## Memory delivers {B} GB/s at {L} ns latency in 64-byte lines; each core keeps {m} misses in flight.

::: part
answer: m*64/L
unit: GB/s
tolerance: 0.5%

### What bandwidth can one core sustain?

::: misses
- [any] MSHRs × line ÷ latency.
:::
:::

::: part
answer: ceil(B*L/(64*m) - 1e-9)
unit: cores
tolerance: 0

### How many cores saturate the memory?

::: misses
- [any] Lines in flight over MSHRs per core.
:::
:::
:::

::: check
kind: parts
given: a = 90 | 110; b = 150 | 200; r = 0.1 | 0.4

## Local memory takes {a} ns and remote {b} ns; {r} of accesses go remote.

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

### What is the average latency?

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