6.3 The Memory Hierarchy

存储器的结构

最近在阅读GPU相关文献的时候看到cache相关的术语,上一次看到这些还是在学校里的时候,有些记不清了,翻了下CSAPP复习了下cache line,cache set相关的内容。

Cache的组织

cache分为很多个set,每个set里面有很多个cache line,每个Cache line包含了valid bit和tag bits,这样内存地址从高到低分为三个部分:

  1. tags,用来确定set中的哪个cache line
  2. set index,用来选择set
  3. block offset in cache line,用来在cache line定位内存偏移

三种不同cache layout

  1. direct mapped caches
    1. 最简单,每个set中只有一个cache line
    2. 缺点是当连续访问只有tag不同的多个内存地址时,会导致连续cache miss
  2. set associative caches
    1. 是两种方案的折中设计
  3. full associative caches
    1. 最复杂,只有一个set
    2. 缺点是一个set中有很多cache line,找到复合tag的时间复杂度很高,硬件不好设计
原文地址:https://www.cnblogs.com/hamwj1991/p/12401363.html