Consider a 4 stage pipeline processor. The number of cycles needed by the four instructions I1, I2, I3, I4 in stages S1, S2, S3, S4 is shown below (I1: 2,1,1,1; I2: 1,3,2,2; I3: 2,1,1,3; I4: 1,2,2,2). What is the number of cycles needed to execute the following loop: for (i = 1 to 2) {I1; I2; I3; I4;}
Explanation
Simulating the 8-instruction sequence (I1,I2,I3,I4 twice) through the 4 stages, where each stage is a single resource that the next instruction can only enter once the previous instruction vacates it, and tracking start/end times per stage per instruction, the last instruction (2nd I4) finishes stage S4 at cycle 23 (starting the timeline at cycle 0 for the very first instruction's S1 entry).
Source: GATE CS 2009 (2009)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.