Consider a stage pipeline processor. The number of cycles needed by the four instructions in stages is shown below:
What is the number of cycles needed to execute the following loop?
For (i=1 to 2) {I1; I2; I3; I4;}
View worked solution
Answer: B
The loop executes the sequence of instructions: (a total of 8 instructions). Let and denote the start and end times of instruction in stage .
The scheduling constraints are:
- An instruction can only enter stage after it finishes stage :
- A stage can only process instruction after instruction has cleared it:
Tracing the execution cycle-by-cycle for all 8 instructions:
| Inst. | Stage S1 (cycles) | Stage S2 (cycles) | Stage S3 (cycles) | Stage S4 (cycles) |
|---|---|---|---|---|
| I1 | [0, 2] | [2, 3] | [3, 4] | [4, 5] |
| I2 | [2, 3] | [3, 6] | [6, 8] | [8, 10] |
| I3 | [3, 5] | [6, 7] | [8, 9] | [10, 13] |
| I4 | [5, 6] | [7, 9] | [9, 11] | [13, 15] |
| I1 | [6, 8] | [9, 10] | [11, 12] | [15, 16] |
| I2 | [8, 9] | [10, 13] | [13, 15] | [16, 18] |
| I3 | [9, 11] | [13, 14] | [15, 16] | [18, 21] |
| I4 | [11, 12] | [14, 16] | [16, 18] | [21, 23] |
The final instruction completes stage at cycle 23.
Free practice · Your answers on this page are not saved.
