CS:APP--Chapter06 : memory hierarchy(part 2)

CS:APP--Chapter06 : memory hierarchy(part 2)

标签(空格分隔): CS:APP


2. Locality

How to exhibit a good locality is one of our goals when we are writing code. This kind of code always accesses data items either that are near the most recently accessed data items or that were recently accessed themselves.

According to it, locality is described as two distinct forms : temporal locality and spatial locality.

type description
temporar locality the accessed data item is likely to be accessed again multiple times in the near future
spatial locality the data item that is near the recently accessed data item is likely to be accessed in the near future

There is a giant advantage of good locality :
the program with good locality must run faster than one with poor locality. It's an effective approach that optimizes program.

2.1 locality of reference to program data

good temporar locality usually with loop

good spatial locality usually with less stride as loop proceeds

2.2 locality of instruction fetches

As same as reference to program data

The introduction has come so far in this time in moving onto the introduction of memory hierarchy.

3. the memory hierarchy

Admittedly, the trade-off between speed and volume (cost as well) always gets in the way of developing higher-performance storage devices.

3.1 caching in the memory hierarchy

memory hierarchy

What can it happen if there is no cache between the register and memory?
The gap in the processing speed between the register and main memory results in a big problem here.

cache bridges the gap in terms of speed and cost.

cache hits

cache misses

kind of cache misses

cache management

posted @ 2023-01-17 21:34  44636346  阅读(20)  评论(0)    收藏  举报