summaryrefslogtreecommitdiffstats
path: root/content/zettel/1c6e.md
blob: ac07adea291c23e756f36e90bb68b85dfef55812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+++
title = "Speculation does not have a cost"
date = "2022-04-29"
author = "Yann Herklotz"
tags = []
categories = []
backlinks = ["1c6d"]
forwardlinks = []
zettelid = "1c6e"
+++

It is interesting to note that speculating on an instruction does not
really incur a cost in itself. The idea is that if one is always wrong
with the speculation, one really only reverts back to the non-pipelined
instructions. So in the worst case one is only sequential. However, if
one speculates, then it is highly unlikely that one is always wrong, and
one will therefore always benefit from it.

Therefore, in the speculative loop pipelining, it does not really matter
in the end which instructions are picked to speculate on, and often the
most efficient will be the shortest path in the pipeline. For example,
Steven showed that even when one speculates on a binary search algorithm
to two iterations (where one then has a 25% chance of being right), one
still benefits from speculating going into one of the directions.