in CO and Architecture edited by
866 views
0 votes
0 votes

A CPU has five-stage pipeline and runs at 1 GHz frequency. Instruction fetch happens in the first stage of the pipeline. A conditional branch instruction computes the target address and evaluates the condition in the third stage of the pipeline. The processor stops fetching new instructions following a conditional branch until the branch outcome is known. Assuming that 20% of all instruction executed are branch instructions. A program executes 109 instructions out of which 40% are conditional branches and 50% of the conditional branch instructions the conditions are false. If each instruction takes one cycle to complete on average, then total execution time of the program is   

i am getting 1.32 

in CO and Architecture edited by
866 views

4 Comments

reshown by
Amit puri If this line was not given still I think the way you are writing is incorrect.

CPI should be 3.

It should be 0.8*1 + 0.2(0.6*3 + 0.4(0.5*3 + 0.5*1))

(not branch) + brached (60% unconditional braches (CPI =3) + (40% conditional (50% true CPI =3 + 50% false CPI =1)
0
0

1+0.20(0.60*2+0.40(0.50*2+0.50*0)) 

Why taking 1 here ?

0
0
@Ashwin,

he has also written correctly, but following different style of answering.

we are finding like this-> (not branch) + brached (60% unconditional braches (CPI =3) + (40% conditional (50% true CPI =3 + 50% false CPI =1)

but he is first finding avg no. of stalls per instruction and then adding it to '1'(actual CPI without stalls).

both are correct.
1
1

2 Answers

0 votes
0 votes
Best answer

Frequency=1 GHz, Cycle time=1/1=1 ns

Average instruction execution time = (1+0.20[0.60 x 2 + 0.40(0.50 x 2 +0.50 x 0)) x 1 ns

                                                                 = (1+0.20 x 3 x 0.80) x 1ns

                                                                 = 1.32 ns

Total execution time=1.32 ns x 109   =1.32 sec.

selected by

2 Comments

How unconditional branch stall cycles = $2$ ? and also conditional branch not taken stall cycles = $0$ ?
0
0
I m not sure Abt the stall cycle...that's why I asked where I m committing mistake..
0
0
1 vote
1 vote
A conditional branch instruction evaluates the condition in the third stage of the pipeline.

So,  branch penalty=2.

Assuming that 20% of all instruction executed are branch instructions.

Out of which 40% are conditional branches and 60% unconditional branches

 50% of the conditional branch instructions the conditions are false

#stall cycle/instruction=$0.2*0.6*2+0.2*0.4*0.5*2=0.24+0.08=0.32$

Avg.inst exe. time=(1+# of stalls/inst)×cycletime$=(1+0.32)\times 1=1.32$