Memory – Hierarchy Design 存储层次设计

1.  Intro

存储器件的 存储速度&离cpu的距离&价格/大小 逆相关,离CPU越近,速度越快,空间越小,价格越高。

时间局部性(Temporal Locality):If an item is referenced, the same item will tend to be referenced again soon.

空间局部性(Spatial Locality):If an item is referenced, nearby itemswill tend to be referenced soon.

 

2. ABCs 36个名词

Cache 缓存,在CPU与增加数据读取速度
full associative 全相关映射可以将一个主存块存储到任意一个Cache行,使用灵活,利用率(命中率)高。
write allocate miss时:先读到速度更快的缓存中进行更改
Virtual memory 把分散的物理地址映射到连续的逻辑地址中,通过页表进行转换
dirty bit cache中已经改过但还没有写回主存
unified cache 合并的cache,既有data也有inst
Memory stall cycles 指令访问存储时由于miss带来的停顿周期数
block 块
block offset 映射到某block后的具体位置
misses per instruction 指令的丢失
direct mapped 直接映射 有多少位置就有多少组
write back 在cache中进行修改后要写回到主存
Valid bit 是否可用
data cache 存储数据的部分
locality 局部性
Block address (index+tag)block的地址
hit time 命中时间
address trace 存放指令的cache 存放宏指令时会把相关指令存入 对分支结构的解决方案的cache
Write through 在写cache的同时写到内存里
cache miss 在cache未找到内容
set 有多少个组
Instruction cache 存储指令的部分
page fault 缺页,Memory中不含该地址,需要读取disk
miss rate cache的失配率
random replacememt 随机匹配一个block来替换
index field cache block的index匹配失败
cache hit cache命中
Average memory access time 平均存储访问时间 hit time + miss rate * miss penalty
page 逻辑地址和物理地址之间的关系
tag field cache blcok的tag匹配失败
n-way set associative 映射到某组中任意一个空间
no-write allocate miss时不先读到速度更快的缓存中进行更改,在底层更改
miss penalty miss后要到内存去读数据所产生的代价
Least-recently used (LRU)最近最少访问
write buffer 防止写回速度过快导致有数据没有写回去
write stall write很快时需要进行停顿

 

3. Cache设计的四类问题

  • Block placement(映射关系)
    • Fully Associative, Set Associative, Direct Mapped
  • Block identification(识别机制)
    • Tag/Block
  • Block replacement(替换策略)
    • Random, LRU,FIFO
  • Write strategy(写策略)
    • Write Back or Write Through (with Write Buffer)

 

4. Block Placement

Direct Mapped 主存中的一个 Block 只能映射到 Cache 上的唯一位置。

*可以看作将 Cache 分成了八个组,每个组只有一个 Block。算法:Mod 取模。

Full-associative 主存中的一个 Block 可以映射到 Cache 上的任何位置。

* 可以看作将Cache 分成了一个组。

n-way associative  主存中的一个 Block 可以映射到 Cache 唯一个组的任何位置。

 

5. The Format of the Physical Address

Tag/Index/Byte Offset

Index  「采用n-way:选择组;采用直接映射:选择block」

Tag 「采用n-way:有log2(#sets)位 ;采用直接映射:有log2(#blocks)位」

Byte Offset 「有log2(block size)位」

 

6. Block Replacement

  • 在直接映射的 Cache 里,只有一个 Block 能够被替换。(不需要块替换策略)
  • 在全关联和组关联的 Cache 里,有多个 Block 能够被替换。

Random replacement 随机替换

Least-recently used (LRU) 最近最少使用

First in,first out(FIFO) 先进先出

 

7. Write Strategy

Write-through cache written to memory 直接写回内存

Write-back cache NOT written to memory 不直接写回,在块替换时统一写回

 

8. Write stall

Write stall CPU等待写执行的停顿

Write buffers 防止大量写操作堵塞,先写入write buffer,在其他时候再写回内存。

 

9. Write misses 写操作在 write 时未命中

Write allocate 先载入到cache中,再进行操作。

Write around 只写入主存中,不存储在cache中。

  • 一般的,write-back使用write-allocate,write-through使用write-around。

10. Cache performance

CPU Execution Time

Average Memory Access Time

= Hit time + Miss Rate * Miss Penalty

= (Accesses time on hitting + Accesses time on miss) / All memory accesses in program

= HitTimeinst + MissRataInst * Miss

  • 如果100条指令里有26条LS指令,则INST%为100/126,DATA%为26/100。

 


0 条评论

发表评论

Avatar placeholder