The Memory Hierarchy and Why Caching Works · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Small fast memory, big slow memory

Computing · Computer Systems · ages 18-19
Name ______________________   Date ____________
  1. A loop reuses the same value many times. Which locality is that?

    • Temporal locality
    • Spatial locality
    • No locality
  2. Which order lists the layers from fastest to slowest?

    • Main memory, caches, registers, disk
    • Registers, caches, main memory, disk
    • Disk, main memory, caches, registers
  3. Spatial locality means touching neighbours next.

    Circle one:   True   False

  4. A loop reads cells 0, 1, 2, 3 in order. Which locality does it use?

    • Spatial locality
    • Temporal locality
    • Neither locality
  5. Why can column by column run several times slower on the same data?

    • It visits fewer cells
    • It sorts the array first
    • It jumps across rows
  6. Which layer is the smallest and fastest?

    • Main memory
    • Registers
    • Disk
  7. Loop A steps through neighbours in order. Loop B jumps across rows over the same data. Which wins?

    • Loop A reuses each cache line
    • Loop B, because jumping skips cells
    • They always tie
  8. A student says column by column must be faster because columns look shorter. What is the mistake?

    • Row order uses more memory
    • Cache lines only hold columns
    • Order decides, not looks
LightMySky · lightmysky.comW1-mt_0f5ArFPlxP-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Small fast memory, big slow memory W1-mt_0f5ArFPlxP-s1

  1. Temporal locality · Reuse of the same value is reuse over time.
  2. Registers, caches, main memory, disk · Speed falls at each step down the stack.
  3. True · Neighbour-next access is the spatial kind.
  4. Spatial locality · Ordered cells are neighbours, and neighbours mean spatial.
  5. It jumps across rows · Jumps across rows waste each cache line.
  6. Registers · Registers top the stack for speed.
  7. Loop A reuses each cache line · Ordered visits reuse each line; jumps waste them.
  8. Order decides, not looks · Looks never decide; visit order decides.
Worksheet · LightMySky