Computer Science — Speculation & Prediction in Computer Architecture

Jake Cutter
Technology Hits
Published in
2 min readJun 6, 2022

Within our computer, the CPU is feed instructions. This continues to change the address values and determines outputs to our console. Part of this process is when the processor predicts what will happen before it does. This solves the problem of latency and improves efficiency. We’ll get more in-depth with that later on. For now, we need to define speculation. Speculation is when the processor predicts the result of an operation before it is executed based on true or not true values.

Photo by Kari Shea on Unsplash

Prediction:

Within the prediction, there are two ways to it determine the outcome. There is a 1-bit and 2-bit prediction detailed in the graphics below. The result when untrue can slow down the execution time; however, when it is true can make a far more efficient machine.

2-bit predictor | http://ece-research.unm.edu/jimp/611/slides/chap4_5.html

The graphic above is a 2-bit predictor. You can follow the arrows yourself, but in short, the predictor guesses a taken or not taken value. These values are used later to add to the instructions. An example string of instruction is below.

Use the arrow diagram to determine correct/incorrect: | image by the author

A 1-bit predictor is very similar but is often less used. For speculation, its general definition is as follows: Speculation is a guess common to both static and dynamic Multiple Issues. Instructions evaluated by speculation are Branch, load, and compiler instructions. Guesses then commit to guaranteed instructions.

Speculation:

The difference between dynamic and static speculation is a key concept. For dynamic scheduling, the prediction is made whilst the memory is allocated. For static speculation, the prediction is made whilst the compiler is running. With speculation comes dynamic scheduling. The scheduling is achieved after the fetching of the instruction. After the fetch, if it is mispredicted will remove all the entries for the instruction up to that point and then restart from the misprediction.

Citations:

Cao, Qing. Professor. University of Tennessee. Knoxville, Tennessee. 2021

Parthasarathi, Dr Ranjani. “Computer Architecture.” Dynamic Scheduling with Speculation — Computer Architecture, INFLIBNET Centre, 24 July 2018, https://www.cs.umd.edu/~meesh/411/CA-online/chapter/dynamic-scheduling-with-speculation/index.html.

--

--