Chapter VI-depth understanding of the storage hierarchy computer system a second time

 

The second time reading this book, spend two to three hours a week of time, you can read how much to read (the read pages 399 - 408 and 418 to 424, a total of 17)

The first pass the corresponding notes link  https://www.cnblogs.com/stone94/p/10056104.html

 

Quantizing each memory speed difference

CPU to access data about the number of devices required for each cycle

Cycle register 0

Cache 4 to 75 cycles

Main memory hundreds of cycles

Disk tens of millions of cycles

 

Understand the practical effect of the memory hierarchy results

Locality can write good programs, such as programs that run faster

 

RAM: Random-Access Memory, Random Access Memory

Divided into two categories:

Static fast SRAM cache
DRAM dynamic slower main memory

 

ROM: Read-Only Memory, read-only memory (Note: some read-only memory can be read either write, do not be confused by the name)

Hard disk is a kind of ROM

 

Locality

Locality usually have two different forms: temporal locality and spatial locality

In a program with good temporal locality, the referenced memory location once again is likely to be referenced multiple times in the near future

In good spatial locality has a program, if a memory location is referenced once, then the program is likely to reference a memory location nearby in the near future.

There are good local programs run faster than the local poor program. (The importance of local programs written for programmers)

All levels of modern computer systems, from hardware to operating systems to applications that are designed to take advantage of the locality. (The importance of local computer design)

 

Some simple principles of quantitative evaluation of the program locality

1, refer to the same variable repeated program has good temporal locality

2, for a length k is not a reference to the program mode, the smaller the step size, the better the spatial locality. The program has a step size reference mode 1 has good spatial locality. In memory for long stride jumping program, spatial locality will be poor.

3, for the instruction fetch, the cycle time and good spatial locality. The smaller the loop, the more the number of loop iterations, the better the locality.

 

Cache Hit

When a program needs k + 1 th layer data object an d, d he first looks at a k-th block in the current storage layer. If d k exactly cached in the first layer, then what we call a cache hit.

Cache miss

With respect to the cache hit, if the k-th layer data is not cached objects d, it is what we call a cache miss.

The type of cache miss

Distinguish between different types of cache miss sometimes is helpful. If the cache level k is empty, so any data access object will not hit. An empty the cache is sometimes called cold cache, called such mandatory miss miss miss or cold.

Because without a hit occurs is normal, so do not hit occurs when there must be a corresponding placement policy. If the most flexible way (i.e., k + 1 to allow the first layer to any block on any of the blocks in the k-th layer), the cost will be higher, because the random placement block, positioning them costly. Thus, in reality, to be used is usually placed more stringent policies, even if the first block k + 1 k-th block layer there is a layer of "many" mapping between the (k + 1 th layer is a several blocks can be mapped to a certain block in the k-layer), which would not lead to a hit by the placement policy caused, we call conflict misses.

 

To write cache friendly code, you need to comply with the following two principles:

1, so that the most common situation of running fast. Programs usually spend most of their time on a small number of core functions, and these functions are usually the most time spent on a small circulation. Therefore, we should focus on the core functions in the cycle, while ignoring other parts.

2, to minimize the cache miss within each cycle number. Under other conditions being equal, the lower hit rate cycle does not run faster.

 

 

Guess you like

Origin www.cnblogs.com/stone94/p/11829561.html