Memory hierarchy. Why are registers expensive?
I understand that:
Faster access times> Extra expensive
Slower access times> Less expensive
I also understand that registers are the top of the hierarchy and have the fastest access times. What is difficult for me to research, why is it so expensive? As far as I know, registers are literally built directly in ALU. If they are literally built into the CPU (especially the ALU), what actually makes it the most expensive?
Is this the size (registers are the smallest, of course)?
source to share
Registers are very, very expensive because they have to be very, very fast, and they need to be accessed from many places at the same time.
For example, if you have statements a = a + x; b = b + x; c = c + x; you have three instructions that all want to read the same case. Thus, a register is not just memory. There are also all data paths that need to be in the processor, so the same data from the register containing x can be sent simultaneously on three instructions. And the data can go to many, many places. If you write double a = x; and x is an integer, then there must be a data path that sends register x to a floating point block. Or to a vector unit. Etc.
Then you have a problem not only with the fact that you need to store data, but you also need to make sure that it is available. If you write x = y + z; a = a + x; someone needs to keep track of when the first command runs that the register holding x is invalid right now until the result of the addition is saved and stop executing the second addition. It's super expensive.
So there is a lot more room for creating a register than just adding bits of memory, and it comes at a price. And registers are so important to processor speed that the most expensive and fastest technologies are used to build them.
source to share