Out Of Order Execution

What is Out-of-Order Execution?

Out-of-order execution refers to a specific type of processing method followed by the modern CPUs where the instructions in a program are executed not in the order of their appearance but ‘out of order.’

These instructions are typically executed based on the availability of data for it. This specific system reduces the chances of wasted clock cycles. This is because it allows starting processing of an instruction when others are experiencing a delay.

Understanding Out-of-Order Execution

What is Out-of-Order Execution

Out-of-order execution, or OoOE, refers to just what the name signifies – to execute instructions out of order of appearance in a program.

This method is followed by high-performance microprocessors. The set of instructions waits in the queue for the right operand to be executed.

They start processing an instruction as soon as the desired operand is ready and available.

When the right operand is available, these pending instructions leave the queue before the older instructions and are sent to the correct functional unit to be executed.

The results of these instructions executed out of order are typically queued as well in temporary locations to be arranged later on in the register file.

Read Also:  What is Dual Processor? Pros, Cons & More

The main objective of out-of-order execution is to reduce wait times in the CPU for the older instructions to be completed first to start the new one.

This helps it to avoid chances of stalls and wasted clock cycles due to the unavailability of data to perform an operation on an instruction in order.

Ideally, to work, a CPU has to follow two specific rules such as:

The out-of-order process, as well as the in-order technique adheres to these two rules, but in the case of the out-of-order execution technique, the cache miss conditions are not as dramatic as it is with the in-order execution technique.

Out-of-order executions work by using an instruction window that contains all of the decoded instructions in the actual order.

A record is maintained to ensure that the results of these instructions are retired just in the same order as each of them is decoded by the CPU.

In addition to that, there is also a scheduling window. This is where the reordering of instructions that takes place is maintained.

It contains logic that marks dependent and independent instructions.

This window sends all independent instructions to the execution units and waits for the dependent instructions to be available for execution.

Out-of-Order Execution Pipeline

The out-of-order execution queue prevents data hazards and pipeline stalls. This is a technique that allows following instructions to execute in Superscalar pipelining.

This specific type of pipelining instructions is an aggressive technique to maximize the final throughput.

In such a process, the processor is equipped with several units, known as processing units, which help it to handle several instructions in parallel at every stage of the pipeline.

In this pipeline, every instruction is typically divided into a series of steps that are good for being carried out in parallel.

Read Also:  What is Threadripper? (Explained)

In simple words, the fundamental instruction cycle is divided into a particular set of instructions in a pipeline.

For example, if it is a five-stage pipeline, the different stages of pipelining could be as follows:

However, the number of dependent steps may vary according to the architecture of the machine.

Nonetheless, if the processor can fetch instructions at every clock cycle, it is supposed to be fully pipelined.

And, when a CPU is properly and fully pipelined, it does not wait for delays in instructions getting data and being executed, so it can avoid situations that may be problematic.

It is the out-of-order execution technique that saves them from facing such issues since instructions that are not dependent on the current ones are executed before them without causing any data hazards.

In-order Vs Out-of-Order

Out-of-Order Execution Examples

One significant example of out-of-order execution is software pipelining where the reordering is done by the compiler and not by the processor.

The POWER1 microprocessor of IBM introduced in 1990, most modern CPUs, and IBM PowerPC processors that use a centralized queue are also good examples of out-of-order execution processors.

Where are the Results of the Out-of-Order Mode of Execution Placed?

The results of the out-of-order executions that are performed before the older operations of a program are stored in temporary locations initially.

These are arranged and sent to the desired or permanent locations at a later stage when the older instructions are executed and their respective results are written back to the register file.

This is called the retirement or graduation stage.

Conclusion

There are more positives than downsides to out-of-order executions, and therefore most modern x86 CPUs are made up of out-of-order cores.

It allows dynamic reordering of the instructions, reduces memory latencies, CPU idle times, and cache misses, and offers higher clock speeds with fewer wasted clock cycles.