Why does the CPU have multiple cache levels such as L1, L2, L3?

"CPUcacheIs multilayered in the way that L1 is 32 KB, L2 is 256 KB, L 3 is 2 MB, why is it not possible with L1 cache of 32 KB + 256 KB + 2 MB? "Fabian Giessen (ryg) responds clearly to the simple question" How to work in the old office in the 1960s "as an example.

Why do CPUs have multiple cache levels? | The ryg blog

The answer to the short version for the above question is "Because each cache has a role." As a premise, it is an answer that it is advantageous to use different kinds of caches depending on necessity, as the cache has the property of slow data transfer speed, high storage density and power saving as the capacity is large .

If you are someone with knowledge and brains clear, you may be able to understand with short version response, but to make it easy for people who have little knowledge, Mr. Giessen speaks of an office worker and speaks differently It explains the role of cache.

Let's assume you are a white-collar office worker with a bureaucratic system of the 1960's. At that time, of course, not in the company such as a computer, manage the necessary documents by putting them in a file case on a paper basis.

Work is done on "my own desk" (a paragraph of "L1 cache"), but materials that we think frequently to use or are likely to use afterwards are placed in a file case and placed on a desk . Although the file case contains various materials, even if one piece of paper is used, it should be retrieved by searching out the data in the file case so as to find out from the file case.

There is also a "cabinet" (analogy of "L2 cache") that secures a large amount of materials in the office. In the cabinet, materials that I have recently used but I do not use right now are lined up. And, in order to make the work efficient, what you do not use in the materials on the desk is a habit of going into a cabinet case. Of course you can use the cabinet's material again, but it takes time and effort to go away taking the seat. Furthermore, it takes time to locate the target material from among a large amount of materials in addition to the index, and it is a feeling that it is troublesome that it is not comparable with the file case material on the desk.

So there is a worker called "Buster" (a parable of "calling the bus") to help you use the cabinet's material. Those that are no longer used in the file in the file case of the desk will be handed to the buster. Buster puts the received data into the cart. Buster patrols the office and checks if anyone is seeking cabinet sorting. Of course, it is Buster who knows the file extracted from the cabinet.

Sometimes someone has requested a buster that does not exist in the cabinet, but there is a case that the data is not on the cabinet but on the desk of another person. At that time, Buster can not silently grab that document on the desk. Buster will check with the desk main to see if it is using or not using it to discuss the liberalization of materials.

The cabinet that keeps the information is always filled with materials. This means that the data collected by Buster can not be returned to the cabinet. Here Buster should do the work to make space in the cabinet case. Therefore, Buster will bring the cabinet's data to the cafe in the basement of the office (parable of "L3 cache").

In the underground storage cabinet, the materials are packed tightly in cardboard boxes and stored on shelves. You will never step into the underground document cabinet of the office worker. The buster goes back and forth between the underground document cabinet and the office, so that the document is moved to the necessary place as necessary.

This is a story in a building that contains "office" called "CPU". Although the building is located in a good location so that office workers are easy to work, the rent is naturally higher. As a result, there is a limit in the space of the underground document cabinet, so it is impossible to hold all the materials in the office. So, what to do with materials that can not be kept is that the company is to prepare a suburban warehouse (a parade of "DRAM" which is the main memory) that is about 30 minutes away from the office by car from the office and store it there I will.

The role of Buster is up to the management of the underground document storage cabinet, and the exchange of materials with suburban warehouse is the role of another warehouse manager. If the office worker requests material in a suburban warehouse, firstly transmit the necessary files to the buster, and if the buster confirms that there is no material in the underground material storage cabinet, it is aimed at the warehouse manager After teaching the materials, the warehouse manager goes to the warehouse, finds the material, returns to the office again, hands the data to the buster, the office worker receives the data from the buster, it takes a lot of time That is why.

That is why "The cache of CPU is divided into multiple layers of L1, 326 MB, 256 KB, 2 MB, but why 32 KB + 256 KB + 2 MB L1 cache is useless?" If we examine the question again, You can see that the alternatives presented by this questioner are like using desks 150 meters wide. Furthermore, on such a desk it can happen that walking 50 meters to get the material with too big a desk. The good accessibility of "reaching hands as soon as you reach it" is important, and desks that are too large, that is, multiple cache levels are not coherent.

Furthermore, it is also very important to work alone on a small desk rather than a large desk (not sharing the cache). Even on a huge desk, if four people share it, only you can not use the materials. It takes time to hand over the materials and may wait in order. It is important that the L1 cache is a separate desk that only you can monopolize.

in Hardware, Posted by darkhorse_log