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

  • piiman - Saturday, January 31, 2015 - link

    who cares how many transistors if it still runs great? This however impacts performance. Dying light turns into a stuttering mess the second the vram go over 3.5gb. This causes me to have to go from a surround 5670x1080 to a single screen and lower graphic settings overall at 1980x1080p , so I can stay under 3.5gb vram,to keep the game playing at an keep good FPS.
    The whole reason I bought 2 970s was to be able to play new 4k games as this could hurt that plan in a big way.
  • fonolavalencia - Wednesday, February 4, 2015 - link

    Booooh, i have to play in one monitor, while people are dying in middle east !. you gringos will get the refound for sure, imagine myself being in ECUADOR... I hope they got a STEP UP program at least. This is very FISHY bussiness friends, we should stop this. And by the way, how about using an application to lower your ram to 3.5
  • frodbonzi - Thursday, February 5, 2015 - link

    Lol... this is a high end card, people dying in the Middle East have nothing to do with it, so get your trolling @ss out of here. And if you actaully bought 2 of these, you SHOULD NOT HAVE TO get an app to limit yourself to 3.5gb!! Especially if you bought them assuming they could handle 4gb!
  • Morawka - Monday, January 26, 2015 - link

    So what if they call everyone's bluff and offer refund's for the cards?

    that's what i would do if i were nvidia, just offer a refund, the majority of people will still keep their card, and nvidia could offer a free game to all those affected.

    Then once the class action suit fires up, they can show all of the goodwill they offered and the case would lose serious steam.
  • spartaman64 - Monday, January 26, 2015 - link

    i just hope nvidia updates the specs and put a disclaimer that there is .5GB of slow ram
  • JlHADJOE - Tuesday, January 27, 2015 - link

    Well, Nvidia's published specs (http://www.geforce.com/hardware/desktop-gpus/gefor... are technically correct, which some people would say is the best kind of correct.

    It's only the review sites really that posted stuff like ROP counts and cache size,
  • piiman - Saturday, January 31, 2015 - link

    funny, they removed that link with the spec's. Perhaps they weren't that correct after all?
  • fuckNvidia - Monday, February 9, 2015 - link

    That was giving to them by nvidia, brainwash the public by the media and say we didn't say it, still is not right.
  • xkieth - Thursday, January 29, 2015 - link

    By majority of people, you mean, those people who bought 970 without any knowledge of the issue. nVidia gives them a free game out of the blue(from their perspective) and ofcourse, free game is free, accepts it, being the oblivious people that they are.

    then BAM!. Ubisoft 2.0
  • piiman - Saturday, January 31, 2015 - link

    "So what if they call everyone's bluff and offer refund's for the cards?"

    A better solution is to turn on the ROP or offer 980's as replacements . Now that would be "good will"

Log in

Don't have an account? Sign up now