简体   繁体   English

确定代码片段的缓存未命中率

[英]Determine cache miss rate for a code snippet

I am preparing for an upcoming exam and I was having trouble with this problem:我正在为即将到来的考试做准备,但遇到了这个问题:

direct mapped cache of size 64K with block size 16 bytes.大小为 64K 的直接映射缓存,块大小为 16 字节。 Cache starts empty缓存开始为空

在此处输入图像描述

What is the cache miss rate if...如果...,缓存未命中率是多少?

  1. ROWS = 128, COLS = 128行 = 128,列 = 128
  2. ROWS = 128 and COLS = 192行 = 128 和列 = 192
  3. ROWS = 128 and COLS = 256行 = 128 和列 = 256

[solution: page 5 http://www.inf.ethz.ch/personal/markusp/teaching/263-2300-ETH-spring11/midterm/midterm.pdf ] [解决方案:第 5 页 http://www.inf.ethz.ch/personal/markusp/teaching/263-2300-ETH-spring11/midterm/midterm.pdf ]

I was confused about how they got "the cache stores 128 x 128 elements".我对他们如何获得“缓存存储 128 x 128 元素”感到困惑。 I thought the cache size was 64K (2^16).我认为缓存大小是 64K (2^16)。

Also, can someone explain how to approach each question?另外,有人可以解释如何处理每个问题吗? My professor had some formula to calculate the number of accesses in each block: block size/stride, but it doesn't seem to work here.我的教授有一些公式来计算每个块中的访问次数:块大小/步幅,但它似乎在这里不起作用。

As far as I understand;据我所理解; in case 1, both src and dst matrices are of 64kb size (128 * 128 * 4 bytes);在情况 1 中,src 和 dst 矩阵都是 64kb 大小(128 * 128 * 4 字节); since the cache is directly mapped and has a size of 64kb;因为缓存是直接映射的,大小为 64kb; the entries of src & dst of the same indexes will have to be mapped to the same location in the cache (since (0+i mod)64 = (64+i mod)64) at the same time to be used in the line相同索引的 src 和 dst 的条目必须同时映射到缓存中的相同位置(因为 (0+i mod)64 = (64+i mod)64)才能在行中使用

dest[i][j]=src[i][j]

Therefore you have 100% miss rate;因此,您有 100% 的未命中率; The same is applied to case 3 since the new size is a multiple of 64kb (128 * 256 * 4), so it doesn't make any difference;同样适用于案例 3,因为新大小是 64kb (128 * 256 * 4) 的倍数,所以没有任何区别;

But for case 2;但是对于案例2; the size of the matrices becomes 96 kb (128 * 192 *4 bytes);矩阵的大小变为 96 kb(128 * 192 *4 字节); so now both src & dst may be loaded at the same time and you will have a lower miss rate.所以现在可以同时加载 src 和 dst 并且您的未命中率会更低。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM