Cache

xiaoxiao2021-03-06  48

Cache work principle

1, read order

When the CPU is to read a data, you will first find it from cache. If you find it, you will read it and give it to the CPU process; if you don't find it, use the relatively slow speed to read and give it to the CPU processing, and put this The data block where the data is located, which can make the readings of the entire block of data from Cache later without having to call memory.

It is this reading mechanism to make the CPU read the hit rate of Cache (most CPU up to 90%), that is, 90% of the data to be read in CPU in cache, only about 10% Need to read from memory. This greatly saves the time when the CPU is directly read, and it is basically no waiting when the CPU reads the data. In general, the order in which the CPU reads data is the first cache memory.

2, cache classification

The front is to consider Cache as a whole, and now you have to classify. Intel begins separate Cache from Pentium, usually divided into first-level cache L1 and secondary cache L2.

In the context, L1 Cache is integrated in the CPU, called the inner Cache. Data cache (i-cache) and instruction Cache (D-Cache) are also submitted in L1. They are used to store data and instructions to perform this data, and two Cache can be accessed by the CPU, reducing the conflicts caused by Cache, and improves processor efficiency.

A advanced level command cache-dynamic tracking cache is used in the P4 processor. It is directly connected to the execution unit and the dynamic tracking engine, and the executed instruction can be quickly found through the dynamic tracking engine, and the order of the instruction is stored in the tracking cache, which reduces the decoding cycle of the main execution cycle, improves processing The operational efficiency of the unit.

The previous L2 Cache is not integrated in the CPU, and is integrated on the motherboard or integrated with the CPU, and therefore also referred to as a sheet Cache. However, starting from PIII, due to the improvement of the process of the process L2 Cache is integrated into the CPU kernel, the history of the L2 Cache and the CPU is divided into the frequency, so that the L2 Cache and L1 Cache are equally equal. Get higher transmission speed. L2Cache only stores data, so it does not divide data Cache and instruction Cache. In the case of the CPU core, increase the capacity of L2 Cache enable performance, the same core CPU high and low end is often made on L2 cache, which can be seen in L2 Cache importance. The only difference between the L1 Cache and L2 Cache of the CPU is in the read order.

3, read the hit rate

The CPU finds useful data in cache is called hit, and when there is no data required in the Cache (here, it is called no misses), the CPU accesses the memory. In theory, in a CPU with Level 2 Cache, the hit rate of L1 Cache is 80%. That is to say, the useful data found in the L1 cache accounts for 80% of the total data, and the remaining 20% ​​is read from the L2 Cache. Since the data to be executed cannot be accurately predicted, the hit rate of the L2 is also around 80% (6% of the data read from L2 to the total data). Then there is some data to be called from memory, but this is already a fairly small proportion. In some high-end CPUs (like ITANIUMs like Intel), we often hear L3 cache, which is designed for data designs after L2 cache, in Cache, only about 5 in CPUs with L3 Cache % Of the data needs to be called from memory, which further enhances the efficiency of the CPU.

In order to ensure that the CPU has a high hit rate, the contents in the cache should be replaced by a certain algorithm. A more common algorithm is "Lost Lost Use Algorithm" (LRU Algorithm), which is eliminated in the least visit to the least visit. Therefore, it is necessary to set a counter for each line, the LRU algorithm is clearing the counter in the hits, and other rows counter plus 1. Data line outlines in the elimination of row counter count values ​​are required to be replaced. This is an efficient and scientific algorithm that eliminates Cache, improves Cache, and improves Cache, and improves Cache. Cache technology development

In summary, there can be used Cache as a match, or the transmission channel of these devices can be adjusted as a matching device. In display system, hard disk, and optical drive, and network communication, Cache technology needs to be used. However, Cache is composed of static RAM, complex, cost-effective, and use existing processes in a limited area, it is impossible to do very much, but this is also the source of technology, there is a need to make progress!

转载请注明原文地址:https://www.9cbs.com/read-80793.html

New Post(0)