Forwarded from Accio
Regarding to pipe-lining, they don't always result in optimization. There are times when you might run into obstacles called Pipeline Hazards.
There are three types of pipeline hazards:
Structural Hazard: When two or more instructions need the same unit of CPU
Data Hazard: An instruction needs to wait for a previous operation to be completed
Control Hazard: CPU can’t tell which instructions it needs to execute next
The third one probably got your attention. How could CPU not know which instruction to execute next? Imagine a simple If statement. When CPU reaches this type of branching, It cannot choose future instructions with 100% certainty. That's why there a set of tricks to remove branches from your program as much as possible called Branchless-Programming.
It's worth noting that compilers do a set of optimizations in regard of removing branches as well. So knowing how your compiler acts is essential to how you optimize your code.
#CPU #Pipelining #Branchless_Programming.
There are three types of pipeline hazards:
Structural Hazard: When two or more instructions need the same unit of CPU
Data Hazard: An instruction needs to wait for a previous operation to be completed
Control Hazard: CPU can’t tell which instructions it needs to execute next
The third one probably got your attention. How could CPU not know which instruction to execute next? Imagine a simple If statement. When CPU reaches this type of branching, It cannot choose future instructions with 100% certainty. That's why there a set of tricks to remove branches from your program as much as possible called Branchless-Programming.
It's worth noting that compilers do a set of optimizations in regard of removing branches as well. So knowing how your compiler acts is essential to how you optimize your code.
#CPU #Pipelining #Branchless_Programming.
Forwarded from Accio
Regarding to pipe-lining, they don't always result in optimization. There are times when you might run into obstacles called Pipeline Hazards.
There are three types of pipeline hazards:
Structural Hazard: When two or more instructions need the same unit of CPU
Data Hazard: An instruction needs to wait for a previous operation to be completed
Control Hazard: CPU can’t tell which instructions it needs to execute next
The third one probably got your attention. How could CPU not know which instruction to execute next? Imagine a simple If statement. When CPU reaches this type of branching, It cannot choose future instructions with 100% certainty. That's why there a set of tricks to remove branches from your program as much as possible called Branchless-Programming.
It's worth noting that compilers do a set of optimizations in regard of removing branches as well. So knowing how your compiler acts is essential to how you optimize your code.
#CPU #Pipelining #Branchless_Programming.
There are three types of pipeline hazards:
Structural Hazard: When two or more instructions need the same unit of CPU
Data Hazard: An instruction needs to wait for a previous operation to be completed
Control Hazard: CPU can’t tell which instructions it needs to execute next
The third one probably got your attention. How could CPU not know which instruction to execute next? Imagine a simple If statement. When CPU reaches this type of branching, It cannot choose future instructions with 100% certainty. That's why there a set of tricks to remove branches from your program as much as possible called Branchless-Programming.
It's worth noting that compilers do a set of optimizations in regard of removing branches as well. So knowing how your compiler acts is essential to how you optimize your code.
#CPU #Pipelining #Branchless_Programming.