The Secret of Denver: Binary Translation & Code Optimization

As we alluded to earlier, NVIDIA’s decision to forgo a traditional out-of-order design for Denver means that much of Denver’s potential is contained in its software rather than its hardware. The underlying chip itself, though by no means simple, is at its core a very large in-order processor. So it falls to the software stack to make Denver sing.

Accomplishing this task is NVIDIA’s dynamic code optimizer (DCO). The purpose of the DCO is to accomplish two tasks: to translate ARM code to Denver’s native format, and to optimize this code to make it run better on Denver. With no out-of-order hardware on Denver, it is the DCO’s task to find instruction level parallelism within a thread to fill Denver’s many execution units, and to reorder instructions around potential stalls, something that is no simple task.

Starting first with the binary translation aspects of DCO, the binary translator is not used for all code. All code goes through the ARM decoder units at least once before, and only after Denver realizes it has run the same code segments enough times does that code get kicked to the translator. Running code translation and optimization is itself a software task, and as a result this task requires a certain amount of real time, CPU time, and power. This means that it only makes sense to send code out for translation and optimization if it’s recurring, even if taking the ARM decoder path fails to exploit much in the way of Denver’s capabilities.

This sets up some very clear best and worst case scenarios for Denver. In the best case scenario Denver is entirely running code that has already been through the DCO, meaning it’s being fed the best code possible and isn’t having to run suboptimal code from the ARM decoder or spending resources invoking the optimizer. On the other hand then, the worst case scenario for Denver is whenever code doesn’t recur. Non-recurring code means that the optimizer is never getting used because that code is never seen again, and invoking the DCO would be pointless as the benefits of optimizing the code are outweighed by the costs of that optimization.

Assuming that a code segment recurs enough to justify translation, it is then kicked over to the DCO to receive translation and optimization. Because this itself is a software process, the DCO is a critical component due to both the code it generates and the code it itself is built from. The DCO needs to be highly tuned so that Denver isn’t spending more resources than it needs to in order to run the DCO, and it needs to produce highly optimal code for Denver to ensure the chip achieves maximum performance. This becomes a very interesting balancing act for NVIDIA, as a longer examination of code segments could potentially produce even better code, but it would increase the costs of running the DCO.

In the optimization step NVIDIA undertakes a number of actions to improve code performance. This includes out-of-order optimizations such as instruction and load/store reordering, along register renaming. However the DCO also behaves as a traditional compiler would, undertaking actions such as unrolling loops and eliminating redundant/dead code that never gets executed. For NVIDIA this optimization step is the most critical aspect of Denver, as its performance will live and die by the DCO.


Denver's optimization cache: optimized code can call other optimized code for even better performance

Once code leaves the DCO, it is then stored for future use in an area NVIDIA calls the optimization cache. The cache is a 128MB segment of main memory reserved to hold these translated and optimized code segments for future reuse, with Denver banking on its ability to reuse code to achieve its peak performance. The presence of the optimization cache does mean that Denver suffers a slight memory capacity penalty compared to other SoCs, which in the case of the N9 means that 1/16th (6%) of the N9’s memory is reserved for the cache. Meanwhile, also resident here is the DCO code itself, which is shipped and stored as already-optimized code so that it can achieve its full performance right off the bat.

Overall the DCO ends up being interesting for a number of reasons, not the least of which are the tradeoffs are made by its inclusion. The DCO instruction window is larger than any comparable OoOE engine, meaning NVIDIA can look at larger code blocks than hardware OoOE reorder engines and potentially extract even better ILP and other optimizations from the code. On the other hand the DCO can only work on code in advance, denying it the ability to see and work on code in real-time as it’s executing like a hardware out-of-order implementation. In such cases, even with a smaller window to work with a hardware OoOE implementation could produce better results, particularly in avoiding memory stalls.

As Denver lives and dies by its optimizer, it puts NVIDIA in an interesting position once again owing to their GPU heritage. Much of the above is true for GPUs as well as it is Denver, and while it’s by no means a perfect overlap it does mean that NVIDIA comes into this with a great deal of experience in optimizing code for an in-order processor. NVIDIA faces a major uphill battle here – hardware OoOE has proven itself reliable time and time again, especially compared to projects banking on superior compilers – so having that compiler background is incredibly important for NVIDIA.

In the meantime because NVIDIA relies on a software optimizer, Denver’s code optimization routine itself has one last advantage over hardware: upgradability. NVIDIA retains the ability to upgrade the DCO itself, potentially deploying new versions of the DCO farther down the line if improvements are made. In principle a DCO upgrade not a feature you want to find yourself needing to use – ideally Denver’s optimizer would be perfect from the start – but it’s none the less a good feature to have for the imperfect real world.

Case in point, we have encountered a floating point bug in Denver that has been traced back to the DCO, which under exceptional workloads causes Denver to overflow an internal register and trigger an SoC reset. Though this bug doesn’t lead to reliability problems in real world usage, it’s exactly the kind of issue that makes DCO updates valuable for NVIDIA as it gives them an opportunity to fix the bug. However at the same time NVIDIA has yet to take advantage of this opportunity, and as of the latest version of Android for the Nexus 9 it seems that this issue still occurs. So it remains to be seen if BSP updates will include DCO updates to improve performance and remove such bugs.

Designing Denver SPECing Denver's Performance
Comments Locked

169 Comments

View All Comments

  • techcrazy - Friday, February 6, 2015 - link

    Best Nexus 9 review i read. Excellent work anandtech team.
  • RobilarOCN - Friday, February 6, 2015 - link

    How does the Tab S fall short of the Nexus 9? I've owned both. Video playback battery life overwhelmingly supports the Tab S, it has a far superior screen (AMOLED...), It has a micro SD slot, it has the ability to connect to HDMI via MHL adapter. The only way the Nexus 9 can output video as it has no available adapter and no onboard MHL support is via 3rd party such as the Chromecast. The 16GB Nexus 9 and 16GB Tab S 8.4 are in the same price range but of course you can expand the memory on the Tab S via a micro SD card. The 32GB Nexus 9 sits in the same price range as the Tab S 10.1 and again the 10.1 can have cheap memory added to it.

    The only places the Nexus 9 wins is if you want a 4:3 format (and in that case the first gen IPad Air 64GB is cheaper and a better device) or if you absolutely have to have Lollipop which will eventually get to the Tab S.
  • UtilityMax - Sunday, February 8, 2015 - link

    In my opinion Tab S will be eventually remembered as a flop. Yes, it has a great wide screen and good battery life for video playback. So it's great for watching videos, which is why I bought one (and would buy it again). Unfortunately, videos is the only thing that Tab S does truly well. The Tab S forums on the web are filled with discussions about "lag" and why Chrome can be so slow. For a flagship tablet, the CPU/GPU performance scores could have been a little better, and the standby as well as web browsing battery life could be A LOT better. The other day I was stuck in a library for hours with this tablet and came to realization that I am not sure if this thing can last for 5 hours of web browsing on a full battery charge, which is horrendous. I have a Samsung laptop with a quad core i7 CPU and 17 inch screen that could work longer on a battery charge.

    Basically, this tablet gives you a great screen, SD card slot, good build quality, and not much else. I am still glad I got a 10.5 Tab S on a sale for $400. However, I don't think it's really worth the "regular" price of +500 dollars.
  • Impulses - Monday, February 9, 2015 - link

    5 hours? Yikes... My Atom netbook from half a decade ago could manage that...
  • UtilityMax - Sunday, February 15, 2015 - link

    But amazingly, the Tab S 10.5 can play a 720p video for something like 10 hours on a full charge. Go figure.
  • mkozakewich - Friday, February 6, 2015 - link

    Those NVidia charts obviously show the IPC measured in a 'ratio'. They're not going to tell us what exact IPC they get.

    So yeah, the highest it goes is less than 2.0, which means their IPC for optimized code isn't quite double the performance of regular ARM stuff. I'd suppose the regular code could get up to 3 IPC, which means the optimized stuff could get up to 6 IPC (out of the maximum 7). It seems to check out.

    I'd have expected you not to throw caution to the wind when reading first-party benchmark slides.
  • flamingspartan3 - Friday, February 6, 2015 - link

    The Nexus 7 2013 is still competitive in many of these benchmarks. It's remarkable how great the device is even after almost two years.
  • UtilityMax - Sunday, February 8, 2015 - link

    The criticism that there aren't enough apps for the big screen is somewhat misplaced. I suspect that web browsing, videos, ebooks, and productivity apps are the prime applications for the large screen tablets. Why bother with the facebook app, when you can just login into facebook from chrome, and with the biggish screen have access to the full facebook web site?
  • Impulses - Monday, February 9, 2015 - link

    Chrome alone probably accounts for like 80% of my tablet use (and I've had an Android tablet since the OG TF) seems that's not necessarily the norm tho...
  • Jumangi - Monday, February 9, 2015 - link

    Then why pay for a device with such high end components like the K1 SoC if your just gonna use the browser? Maybe this is what some do because the android marketplace is so limited for large tablet apps but doesn't mean its ok.

Log in

Don't have an account? Sign up now