CA Unit-3 Part2
CA Unit-3 Part2
the maximum speedup, also called ideal speedup, of a pipeline processor with m stages over an
equivalent nonpipelined processor is m. In other words, the ideal speedup is equal to the number of
pipeline stages. That is, when n is very large, a pipelined processor can produce output approximately m
times faster than a nonpipelined processor. When n is small, the speedup decreases.
Pipeline Hazards
There are situations in pipelining when the next instruction cannot execute in the
following clock cycle. These events are called hazards, and there are three different
types.
COA – Dept of IT Page 38
Hazards
The first hazard is called a structural hazard. It means that the hardware cannot support the
combination of instructions that we want to execute in the same clock cycle. A structural hazard in the
laundry room would occur if we used a washer dryer combination instead of a separate washer and
dryer, or if our roommate was busy doing something else and wouldn‟t put clothes away. Our carefully
scheduled pipeline plans would then be foiled.
As we said above, the MIPS instruction set was designed to be pipelined, making it fairly easy
for designers to avoid structural hazards when designing a pipeline. Suppose, however, that we had a
single memory instead of two memories. If the pipeline in Figure 4.27 had a fourth instruction, we
would see that in the same clock cycle the fi rst instruction is accessing data from memory while the
fourth instruction is fetching an instruction from that same memory. Without two memories, our pipeline
could have a structural hazard.
Data Hazards
Data hazards occur when the pipeline must be stalled because one step must wait for another to
complete. Suppose you found a sock at the folding station for which no match existed. One possible
strategy is to run down to your room and search through your clothes bureau to see if you can find the
match. Obviously, while you are doing the search, loads must wait that have completed drying and are
ready to fold as well as those that have finished washing and are ready to dry.
In a pipeline, data hazards arise from the dependence of one instruction on an earlier one that is still in
the pipeline (a relationship that does not really exist when doing laundry). For example, suppose we
have an add instruction followed immediately by a subtract instruction that uses the sum ($s0):
add $s0, $t0, $t1
sub $t2, $s0, $t3
Without intervention, a data hazard could severely stall the pipeline. The add instruction doesn‟t
write its result until the fifth stage, meaning that we would have to waste three clock cycles in the
pipeline.Although we could try to rely on compilers to remove all such hazards, the results would not be
satisfactory. These dependences happen just too oft en and the delay is just too long to expect the
compiler to rescue us from this dilemma.
The primary solution is based on the observation that we don‟t need to wait for the instruction to
complete before trying to resolve the data hazard. For the code sequence above, as soon as the ALU
creates the sum for the add, we can supply it as an input for the subtract. Adding extra hardware to
retrieve the missing item early from the internal resources is called forwarding or bypassing.
In this graphical representation of events, forwarding paths are valid only if the destination stage
is later in time than the source stage. For example, there cannot be a valid forwarding path from the
output of the memory access stage in the first instruction to the input of the execution stage of the
following, since that would mean going backward in time.
Control Hazards
The third type of hazard is called a control hazard, arising from the need to make a decision based on
the results of one instruction while others are executing. Suppose our laundry crew was given the happy
task of cleaning the uniforms of a football team. Given how filthy the laundry is, we need to determine
whether the detergent and water temperature setting we select is strong enough to get the uniforms clean
but not so strong that the uniforms wear out sooner. In our laundry pipeline, we have to wait until aft er
the second stage to examine the dry uniform to see if we need to change the washer setup or not. What
to do?
Here is the first of two solutions to control hazards in the laundry room and its computer equivalent.
Stall: Just operate sequentially until the first batch is dry and then repeat until you have the right
formula.
This conservative option certainly works, but it is slow.
SISD represents the organization of a single computer containing a control unit, a processor unit,
and a memory unit. Instructions are executed sequentially and the system may or may not have internal
parallel processing capabilities. Parallel processing in this case may be achieved by means of multiple
functional units or by pipeline processing.
SIMD represents an organization that includes many processing units under the supervision of a
common control unit. All processors receive the same instruction from the control unit but operate on
different items of data. The shared memory unit must contain multiple modules so that it can
communicate with all the processors simultaneously.
MISD structure is only of theoretical interest since no practical system has been constructed
using this organization.
MIMD organization refers to a computer system capable of processing several programs at the
same time. Most multiprocessor and multicomputer systems can be classified in this category.
This is shown in Fig. 13-13. A store to X (of the value of 120) into the cache of processor P1 updates
memory to the new value in a write-through policy. A write-through policy maintains consistency
between memory and the originating cache, but the other two caches are inconsistent since they still
hold the old value. In a write-back policy, main memory is not updated at the time of the store. The
copies in the other two caches and main memory are inconsistent. Memory is updated eventually when
the modified data in the cache are copied back into memory.