Consider a 4-stage pipeline processor. The number of cycle needed by the four instruction l1, l2, l3, l4 in stages S1, S2, S3, S4 is show below

 S1 S2 S3 S4 l1 2 1 1 1 l2 1 3 2 2 l3 2 1 1 3 l4 1 2 2 2

The number of cycles needed to execute the following loop is ____________.

for(i=1 to 2)
{     l1; l2; l3; l4;
}

Sumit Verma sumitverma 1 Dec 2016 04:24 pm

for i = 1,

 Clock Cycle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 l1 S1 S1 S2 S3 S4 l2 - - S1 S2 S2 S2 S3 S3 S4 S4 l3 - - - S1 S1 - S2 - S3 - S4 S4 S4 l4 - - - - - S1 - S2 S2 S3 S3 - - S4 S4

So, total 15 clock cycles are required for i = 1
Hence, it should take 15 clock cycles for next iteration for i = 2; hence total cycles should be 15x2 = 30.
But it is not the case.
2ns execution of the loop will start with l1 which needs S1. The stage S1 will be free to use on 7th clock cycle after l4 releases it. Hence, we can extend the above pipeline execution diagram which will give us the required clock cycle as 23 cycles.

Habib Mohammad Khan habibkhan 1 Dec 2016 08:37 pm

Plz check my one..I think u may have mistaken somewhere..The correct answer should be 25 with loop level parallelism which is default assumption..

Jaya jaya1 1 Dec 2016 09:35 pm

the answer should be 25 .

Shobhit sudsho 2 Dec 2016 12:46 am

answer is 23 only..here only 4 instructions are repeated 2 times and we can assume pipeline buffers to store multiple results in between...

Sumit Verma sumitverma 2 Dec 2016 09:45 pm