编辑
2025-04-07
记录知识
0
请注意,本文编写于 80 天前,最后修改于 59 天前,其中某些信息可能已经过时。

目录

cache种类
分配策略
回写策略
shareability
cache可见性

在学习cache的时候,有看到一系列的cache策略,这里汇总cache的策略,方便记忆

cache种类

cache分cacheable和non-cacheable
non-cacheable就是数据没有cache,而cacheable则又可以细分为如下

  • read/write allocate
  • write-back cacheable
  • write-through cacheable
  • shareability

分配策略

我们知道到数据miss的时候会分配cache line,那么主要有两种分配方式

  • read allocation

读取操作miss时,分配一个cache line,并记录cache

  • write allocation

写入操作miss时,分配一个cache line,并记录cache

回写策略

数据更新也就是write的时候,cache对回写的策略如下

  • write-back

写操作只会更新到cache,然后标记cache line为dirty,不会更新到内存中

image.png

  • write-through

写操作会直接更新到cache中,并同时更新到内存中

image.png

shareability

cache的共享属性分为 inner和outer,对于共享属性,我们可以这样记忆

  • 对于每个cluster内部,cache是inner shareable属性的
  • 两个cluster之间,cache是outer shareable属性的

image.png

cache可见性

  • PoU: point of unification : 对于inner share的cache,整个cluster内部看到的都是同一份cache的拷贝,不会出现两份不同的cache

image.png

  • PoC: point of coherency : 对于系统的硬件,如GPU,DMA,多个Cluster的CPU之间,看到的都是同一份cache的拷贝,不会出现两份不同的cache

image.png