当前位置:网站首页>【并行与分布式系统】Cache学习
【并行与分布式系统】Cache学习
2022-06-11 01:10:00 【I'll carry you】
文章目录
我们一共有8行cache line,cache line大小是8 Bytes。所以我们可以利用地址低3 bits(如上图地址蓝色部分)用来寻址8 bytes中某一字节,我们称这部分bit组合为offset。同理,8行cache line,为了覆盖所有行。我们需要3 bits(如上图地址黄色部分)查找某一行,这部分地址部分称之为index。现在我们知道,如果两个不同的地址,其地址的bit3-bit5如果完全一样的话,那么这两个地址经过硬件散列之后都会找到同一个cache line。所以,当我们找到cache line之后,只代表我们访问的地址对应的数据可能存在这个cache line中,但是也有可能是其他地址对应的数据。所以,我们又引入tag array区域,tag array和data array一一对应。每一个cache line都对应唯一一个tag,tag中保存的是整个地址位宽去除index和offset使用的bit剩余部分(如上图地址绿色部分)。tag、index和offset三者组合就可以唯一确定一个地址了。因此,当我们根据地址中index位找到cache line后,取出当前cache line对应的tag,然后和地址中的tag进行比较,如果相等,这说明cache命中。如果不相等,说明当前cache line存储的是其他地址的数据,这就是cache缺失。在上述图中,我们看到tag的值是0x19,和地址中的tag部分相等,因此在本次访问会命中。由于tag的引入,因此解答了我们之前的一个疑问“为什么硬件cache line不做成一个字节?”。这样会导致硬件成本的上升,因为原本8个字节对应一个tag,现在需要8个tag,占用了很多内存。tag也是cache的一部分,但是我们谈到cache size的时候并不考虑tag占用的内存部分。我们可以从图中看到tag旁边还有一个valid bit,这个bit用来表示cache line中数据是否有效(例如:1代表有效;0代表无效)。当系统刚启动时,cache中的数据都应该是无效的,因为还没有缓存任何数据。cache控制器可以根据valid bit确认当前cache line数据是否有效。所以,上述比较tag确认cache line是否命中之前还会检查valid bit是否有效。只有在有效的情况下,比较tag才有意义。如果无效,直接判定cache缺失。
上面的例子中,cache size是64 Bytes并且cache line size是8 bytes。offset、index和tag分别使用3 bits、3 bits和42 bits(假设地址宽度是48 bits)。我们现在再看一个例子:512 Bytes cache size,64 Bytes cache line size。根据之前的地址划分方法,offset、index和tag分别使用6 bits、3 bits和39 bits。如下图所示。
边栏推荐
- Return function of different return values
- Find - (sequential search)
- 14:00面试,14:08就出来了 ,问的实在是太...
- Go develop web
- Coordinates of the capital of each province in China
- How to reinstall win11 drawing tool when it is missing
- 关于Set集合类你都知道什么?来自《卷Ⅰ》的灵魂提问
- Oracle tablespaces, users, and authorization to users
- NFT Insider #61:Animoca Brands 在 340 项投资中持有 15 亿美元的加密资产
- [matlab] image compression coding (DCT, RLE)
猜你喜欢

ABAP CDs realizes multi line field content splicing

Task02: linked list

FB02编辑Coding Block字段

InfoQ geek media's 15th anniversary solicitation | in depth analysis of container runtime Technology

ACM tutorial - heap sorting

---Arrange numbers---

Go develop web
![Md61 plan independent demand import Bapi [by daily dimension / dynamic template / dynamic field]](/img/28/2a4fd7f019f6528bd322c5e75ecaa7.png)
Md61 plan independent demand import Bapi [by daily dimension / dynamic template / dynamic field]

JS basic part hand exercises

ME11/ME12采购信息记录及条件记录创建及更新BAPI:ME_INFORECORD_MAINTAIN_MULTI
随机推荐
可扩/减容线程池C语言原理讲解及代码实现
CRS-4544 & ORA-09925
[3.delphi common components] 8 dialog box
[matlab] image segmentation
[matlab] image transform (Fourier transform, discrete cosine transform)
14: 00 interview, came out at 14:08, the question is really too
Within one month, the broadcasting volume has increased by 9million, and station B has three traffic growth passwords!
Task03: building an offline material system
Analysis of common ADB commands
The female programmer gives out a salary slip: the salary is high, but she feels she is 10 years old
[penetration test tool bee] how to install and use the XSS penetration test tool bee?
Secret
Find - (sequential search)
20n10-asemi medium and small power MOS transistor 20n10
Merge sort ()
MD61计划独立需求导入BAPI【按日维度/动态模板/动态字段】
[music] playing city of the sky based on MATLAB [including Matlab source code 1874]
[C language] storage of data in memory -1 plastic
Record the actual record of my question brushing
27岁女生零基础转行软件测试,合适吗?
