Modern CPUs are incredibly complex devices.

They use many very clever tricks to eke out as much performance as possible.

One of those tricks is memory dependence prediction.

This is simply the process of predicting if a specific memory access is dependent on any other memory access.

This is only necessary because of another performance trick called Out Of Order execution.

Contents

What is OOO?

An OOO CPU can look at a buffer of decoded instructions and choose to reorder them to improve efficiency.

The main purpose of this is to delay instructions that need data that isnt available yet.

OOO can provide a significant speed-up, simply by being able to delay instructions that arent ready.

Other performance benefits can also be felt such as prioritising branching instructions.

A branch instruction can result in the branch being taken or not taken.

The result determines what code needs to be run next.

In code, an IF statement is one implementation of a branch.

The problem is that while many things can be reordered, some instructions are dependent on other instructions.

This is the sort of problem that memory dependence prediction aims to fix.

This can lead to potentially lost performance optimisation.

This involves tracking and analysing memory accesses and determining which ones interact with memory that still has pending operations.

Specifically, it allows memory operations without dependencies to be reordered to increase performance.

It does this while tying the execution of memory operations with dependencies to the execution of their dependencies.

This enables the performance gain from out of order execution.

The techniques needed to perform this accurately have been known since the late 1990s.