262 views
Quantify the effect on performance that results from the use of a cache in the case of a program that has a total of 500 instructions, including a 100-instruction loop that is executed 25 times. Determine the ratio of execution time without the cache to execution time with the cache. This ratio is called the speedup.
1)Program execution time is proportional to the total amount of time needed to fetch the instruction from either the main memory or the cache.With operand data access being ignored

2)Initially all instruction is stored in main memory and the cache is empty.

3)The cache is large enough to contain all loop instruction.

_________________________________________________________________

my solution is

execution time without cache is=400∗10+100∗10∗25=29000400∗10+100∗10∗25=29000

execution time with cache =500∗10+100∗1∗25=7500
My question is why we take 400 instructions instead of 500 instruction pls explain.

### 1 comment

From the solution you have provided I am assuming main memory access time 10 unit and cache access time is 1 unit.

While calculating execution time without cache we have total 500 instruction out of which 100 instruction runs in loops for 25 times and rest (500-100)=400 instruction runs once.

So ,total number of times we have to go to main memory to fetch the instruction as we don’t have cache to store the instructions is =(400+25*100)=2900.

Now each instruction it took 10 unit time to access main memory .

So total time required to run 2900 instruction=2900*10=29000 unit time

When we use cache we can store the looping instruction inside the cache so that we don’t have to go to fetch those 100 instruction every time.

So ,we have to definitely fetch those 500 instruction once from memory which will took 500*10=5000 unit time .

now by this we store the 100 instruction inside the cache and run them once .

now we need to run them only 24 times as we already run them once.

Now we can easily access them from cache which will take 1 unit of time to access one instruction.

So , to access 100 instruction once it will took =100*1=100 unit time.

we need to execute them 24 times so time it took =24*100=2400 unit time.

So total time it took without cache=5000+2400=7400 unit time.

Speed up=$\frac{29000}{7400}=3.91$