Pipelining I: Prepared By: Noshaba Nasir
Pipelining I: Prepared By: Noshaba Nasir
Car 2 A+P+T
Car 3 A+P+T
Real World Analogy
• Automobile manufacturing line with pipelining, in 3 stages
• Assemble (A), Paint (P), Fix tires (T)
• Assuming each stage takes 1 hour
• It takes 5 hours with pipelining and 9hours without pipelining
• Speedup = 9/5
Time 1st 2nd 3rd 4th 5th 6th 7th 8th 9th
line hour hour hour hour hour hour hour hour hour
Car 1 A P T
Car 2 A P T
Car 3 A P T
Real World Analogy
• Here our assumptions are
• There is no time consumed to transition car from one working station on other
• All the stages consume equal time
• However these assumption are not valid
• Each stage can take different amount of time
• For example painting a car takes 2 hours and Assembly and installing types take 0.5 hours
each
• To transfer car from one stage to another will take time.
• For example, it takes 10 minutes to transfer a car from Assembly room to paint rooms and
10 minute to transfer from paint room to tire fixing room.
• Note that this will not be consume in un-pipeline factory as everything will be done is
same room
Real World Analogy
• Automobile manufacturing line with pipelining, in 3 stages
• If Assemble (A), Paint (P), Fix tires (T) take different time
• If Assembly take 0.5 hour, Paint 2 hours and Tires 0.5 hours
• Paint of Car2 cannot start before 2.5th hour because Paint unit is busy with Car1. So after Assembly Car 2
has to wait for 1.5 Hours
• Total time take to complete 3 instructions =7h
• Speed Up = 9/7
Car 1 A P T
Car 2 A P T
Car 3 A P T
Exercise
• Divide your paint job in 4 stages, 1st coat, 2nd coat, 3rd coat and drying ,
each phase takes 0.5 hours.
• What will be throughput with these 6 stages for 3 cars?
• Ignore the latch/transition time
Pipeline in Computer:: Frequency
• Computer processors can execute one or more instructions per clock
cycle, depending on the type of processor.
• Frequency of computer is 1/clock cycle
• For example if 1 clock cycle= 10 ms;
• Frequency = 1/10ms= 1MHZ
• i.e. 1 000 000 cycles / second
• Frequency is AKA as clock speed
Pipeline in Computer:: Performance
• IDEAL CASE
• In ideal case i.e. all the stages require same amount of time and
ignoring time to transfer data from one stage to another
• Speedup= n*k/ k+(n-1)
• where n is number of instructions and k is number of stages
Time T T T T T
line
Car 1 A P T
Car 2 A P T
Car 3 A P T
.. … ..
Pipeline in Computer:: Performance
Ideal case (Derivations)
• If
• All stages take equal amount of time T
• Latch time=0
• Stages =k
• Number of instructions = n
• Then
• Clock cycle of pipeline=T, clock cycle of non pipeline= k*T
• Frequency of pipeline=1/T , Frequency of non pipeline=1/k*T
• Time taken to complete n instructions without pipeline= n*k*T= n*clock cycle of non pipeline
• Through put for n instructions without pipeline= n/ n*k*T
• Time taken to complete n instructions with pipeline= (k+n-1)*T= (k+n-1)*(Clock Cycle of pipeline)
• Through put for n instructions with pipeline= n/ (k+n-1)*T
• Speedup for n instructions = n*k*T/ (k+n-1)*T = n*k/ (k+n-1)
• Latency without pipelining = k*T
• Latency with pipelining= k*T
Pipeline in Computer:: Performance
Ideal case
• Numerical:
• It takes 6us to complete one instruction in non-pipeline processor
• We were able to convert the circuit into 6 equal sequential pipeline stages.
• Assume latch time is 0
• Answer the following, assuming that there are no stalls in the pipeline.
• What are the clock cycle in the two processors?
• What are the clock speeds(frequency) in two processors?
• How long does it take to finish one instruction in pipeline and no pipeline (latency )?
• What is the throughput for 100 instructions without pipelining?
• What is the throughput for 100 instructions with pipelining?
• What is the speedup from pipelining for 1 instructions?
• What is the speedup from pipelining for 100 instructions?
Pipeline in Computer:: Performance
• Another example
• It takes 5us to complete one instruction in non-pipeline processor
• We were able to convert the circuit into 5 equal duration sequential pipeline stages.
• Latch time is 0us
• Answer the following, assuming that there are no stalls in the pipeline.
• What are the clock cycle in the two processors?
• What are the clock speeds(frequency) in two processors?
• How long does it take to finish one instr in pipeline and no pipeline (latency )?
• What is the throughput for 100 instructions without pipelining?
• What is the throughput for 100 instructions with pipelining?
• What is the speedup from pipelining for 1 instructions?
• What is the speedup from pipelining for 100 instructions?
Exercise
• Question 1: If throughput of one processor1 for n instruction is 10us
and through put of processor 2 is 15us for same n instruction what
speed up is achieved by processor2 are compare to processor 1?
• Question 2: If Latency with pipelining with 5 stages is 6us and latch
time is 0 what is the clock cycle time?