Introduction:
Pipelining can efficiently increase the performance of a processor by overlapping execution of instructions. But the efficiency of the pipelining depends upon, how the problem encountered during the implementation of pipelining is handled. These problems are known as HAZARDS.
Types of Hazards:
a) Structural Hazards (Resource Bound)
b) Control Hazards ( Pipelining Bubbles)
c) Data Hazards ( Data dependencies)
Structural Hazards:
During the pipelining, the overlapped execution of instructions requires pipelining of functional units and duplication of resources to allow all possible combinations of instructions in the pipeline.This type of hazards occurs when two activities require the same resource simultaneously.
Example:
If machine has shared a single-memory pipeline for data and instructions. As a result,when an instruction contains a data-memory reference (load-MEM), it will conflict with the instruction reference for a later instruction (instr 3-IF):
Clock cycle number
Instr 1 2 3 4 5 6 7 8
Load IF ID EX MEM* WB
Instr 1 IF ID EX MEM WB
Instr2 IF ID EX MEM WB
Instr 3 IF* ID EX MEM WB
To resolve this, we stall the pipeline for one clock cycle when a data-memory access occurs. The effect of the stall is actually to occupy the resources for that instruction slot. The following table shows how the stalls are actually implemented.
Clock cycle number
Instr 1 2 3 4 5 6 7 8 9
Load IF ID EX MEM WB
Instr1 IF ID EX MEM WB
Instr 2 IF ID EX MEM WB
Instr 3 stall IF ID EX MEM W B
Instruction 1 assumed not to be data-memory reference (load or store), otherwise Instruction 3 cannot start execution because of structural hazard.
We know that introduction of stall reduces the performance of the system but there are following reasons for allowing structural hazard while designing the system:
To reduce cost: For example, machines that support both an instruction and a
cache access every cycle (to prevent the structural hazard of the above example)
require at least twice as much total memory.
A classical way to avoid hazard at memory access is by providing separate data and instruction cache
Control Hazard:
This type of hazard is caused by uncertainty of execution path, branch taken or
not taken.It results when we branch to a new location in the program, invalidating
everything we have loaded in our pipeline. They arises from the pipelining of branches and other instruction that change the content of PC (program counter). If a branch instruction enters in the pipeline , the performance would be hampered.
CLK 0 1 2 3 4 5 6 7 8 9 10 11 12
I1 IF ID EX W
I2 IF ID EX W
I3 IF ID EX W
I4 IF ID EX W
overlapped execution without branching
I1 IF ID EX W
I2 IF ID EX W
I3 IF ID EX W
I4 IF ID EX W
overlapped execution with branching
if you get any error or new thing then plzz share your view
ReplyDelete