【问题标题】:How to calculate Cache hit ratio from 2-way set associate cache如何从 2 路集关联缓存计算缓存命中率
【发布时间】:2014-04-07 00:34:27
【问题描述】:

在我的作业中,我们有 2 个问题:我们有一个 2-way set associative cache。缓存共有四组。主存储器由 4K 块组成,每块 8 个字,并使用字寻址。 a) 部分要求演示地址格式,我已解决为 word = 3 bit set =2 bit 和 field = 7 bit。我遇到的问题在 b) 部分: 计算从位置 8 到位置 51 循环 3 次的程序的命中率。换句话说,将其视为从位置 8 的操作码运行到位置 51m 的操作码然后循环回到位置 8 的汇编语言程序. 它总共进行了 3 次这样的迭代。

现在据我了解,在我完成研究后,通常会给出某种标准的速度或命中率?我想知道如果我不知道未命中率、未命中惩罚、缓存速度或任何其他信息,我该如何计算命中率?

【问题讨论】:

    标签: caching


    【解决方案1】:

    我想我们在同一个班,哈哈,我今晚的作业有完全相同的问题。无论如何,我做了一些研究,并在 chegg 上找到了一个类似问题的答案:

    a. Given that memory contains 2K blocks of eight words.
    2K can be distributed as 2K * 23 = 211* 23 = 214 so we have 14-bit addresses with 9 bits
    in the tag field, 2 bits in the set field and 3 in the word field
    
    b. First iteration of the loop:
        → Address 8 is a miss, then entire block brought into Set 1.9-15 are then hits.
        → 16 is a miss, entire block brought into Set 2, 17-23 are hits.
        → 24 is a miss, entire block brought into Set 3, 25-31 are hits.
        → 32 is a miss, entire block brought into Set 0, 33-39 are then hits.
        → 40 is a miss, entire block brought into Set 1 41-47 are hits.
        → 48 is a miss, entire block brought into Set 2, 49-51 are hits.
    
        For the first iteration of the loop, we have 6 misses, and 5*7 + 3 hits, or 38 hits.
        On the remaining iterations, we have 5*8+4 hits, or 44 hits each,for 88 more hits.
        Therefore, we have 6 misses and 126 hits, for a hit ratio of 126/132, or 95.45%.
    

    希望这会有所帮助,祝你好运!

    【讨论】:

    • 顺便说一句,我得到的答案与您对 a 部分的答案不同。我得到了 10 位标签字段、2 位设置字段、3 位字字段。
    猜你喜欢
    • 2018-07-22
    • 1970-01-01
    • 2014-07-29
    • 2019-10-05
    • 2018-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多