Discussion:
hit percentage problem?
(too old to reply)
Jeremy Cowles
2008-08-14 05:46:50 UTC
Permalink
Raw Message
I'm confused as to how to calculate the hit percentage for cache/TLB and
page table. (I'm looking at problem F2(c-e) in fall 06 final).
The solution only lists steps in fraction, doesn't tell me where the
numbers are from. Any help?
c) Calculate hit % for cache

Since this is a percentage, and both loops are doing the same thing in terms
of memory access
you can just look at one of them.

Hit % for cache = hits / (total reads)

reads = data / stride
= 8K / 128 = 2^13 / 2^7 = 2^6
= 64 reads

The loop increments by 128 each iteration, which is in int's, so you
multiply it by 4 to get bytes so it's compatible with the block size which
is given in KiB:

stride = 128*4
= 2^7 * 2^2
=2^9 Bytes
= 512 Bytes

Since the block size is 1 KiB, which is 1024 Bytes, and it was given that
the data is block aligned, there will be one
compulsory miss per block, and then one hit. Since there are 64 iterations,
each with 1 hit and 1 miss, you just count the hits, 32. So

Hit % = 32 / 64 = 50%


d) Calculate hit percentage for TLB

Again, the loops are both processing in the same direction, so you can just
look at one of them. So first find out how many reads there are per page:

reads/page = page size / stride (128*4)
= 2^12 / 2^9
= 2^3
= 8 reads / page

So there are 8 reads per page, and one must be a compulsory miss, and 7 will
hit. So:

TLB Hit % = 7/8

e) Calculate the page hit % for the page table

First, find the number of pages the data fits into:

data = 8192 ints
= 8KiB * 4
= 32KiB

The page size is 4 KiB, so

#pages = 32 / 4
= 8 pages of data

And there is 1 MiB of physical address space, so

# physical pages = 2^20 / 2^12
= 2^8
= 256 pages

So the 8 pages fit in memory fine, every read will be a hit:
100%


Sorry if I over explained this, I was half convincing myself at the same
time :)

Jeremy
Jeremy Cowles
2008-08-14 05:51:03 UTC
Permalink
Raw Message
Sorry, mistake: the directions said only look at the second loop, marked
*special*.

This is why the page hit % is 100%, because the first loop guarantees that
the page will be loaded.
Without that, I'm not sure what would happen (as far as the page table hits
go).
Post by Jeremy Cowles
I'm confused as to how to calculate the hit percentage for cache/TLB and
page table. (I'm looking at problem F2(c-e) in fall 06 final).
The solution only lists steps in fraction, doesn't tell me where the
numbers are from. Any help?
c) Calculate hit % for cache
Since this is a percentage, and both loops are doing the same thing in
terms of memory access
you can just look at one of them.
Hit % for cache = hits / (total reads)
reads = data / stride
= 8K / 128 = 2^13 / 2^7 = 2^6
= 64 reads
The loop increments by 128 each iteration, which is in int's, so you
multiply it by 4 to get bytes so it's compatible with the block size which
stride = 128*4
= 2^7 * 2^2
=2^9 Bytes
= 512 Bytes
Since the block size is 1 KiB, which is 1024 Bytes, and it was given that
the data is block aligned, there will be one
compulsory miss per block, and then one hit. Since there are 64
iterations, each with 1 hit and 1 miss, you just count the hits, 32. So
Hit % = 32 / 64 = 50%
d) Calculate hit percentage for TLB
Again, the loops are both processing in the same direction, so you can
just look at one of them. So first find out how many reads there are per
reads/page = page size / stride (128*4)
= 2^12 / 2^9
= 2^3
= 8 reads / page
So there are 8 reads per page, and one must be a compulsory miss, and 7
TLB Hit % = 7/8
e) Calculate the page hit % for the page table
data = 8192 ints
= 8KiB * 4
= 32KiB
The page size is 4 KiB, so
#pages = 32 / 4
= 8 pages of data
And there is 1 MiB of physical address space, so
# physical pages = 2^20 / 2^12
= 2^8
= 256 pages
100%
Sorry if I over explained this, I was half convincing myself at the same
time :)
Jeremy
Loading...