197k views
5 votes
assume that machine a is a 5-stage pipeline with 1ns clock cycle, and machine b is a 10-stage pipeline with 0.6ns clock cycle. the machine a experiences a stall due to a data hazard every 5 instructions, and the machine b experiences 3 stalls every 8 instructions. also, branches constitute 30% of the instructions, and the misprediction rate for both machines is 5%. which machine is faster, and by how much, when only considering data hazards? if the branch misprediction penalty for machine a and b is 2 and 5 cycles respectively, what are the cpis of each machine?

1 Answer

0 votes

Final answer:

Machine B is faster than Machine A both before and after considering the branch misprediction penalties. It has a lower average time per instruction due to a more efficient pipeline despite greater stall frequency, and this includes data hazards and branch penalties.

Step-by-step explanation:

To determine which machine is faster when only considering data hazards, we first calculate the average time per instruction for each machine without considering branch mispredictions. For Machine A, a stall occurs every 5 instructions, so the average clock cycles per instruction (CPI) due to data hazards would be 1 stall every 5 instructions or 1.2 (5/4 + 1, because 1 out of 5 instructions causes an additional cycle to be used). With a 1ns clock cycle, Machine A has an average time per instruction of 1.2ns due to data hazards. For Machine B, there are 3 stalls every 8 instructions, which gives us a stall rate of 3/8. Therefore, the average CPI for Machine B due to data hazards is 1 + (3/8), or 1.375. With a 0.6ns clock cycle, the average time per instruction for Machine B is 0.825ns (1.375 * 0.6).

Considering this, Machine B is faster in dealing with data hazards since it has a lower average time per instruction of 0.825ns compared to Machine A's 1.2ns. However, when we factor in the branch misprediction penalty, Machine A will have an increased CPI of 2 for the 5% mispredicted branches (which constitute 30% of instructions), and Machine B will have an increased CPI of 5 for the same proportion of branch mispredictions. Calculating the total CPI including the branch mispredictions gives us:

  • Machine A: 1.2 (data hazard CPI) + (0.3 * 5% * 2) (branch misprediction penalty per instruction) = 1.23 CPI
  • Machine B: 1.375 (data hazard CPI) + (0.3 * 5% * 5) (branch misprediction penalty per instruction) = 1.43125 CPI

Converting the CPI to time per instruction for considering branch mispredictions: Machine A has 1.23ns and Machine B has 0.85875ns (1.43125 * 0.6).

Even after including the branch misprediction penalty, Machine B remains faster than Machine A.

User Sedat
by
7.9k points