liveBook · Manning

Simultaneous multithreading

As explained in The Coder Cafe

SMT, or simultaneous multithreading, is a processor technique that allows multiple hardware threads to share a physical core's execution resources.

Simultaneous multithreading (SMT) lets multiple hardware threads share one physical core’s execution resources. It aims to keep those resources busy when one thread cannot use them. A hardware thread is a logical processing unit visible to the operating system, not an additional physical core. section 8.2.1 section 8.3

Four cores, eight visible threads

A four-core CPU with one hardware thread per core exposes four processing units to the operating system. With two hardware threads per core, as on the Intel i7-7700K, it exposes eight. Those eight threads still share four physical cores; they do not provide the capacity of eight independent cores. section 8.2.1 section 8.3

Each SMT hardware thread has its own architectural state and instruction queue. An instruction scheduler selects ready instructions from the queues for shared execution units, including arithmetic, floating-point, and load/store units. It can draw from another thread when one stalls. Separate architectural states allow this without a full operating-system context switch between the hardware threads. section 8.2.3

Trace the separate per-thread queues and state into the shared execution resources to see what SMT duplicates—and what it does not. section 8.2.3

Treat extra hardware threads as a workload-dependent opportunity, not a guaranteed speedup:

  • Two threads sharing a core may deliver a gain around 30%, rather than the 100% an extra physical core might suggest; the cited Intel estimate also carries roughly 20% more power consumption. section 8.2.4 section 8.3
  • Parallelizing across eight visible threads on four cores therefore does not imply eightfold throughput. Benchmark the application: some memory-bound workloads perform worse with SMT enabled. section 8.2.4

SMT also reflects a design tradeoff. Intel introduced Hyper-Threading on the Pentium 4 to make use of a second thread while the first stalled. Later designs have made different choices: Alder Lake pairs SMT-equipped performance cores with efficiency cores without SMT, while Lunar Lake removes Hyper-Threading in favor of other approaches. section 8.2.2 section 8.2.6

How The Coder Cafe covers it

How deep it goes
Explains architectural state, instruction queues, scheduling onto shared execution units, and performance tradeoffs without presenting a hardware implementation.
Examples
Compares four-core CPUs with four or eight visible threads and uses the i7-7700K to illustrate non-linear scaling.
What it assumes
Defines hardware threads, virtual CPUs, and architectural state while building on basic familiarity with cores and operating systems.
What you can do after
Evaluate/understand SMT benefits by distinguishing hardware threads from cores and benchmarking workloads rather than assuming linear speedups.
How it connects
Connects SMT to operating-system scheduling, context switching, instruction pipelining, branch prediction, and performance-per-watt.

Also explained in

Compare how 3 books explain simultaneous multithreading →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.