Newsgroups: comp.graphics.rendering.raytracing
From: Jon Harrop <use...@jdh30.plus.com>
Date: Tue, 10 May 2005 04:33:46 +0100
Local: Tues 10 May 2005 04:33
Subject: Re: Mini ray tracer
tbp wrote: My post is more about clarity and less about performance. Your proposed > Matt Pharr wrote: >> > [demonstration that "inline" vector math makes C++ programs faster >> > elided] > You've missed the point. alterations make the C++ implementation significantly longer and more obfuscated and your littering of the source code with "inline" actually slows the program down on my Athlon t-bird. Moreover, your choices of initial optimisation are decidedly suboptimal. I'd 1. Terminating the intersection of shadow rays when the first intersection 2. Use an implicit scene, to avoid storing it explicitly. 3. Use single-precision storage (or no storage at all). Both of these optimisations will give much bigger performance improvements As it happens, I had already implemented all of your optimisations and all > a) he's telling the OCaml compiler to inline everything it can while Both ocamlopt and g++ were allowed to inline code. > not giving its c++ counterpart opportunities to do so; fairness? As OCaml is for symbolic use, it performs no inlining by default (unlike > b) more importantly he's passing large structures by _value_ and i've Both implementations use pass by value as this is clearer, shorter and (as a > turned them into _references_. consequence) more common in real code. > In fact if you do the same for other hotpath functions as in: If you want a fair comparison then you should also make equivalent changes > ... > then the c++ version becomes 50% faster than originally to the OCaml implementation. > (and in fact, unconditionally faster than the OCaml version), You are trying to compare optimised C++ against unoptimised OCaml, which would be unfair. More worryingly, you seem to have skipped the part of the experiment where you actually measure something. > without adding a single line. When restricted to 80 columns, your optimisations add several lines. Indeed, they push the C++ program over 100 LOC limit imposed by the creators of the shootout. In fact, I'd already implemented your optimisations (and many more effective > You'll notice i haven't even fixed the gratitious use of virtual What would you recommend instead? > functions, I chose an inheritance hierarchy because this is the closest C++ equivalent Another optimisation that I made was to replace inheritance with a single > and other details Can you elaborate on these other "details"? > that force standard compliant c++ Manually implementing pass constant by reference is both obfuscating and > compilers to pessimize a lot when facing such... hmm.. source. error-prone whilst being theoretically unnecessary. The fact that the OCaml compiler does this optimisation for you when the GNU C++ compiler does not might interest some people. > I'm sure OCaml is a wonderful & expressive language, but crafting such Everyone will be free to contribute to the shootout version of the ray > a fishy c++ equivalent to make it shine (because you have an agenda) is > a despicable practice. tracer. Perhaps you would like to contribute a less "fishy" C++ implementation? -- You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||