Let's talk Compilers...

Creating the perfect compiler is one of the more difficult problems in computing. Compiler optimization and scheduling is an NP-complete problem (think chess) so we can't "solve" it. And compounding the issue is that the best compiled code comes from a compiler that is written specifically for a certain processor and knows it inside and out. If we were to use a standard compiler to produce standard x86 code, our program will run much slower than if we tell our compiler we have a P4 with SSE2 and all the goodies that go along with it. I know this all seems pretty obvious, but allow me to illustrate a little.

Since I've always been interested in 3D graphics, back in 1998 I decided to write a 3D engine with a friend of mine for a project in our C++ class. It only did software rendering, but we implemented a software z-buffer and did back face culling with flat shading. Back then, my dad had a top of the line PII 300, and I acquired an AMD K6 200. Using a regular Borland C++ compiler with no real optimizations turned on, our little software 3D engine ran faster on my K6 than it did on my dad's PII. Honestly, I have no idea why that happened. But the point is that the standard output of the compiler ran faster on my slower platform while both systems were producing the same output. Now, if I had had a compiler from Intel optimized for the PII that knew what it was doing (or if I had hand coded the program in assembly for the PII), my code could have run insanely faster on my dad's box.

So, there are some really important points here. Intel and AMD processors were built around the same ISA (Instruction Set Architecture) and had a great deal in common back in 1998. Yet, performance varied in favor of the underpowered machine for my test. When you look at ATI and NVIDIA, their GPUs are completely and totally different. Sure, they both have to be able to run OpenGL and DirectX9, but this just means they are able to map OGL or DX9 function calls (via their drivers) to specific hardware routines (or even multiple hardware operations if necessary). It just so happens that the default Microsoft compiler generates code that runs faster on ATI's hardware than on NVIDIA's.

The solution NVIDIA has is to sit down with developers and help handcode stuff to run better on their hardware. Obviously this is an inelegant solution, and it has caused quite a few problems (*cough* Valve *cough*). The goal NVIDIA has is to eliminate this extended development effort via their compiler technology.

Obviously, if NVIDIA starts "optimizing" their compiler to the point where their hardware is doing things not intended by the developer, we have a problem. I think its very necessary to keep an eye on this, but its helpful to remember that such things are not advantageous to NVIDIA. Over at Beyond3d, there is a comparison of the different compiler (DX9 HLSL and NV Cg) options for NVIDIAs shaders.

We didn't have time to delve into comparisons with the reference rasterizer for this article, but our visual inspections confirm Beyond3d's findings. Since going from the game code to the screen is what this is all about, as long as image quality remains pristine, we think using the Cg compiler makes perfect sense. It is important to know that the Cg compiler doesn't improve performance (except for a marginal gain while using AA), and does a lot over the 45.xx dets for image quality.

Tomb Raider: Angel of Darkness Back to the game...
Comments Locked

117 Comments

View All Comments

  • Anonymous User - Tuesday, October 7, 2003 - link

    yea I agree with what #3 said..hardly any commentary on the IQ... and If I'm not mistaken, aren't the new cats going to be out tomorrow???? If so, you might as well do the whole thing over again...
  • Anonymous User - Tuesday, October 7, 2003 - link

    #3, go away you fanboy. There was absolutely no IQ difference between the CAT 3.7 and 52.14 drivers.
  • Anonymous User - Tuesday, October 7, 2003 - link

    i'm sure intel will be happy to hear that you 'upgraded' your prescott to an FX.
  • dvinnen - Tuesday, October 7, 2003 - link

    errr, a lot of the piture links aren't wrking, like teh halo iq one and TR:AoD
  • Anonymous User - Tuesday, October 7, 2003 - link

    Um...

    Why was there nothing noting the difference between nVidia and ATI's in the IQ section? nVidia looks absolutely horrid compared to the ATI.
  • AgaBooga - Tuesday, October 7, 2003 - link

    I saw more opinions in this article leaning towards Nvidia, especially around the Tomb Raider benchmarks. More specifically, starting with the page regarding compilers. I liked this articles, but there could have been less opinionated viewpoints on this. Also, it might be better if we get names of authors with what they typed, so we know who typed what, because some of this sure didn't sound like something Mr. Shimpi has written in the past...
  • Anonymous User - Tuesday, October 7, 2003 - link

    i'm still reading..............

Log in

Don't have an account? Sign up now