Memory Hierarchy - Why are registers expensive?

本秂侑毒 提交于 2019-12-10 18:37:34

问题


I understand that:

Faster access time > More expensive

Slower access time > Less expensive

I also understand that registers are the top of the hierarchy, and have the fastest access time. What I am having a hard time researching is why it's so expensive? To my knowledge, registers are literally circuits built directly into the ALU. If they're literally built into the CPU (the ALU especially), what actually makes it the most expensive?

Is it the size (registers being the smallest, of course)?


回答1:


Registers are very, very expensive because they have to be very, very fast and they need to be accessed from many places simultaneously.

For example if you have statements a = a + x; b = b + x; c = c + x; you have three instructions which all want to read the same register. So the register is not just the memory. There are also all the data paths that need to be in the processor so the same data from the register holding x can be sent to three instructions at the same time. 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 the register x to the floating point unit. Or to a vector unit. And so on.

Then you have the problem that not only to you need to store the data, you also must make sure that it is available. If you write x = y + z; a = a + x; someone must keep track when the first instruction runs that the register holding x is not valid right now until the result of the addition is stored, and stop the second addition from running. That is super expensive.

So there is much more to building a register than just adding a bit of memory, and that needs to be paid for. And registers are so essential to the speed of the processor, that the most expensive and fastest technology is used to build them.



来源:https://stackoverflow.com/questions/26055452/memory-hierarchy-why-are-registers-expensive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!