retagged by
529 views
2 votes
2 votes

Suppose there are $m$ instructions to be executed in a program. $p$  is the probability that an instruction is a conditional branch instruction, and $q$ is the probability of a successful branch. Assume the average number of instructions completed in a simple pipelined processor is $1$ and a branch instruction takes $n$ clock cycles.

What should be the average CPI for the given program?

  1.   $1$
  2.   $pq (mn -1) + p( 1- q) mn$
  3.   $1 +pq ( n - 1)$
  4.    $p - pq$
retagged by

2 Answers

Best answer
9 votes
9 votes

There are total m instructions to be executed.

from m instructions , if branch taken mp , if no branch is taken then number of instructions m(1-p)

see below diagram 

instructions mpq take n clock cyles for each instruction to execute so total number of clock cycles = mpqn

instructions mp(1-q) take 1 clock cyles per 1 ns so total clock cycle is mp(1-q)

And m(1-p) take 1 clock cycles in each ns so total clock cycle is m(1-p)

Now , CPI = {mpqn + mp(1-q) + m(1-p)} / m

 = (mpqn + mp - mpq + m - mp ) / m

= (mpqn - mpq + m ) / m

= mpq( n-1) + m / m

= m {pq(n-1) + 1 } / m

= pqn - pq + 1

= 1 + pq ( n -1) 

which is option C 

selected
0 votes
0 votes
only succesful banch gives stall so total succesful branch = pq

total cycles by branch  ‘n’

so stall cycle is n-1

avg cpi = 1+ no of stall per inst

=1 + pq(n-1)
Answer:

Related questions

0 votes
0 votes
2 answers
2
Bikram asked May 27, 2017
362 views
Consider a $5$ stage instruction pipeline which can implement the $4$ instructions $I1, \ I2, \ I3, \ I4$. Below table gives the number of clocks required per instruction...