In this post, we will explain what is a computer CPU pipeline. CPU (an abbreviation of the Central Processing Unit) is an important part of the computer that functions like a brain. And we already know that. But what we might not know are the techniques that make the CPU efficient. One such technique is Pipelining. If you want to know what is a pipelined CPU and how pipelining improves CPU performance then read this post.
What is a Computer CPU Pipeline?
In computer science, an instruction refers to the command given by a program to the CPU. It consists of a machine language code that the CPU understands and executes. For example,
store is an instruction used to command the CPU to store information in the RAM. Pipelining is a technique used in the designing of modern CPUs. It increases the overall instruction throughput (number of instructions executed per second) by dividing the instructions into subtasks that the CPU can process parallelly.
What is a Pipelined CPU?
A pipelined CPU works on the concept of pipelining by splitting the instruction set into a series of subtasks, where each subtask performs a single operation. The pipeline has 2 endpoints: the input and the output. Multiple subtasks are accumulated between these ends in such a way that the output of one subtask is connected to the input of the next subtask. Hence a pipelined CPU performs more than 1 subtask at the same time.
Also Read: Types of Topology in Computer Network explained.
How Pipelining improves CPU Performance?
In general, CPU can break an instruction in the following 4 subtasks (at a very basic level):
- Fetch – fetching the instruction from memory.
- Decode – decoding the instruction.
- Execute – executing the instruction.
- Write – writing the result back to the memory.
Now suppose the CPU has a dedicated unit to perform each of these subtasks. While one unit is performing a subtask, the rest of the CPU units will be sitting idle, doing nothing during the time. Pipelining takes advantage of these idle units by using them to process other instructions in the queue.
Let us understand this with the help of an example. Look at the following figure:
The above figure explains how a set of 2 instructions are executed in a non-pipelined CPU environment and a pipelined CPU environment. As you can see, a non-pipelined CPU is taking 8 clock cycles to perform 2 instructions, whereas a pipelined CPU executes the same set of instructions in just 5 clock cycles.
If you look closely, the pipelined CPU is using its ‘Fetch’ unit to execute the first subtask of the second instruction, while its ‘Decode’ unit is already executing the second subtask of the first instruction. Hence, it is utilizing the second unit concurrently with the first unit, which would otherwise sit idle in a non-pipelined environment.
Increasing the speed of execution of a given set of instructions consequently increases the speed of the CPU. And this is how pipelining improves the efficiency of a CPU. An important thing to note here is that pipelining is not reducing the time taken by the CPU to execute an instruction. Rather, it increases the number of instructions that the CPU can process simultaneously. So increasing the number of subtasks doesn’t really mean that a pipelined CPU will work faster than a non-pipelined CPU. In fact, a non-pipelined CPU may take less time to execute a single instruction than a pipelined CPU, depending on the number of pipeline stages (number of subtasks) involved.
I hope the above explanation clarifies what a is Computer CPU Pipeline. If you have any doubts, do share them in the comments section below.
How does pipeline improve CPU performance?
The pipeline architecture increases the number of instructions processed per CPU clock cycle. By increasing the instruction throughput, it increases the overall performance of the CPU. However, if the instruction set consists of complex instructions (such as branch instructions), the CPU will not know in advance where to read the next instruction and must wait till the current instruction is executed completely. In such cases, the pipelining architecture may fail to achieve CPU efficiency.
Does pipelining increase execution time?
Pipelining increases the number of instructions running concurrently at each clock cycle. But it doesn’t necessarily improve the time taken to execute a single instruction. For example, pipelining is not suitable to execute branch instructions, which deviates the sequential execution to a different path. This disorganization may disrupt the pipeline or flush it completely unless suitable methods are introduced to resolve branch issues.
Read Next: How to limit CPU usage for a process in Windows.