Segmented Memory Allocation in Software

So far we’ve talked about the hardware, and having finally explained the hardware basis of segmented memory we can begin to understand the role software plays, and how software allocates memory among the two segments.

From a low-level perspective, video memory management under Windows is the domain of the combination of the operating system and the video drivers. Strictly speaking Windows controls video memory management – this being one of the big changes of Windows Vista and the Windows Display Driver Model – while the video drivers get a significant amount of input in hinting at how things should be laid out.

Meanwhile from an application’s perspective all video memory and its address space is virtual. This means that applications are writing to their own private space, blissfully unaware of what else is in video memory and where it may be, or for that matter where in memory (or even which memory) they are writing. As a result of this memory virtualization it falls to the OS and video drivers to decide where in physical VRAM to allocate memory requests, and for the GTX 970 in particular, whether to put a request in the 3.5GB segment, the 512MB segment, or in the worst case scenario system memory over PCIe.


Virtual Address Space (Image Courtesy Dysprosia)

Without going quite so far to rehash the entire theory of memory management and caching, the goal of memory management in the case of the GTX 970 is to allocate resources over the entire 4GB of VRAM such that high-priority items end up in the fast segment and low-priority items end up in the slow segment. To do this NVIDIA focuses up to the first 3.5GB of memory allocations on the faster 3.5GB segment, and then finally for memory allocations beyond 3.5GB they turn to the 512MB segment, as there’s no benefit to using the slower segment so long as there’s available space in the faster segment.

The complex part of this process occurs once both memory segments are in use, at which point NVIDIA’s heuristics come into play to try to best determine which resources to allocate to which segments. How NVIDIA does this is very much a “secret sauce” scenario for the company, but from a high level identifying the type of resource and when it was last used are good ways to figure out where to send a resource. Frame buffers, render targets, UAVs, and other intermediate buffers for example are the last thing you want to send to the slow segment; meanwhile textures, resources not in active use (e.g. cached), and resources belonging to inactive applications would be great candidates to send off to the slower segment. The way NVIDIA describes the process we suspect there are even per-application optimizations in use, though NVIDIA can clearly handle generic cases as well.

From an API perspective this is applicable towards both graphics and compute, though it’s a safe bet that graphics is the more easily and accurately handled of the two thanks to the rigid nature of graphics rendering. Direct3D, OpenGL, CUDA, and OpenCL all see and have access to the full 4GB of memory available on the GTX 970, and from the perspective of the applications using these APIs the 4GB of memory is identical, the segments being abstracted. This is also why applications attempting to benchmark the memory in a piecemeal fashion will not find slow memory areas until the end of their run, as their earlier allocations will be in the fast segment and only finally spill over to the slow segment once the fast segment is full.

GeForce GTX 970 Addressable VRAM
API Memory
Direct3D 4GB
OpenGL 4GB
CUDA 4GB
OpenCL 4GB

The one remaining unknown element here (and something NVIDIA is still investigating) is why some users have been seeing total VRAM allocation top out at 3.5GB on a GTX 970, but go to 4GB on a GTX 980. Again from a high-level perspective all of this segmentation is abstracted, so games should not be aware of what’s going on under the hood.

Overall then the role of software in memory allocation is relatively straightforward since it’s layered on top of the segments. Applications have access to the full 4GB, and due to the fact that application memory space is virtualized the existence and usage of the memory segments is abstracted from the application, with the physical memory allocation handled by the OS and driver. Only after 3.5GB is requested – enough to fill the entire 3.5GB segment – does the 512MB segment get used, at which point NVIDIA attempts to place the least sensitive/important data in the slower segment.

Diving Deeper: The Maxwell 2 Memory Crossbar & ROP Partitions Practical Performance Possibilities & Closing Thoughts
Comments Locked

398 Comments

View All Comments

  • Ryan Smith - Monday, January 26, 2015 - link

    I have updated the article with more information (page 2).

    In short only GTX 970 has this configuration. 980M is a full memory controller layout, and 970M disables a whole ROP/MC partition, which means it's still balanced.
  • OrphanageExplosion - Monday, January 26, 2015 - link

    Interesting - 970M looks rather like a downclocked version of how I'd envisage a GTX 960 Ti, so hopefully there'll be no issues with that product.
  • bznotins - Monday, January 26, 2015 - link

    /shrug

    As a 970 owner, knowing this wouldn't have changed my buying decision whatsoever. All I really care about is output (quality/framerate) and price (thus value). All the technical details under the hood really don't change that.
  • mapesdhs - Monday, January 26, 2015 - link


    Succinctly and sensibly put.

    Ian.
  • just4U - Tuesday, January 27, 2015 - link

    Not quite.. prospective buyers look at the reviews and likely go by that with an initial purchase. It's quite possible that the reviews would have been slightly altered which could change a person's buying decision.. either getting something better (smaller chance..) or holding off (greater chance..) and sticking with what they have a little longer.

    The reviewer may not go into as much investigative detail in certain areas because they make assumptions based upon the spec sheet their given. If they'd known what was fundamentally off from the get go they'd have gone into greater detail and their summaries may have been toned down a little.
  • cgalyon - Monday, January 26, 2015 - link

    My concern, which may be completely unfounded, is that developers assuming 4GB of memory will opt to take advantage of that (either by over-allocation or actual usage) and the card reports it has that much available. When items enter into the segmented memory space, or a texture simply spans between the two (overflow of some amount), how will the card handle it? Will it produce stuttering, asynchronous events, or just an overflow crash? If any of those should happen, nVidia may be able to address that scenario (as you described in the article), but it would seem that 970 owners would be more dependent on nVidia's support. If that support is not forthcoming, then 970 owners would either experience performance problems or have to run at lower settings to prevent the problem from occurring.

    It currently seems like a non-issue, for which I'm glad (as a 970 owner), but if it ultimately means this card frequently encounters problems that need to be fixed, then this card becomes a bit of a headache to own.
  • DarkStryke - Monday, January 26, 2015 - link

    So you're telling me, the 970 isn't as good as the 980, who'd have thought?!
  • Horza - Monday, January 26, 2015 - link

    Thaks for explaining it so simply who needs the article at all. /s

    The 970 isn't as good as they said* n
  • Fernando H - Monday, January 26, 2015 - link

    I got my GTX 970 due to its excelent speep and great price. Now, when I say price, I consider the performance and how long I will keep it to my computer. since the memory has been reduced by around 13%, it is still a great performer, but I'm not too sure about its future. As games demand more and more memory, it can soon become outdated. At least sooner than it would if it actually had 4gb.
  • anandreader106 - Monday, January 26, 2015 - link

    You should be compensated, probably by class action lawsuit, for that extra value you thought you were getting.

    Even if it's just $20, you can put that towards your next card whenever that time comes.

Log in

Don't have an account? Sign up now