Lecture 04 · Code Execution on a CPU

The whole deck on two pages.

Page numbers refer to ../lectures/Lecture_04_ExecInsideCPU.pdf.

Execution models

Model What happens Limit p.
subscalar one instruction at a time, all 5 stages ~10 cycles for 2 instructions 5–6
pipelining stages of different instructions overlap fill time, branches 7
superscalar (n-way) n instructions issued per cycle needs n independent instructions 8
out-of-order run when inputs are ready true data dependencies 9
Hyper-Threading built on superscalar + OoO to keep units busy handled inside the CPU 8–9, 22
subscalar: n · k cycles pipeline: k + (n − 1) w-way ideal: k + (n/w − 1)

Branches

Internal accelerators

ISAs

CISC (x86) RISC (Arm, RISC-V)
Instructions complex, micro-code simple
Timing variable predictable (speculation still exists)
Memory / compiling saves memory, easier to compile to more memory, harder to compile for — no longer an issue

p.16

Summary

Exam-style questions from the deck p.21

  1. An n-way superscalar CPU can always execute n instructions in parallel. True? Explain why.
  2. Can a "Last Time" branch predictor learn the pattern of if (x%2==0) A else B in a loop? Which predictor would work well, and how?
  3. Arm CPUs are becoming widespread in servers. What limitations, if any, must applications overcome on Arm vs x86?