What is Pipelining?
Published on 2022-05-03
Category: Misc
Computer instructions will overlap in a processor and the way these processes work gets done through pipelining. You can think of assembly lines in the same way and how their processes overlap to get things done faster.
Benefits of Pipelining
Imagine a computer trying to run Google Chrome and Microsoft Word. Without pipelining, Google Chrome needs to run completely before Microsoft Word can even think about opening up. With pipelining, what you probably experience in your computer, if you open both at the same time, they will open at the same time and fairly quickly too.
Types of Hazards
Instruction pipelining can bring some hazards in many situations. This is the cost of trying to be as efficient as possible. Luckily, there are solutions to many of these problems and this is what I’ll be touching upon in this blog!
1. Structural Hazards
When instructions overlap, it is important for them to not consume the same hardware resource if there isn’t enough hardware for them. This is defined as a structural hazard.
Solutions:
- Separate hardware resources (e.g., data memory vs instruction memory).
- Access resources in sequence during the same cycle.
- Duplicate resources for frequently used hardware.
2. Data Hazards
If an instruction depends on the result of the previous instruction, that would be a hazard since instructions would overlap.
Solutions:
- Stall the pipeline to wait for older instructions to complete.
- Implement bypassing/forwarding to pass data between pipeline stages without stalling.
3. Control Hazards
These hazards occur when branch instructions or exceptions interrupt the normal pipeline flow.
Solutions:
- Add branch prediction mechanisms to guess the outcome of branch instructions.
- Flush the pipeline for exceptions or incorrect predictions.
- Delay instruction slots strategically to resolve branch hazards.
Conclusion
Pipelining is a powerful tool in modern computing, enabling faster execution of tasks by overlapping processes. Although it introduces hazards like structural, data, and control issues, various solutions mitigate these risks to ensure efficiency and reliability. Understanding pipelining is key to optimizing processor performance and addressing its challenges effectively.