Sunday 28 March 2021

Laptop Hardware Update

A long time ago I used to have some good knowledge about computer hardware, but that's no longer the case. In the last years I only get slightly updated about hardware evolution when I buy (or receive from my employer) a new laptop. This has been the case recently, and out of curiosity I've been learning a few things.

Unless you're a gamer or 3D guy and has bought a laptop accordingly to you extra needs, it's 99% likely that your laptop has an integrated GPU, and not a dedicated one in a separate chip in the motherboard. Well, indeed, we could say that there are 2 different levels of GPU integration.

  • What we properly call integrated GPU means that a CPU die and a GPU die (a die is a block of semiconducting material) are placed in the same processor package.
  • AMD evolved this schema to what is called an APU, where the CPU and GPU are built on the same die. Notice that both entities continue to exist, it's not that the GPU has disappeared and the CPU is taking over its work.

I remember from the old times the existence of 2 main chips on the motherboard, the Northbridge and the Southbride. The Northbridge mainly takes care of the communication between CPU, GPU and Memory. My understanding is that in an integrated GPU the Nortbridge circuit (or a circuit with most of the functionality that was present in the traditional Northbridge) is also placed in the processor package but as a separate die. In an APU the Northbridge is built on the same die as CPU and GPU.

Integrated GPU's and APU's (I'll just use the term "integrated" for both cases), do not have a separate graphic memory, but they use the normal RAM for their tasks. Anyway, we'll continue to hear about the dedicated graphic memory of our integrated GPU. In this case, "dedicated" means that one fixed portion of the normal RAM is permanently reserved for graphic use, and is no longer available to the CPU. Apart from that, we have the shared GPU memory, that is the amount of normal RAM that can be shared between CPU and GPU, and that normally is set to 1/2 of the remaining physical memory. Portions of this shared GPU memory is taken and released by the GPU as needed, and if we are not using games or 3D stuff chances are that the GPU has enough with just the dedicated memory.

One could wonder why that dedicated memory is needed. In in many occasions we will be using just one part of it, so taking away all of it from the CPU beforehand seems odd... Well, it seems there are performance considerations. This dedicated memory is contiguous memory so its use will be a bit faster. Additionally, when reserving graphic memory from the shared memory there is additional logic to "negotiate" this. It's mentioned here.

I suspect the 2GB reservation is a firmware bug. 2GB is quite aggressive on an 8GB system and unlikely to have much higher graphics performance than say a 256-512MB up-front contiguous reservation with the rest being on-the-fly allocated "shared" memory. With modern hardware, the latency penalty for on-the-fly shared memory allocations and the associated scatter/gather techniques to collate them is small except for very specific workloads.

Windows 10 is quite good showing information about Graphic memory. In my work laptop I have 16 GBs of RAM, of which 512 MBs are dedicated to graphic use, and almost 1/2 of the remaining memory is availabe as shared graphic memory.

We can also see information in the Memory tab:

There's still something that I don't fully understand. As you see above, it says that 792 MBs are Hardware reserved. As we've seen in the first screenshot, 512 MBs are reserved (dedicated) for the GPU, so we have a 280 MBs gap!. OK, we should know that because of Memory-mapped I/O. Memory-mapped I/O remained confusing to me for years until I read this excellent answer. So part of the physical address space is used for accessing to IO devices rather than for RAM access. In 32 bits systems, where the address space is limited to 4 GBs that means that the CPU won't be able to use more than around 3.5 GBs of RAM. However, in 64 this is not a problem. As we have a huge address space, the addresses reserved for IO should be well above the addresses of our physical memory.
Well, given this 280 MBs gap in my system (I see something similar in my personal laptop too), maybe for some reason one part of the Memory-mapped I/O address space needs to be taken from the lower address space!?

No comments:

Post a Comment