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

    Wasn't Anand allowed to use ShaderMark v2.0 for det. the pixel shader performace?
  • Anonymous User - Tuesday, October 7, 2003 - link

    lol read this article take me a 1/2 hour. this article is great but it can be improved
  • Anonymous User - Tuesday, October 7, 2003 - link

    why anand didnt review bf1942 :(
  • Anonymous User - Tuesday, October 7, 2003 - link

    why is anand bashing Tomb raider
    and whats up with PS 2.0 graph
    why not just post the fps, makes it seem
    like nvidia is beating Ati. Also why are beta drivers being tested with nvidia. Should have used
    cat 3.8 for Radeon.
  • Anonymous User - Tuesday, October 7, 2003 - link

    im still waiting that a site post a review for an 9600 XT
  • Pete - Tuesday, October 7, 2003 - link

    Overall, a good read. Thanks, Derek and Anand.
  • Anonymous User - Tuesday, October 7, 2003 - link

    im not biased towards either card. i myself own a 9800pro. what concerns me is the immaturity shown by other ATI card owners. you guys act like nvidia can never measure up to ATI (which is so untrue). there was none/little difference in the IQ and benchmark results (with few exceptions, but explanations were given for the most part). also keep in mind that the 9800xt specs are higher than the 5900/5950 and it still managed to get beat in some of the tests. anyway, good job nvidia. you guys are certainly headed in the right direction. i was a bit sad to see my card excluded though :( ... they said they'll benchmark the value cards soon...i hope to see mine there ;)

    ps: i could be wrong about the specs, but i do remember anand saying the XT had higher memory bandwidth (which could've accounted for some performance differences).

    all in all, a good review, ill be waiting for more updates.
  • Anonymous User - Tuesday, October 7, 2003 - link

    18, he says he saw it saw it, he doesnt know why it was there, there is no reason to exclude regular fps graphs, especially since people want to know the fps of this game, since it is the ONLY truly dx9 game in the entire suite
  • Anonymous User - Tuesday, October 7, 2003 - link

    Hey Anand did nvidias check arrive yet
  • Anonymous User - Tuesday, October 7, 2003 - link

    Haha, yet again, we see fanATIcs (#10, #14) coming out of the woodworks to claim that Anandtech's review is either biased or NVIDIA is still cheating. lmao, losers!

    And by the way #14, you're plain dumb if you couldn't figure out that the TR:AOD graphs were showing a percentage difference. Christ, read the review.

Log in

Don't have an account? Sign up now