likeGreen
likeGreen

Reputation: 1079

CPI calculation

I have calculated a graph with cache miss rate(mr) vs the size of cache(sc). How can the CPI (cycle per instructions) be calculated for various cache sizes. Assumptions are :

Given cache miss latency (say 10 ) , 
base CPI of 1 and 
33.33% of instructions as memory operations.

What I understand is that the CPI can be calculated using the following formula. Is the below method correct?

CPI = miss rate*(.3333)*10 + 1

for the MISS RATE: 2.700978 I got the following CPI

CPI: 1.090024

Upvotes: 1

Views: 5037

Answers (1)

Gabriel Southern
Gabriel Southern

Reputation: 10063

To calculate CPI when given a baseline CPI and statistics about cache hierarchy you can use the following formula:

Effective CPI = Baseline CPI + CPI of memory accesses

Your baseline CPI is 1 (given in the problem statement). So you just need to find the CPI of the memory accesses.

If the memory access is a hit in the cache then we assume that the CPI is the same as the baseline CPI. If it is a miss then it will be the miss latency.

So you have 33% of instructions that are memory accesses. Of those the ones that are misses will take 10 cycles. So putting all of this together you get:

CPI = miss rate*(.3333)*10 + 1

Which is what you have in your question.

As for the code you included and the "Answer" section I don't know what you are asking about there or what its purpose is.

Upvotes: 3

Related Questions