1

Using the sequence of references from Exercise 5.2, show the final cache contents for a three-way set associative cache with two-word blocks and a total size of 24 words.

Here is the problem, how many "blocks" in this cache.

I think a block has 2 words, so there should be 12 blocks, and in three-way, one way contains 4 blocks. But the solution says there are 24/3=8 blocks per way.

Am I wrong? Or solution was not correct?

Mr.Knife
  • 69
  • 4

1 Answers1

0

Here is the problem, how many "blocks" in this cache.

24 words / 2 words-per-block = 12 blocks.


Blocks per way

One way of one set is one cache line, aka 1 block, which we're told is 2 words for this cache. One of the 3 ways across all sets is 24 words / 3 ways = 8 words = 4 blocks. You're correct.

That's an odd way to describe the total number of sets, but it is the same thing. You could also calculate it as 12 blocks / 3 blocks-per-set = 4 sets. Each way is by definition 1 block, so 3-way set associative means 3 blocks / set. So 24 words / (2 words/block * 3 blocks/set) = 24/6 blocks/set = 4 blocks/set.

What textbook is this? It's not CS:APP 3e global edition, is it? The practice problems in that edition of the textbook were replaced by incompetent people hired by the publisher, see CS:APP example uses idivq with two operands?

8 words per way (size of each set) is the distance between word addresses that index the same set, so accesses that far apart will alias each other and potentially generate a lot more conflict misses.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • actually the problem is not how many blocks per way. But you need to know for solving this problem. Full question is below. It's from Patterson's 5th edition – Mr.Knife Jan 17 '23 at 16:15
  • Using the sequence of references from Exercise 5.2, show the fi nal cache contents for a three-way set associative cache with two-word blocks and a total size of 24 words. Use LRU replacement. For each reference identify the index bits, the tag bits, the block off set bits, and if it is a hit or a miss. – Mr.Knife Jan 17 '23 at 16:15
  • @Mr.Knife: Oh right, number of blocks per way (across all sets) is the same thing as number of sets, so yeah it is what you need to know to figure out the cache indexing. Seems to me like an unusual way of describing it. – Peter Cordes Jan 17 '23 at 16:28