Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exercise 6.37 #32

Open
zagortenay333 opened this issue Aug 14, 2018 · 1 comment
Open

exercise 6.37 #32

zagortenay333 opened this issue Aug 14, 2018 · 1 comment

Comments

@zagortenay333
Copy link

I don't quite understand your solutions to this exercise for sumB and sumC.

The array_t is more than a 2 multiple of the cache size (4C) and in sumB we read column by column. After the first 16 iterations of the inner loop the first quarter of the matrix will be in the cache, which means by the time we wrap around to the first row all blocks in the first quarter of the matrix will have been evicted.
sumB has a 100% miss rate, not 25%.

sumC is similar to sumB (reading columns wise) with the only diff being that we read two items out of a block once it's loaded into the cache, so we get two hits per block (per 4 ints).
sumC has a 50% miss rate, not 25%.

There is no difference between N=64 and N=60 because both will lead to a multiple of 16 and an array that is more than a 2 multiple of the cache size.

Since the stride is larger than the block size, sumB and sumC could have smaller miss rates only if the whole array_t was less than a 2 multiple of the cache size. For example, if the entire array could fit into the cache, then they would have a 25% miss rate.

@k0Iry
Copy link

k0Iry commented Jan 20, 2019

agreed. In sumB, reading columns always evicts the previous mapping, so the miss rate should be 100%. In sumC, the first two always miss, the latter always hits, so sumC's miss rate should be 50%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants