Google Groups Home
Help | Sign in
Message from discussion Mini ray tracer
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
tbp  
View profile
 More options 9 May 2005, 23:51
Newsgroups: comp.graphics.rendering.raytracing
From: "tbp" <tbp...@gmail.com>
Date: 9 May 2005 15:51:11 -0700
Local: Mon 9 May 2005 23:51
Subject: Re: Mini ray tracer
Matt Pharr wrote:
> > [demonstration that "inline" vector math makes C++ programs faster
> > elided]

You've missed the point.
a) he's telling the OCaml compiler to inline everything it can while
not giving its c++ counterpart opportunities to do so; fairness?
b) more importantly he's passing large structures by _value_ and i've
turned them into _references_.

In fact if you do the same for other hotpath functions as in:
19c21
<   virtual void intersect(double &, Vec &, Ray) = 0;
---

>   virtual void intersect(double &, Vec &, const Ray &) = 0;

26c28
<   double ray_sphere(Ray ray) { // Intersection of a ray with a sphere
---
>   double ray_sphere(const Ray &ray) { // Intersection of a ray with a

sphere
35c37
<   void intersect(double &lambda, Vec &normal, Ray ray) {
---
>   void intersect(double &lambda, Vec &normal, const Ray &ray) {

50c52
<   void intersect(double &lambda, Vec &normal, Ray ray) {
---

>   void intersect(double &lambda, Vec &normal, const Ray &ray) {

then the c++ version becomes 50% faster than originally (and in fact,
unconditionally faster than the OCaml version), without adding a single
line.

You'll notice i haven't even fixed the gratitious use of virtual
functions, and other details that force standard compliant c++
compilers to pessimize a lot when facing such... hmm.. source.

I'm sure OCaml is a wonderful & expressive language, but crafting such
a fishy c++ equivalent to make it shine (because you have an agenda) is
a despicable practice.

> > If your point was to show how to write unbelievably inneficient
code in
> > C++, you've succeeded.

> I think the point was to have some fun and to make a little demo that
shows
> how a functional language like OCaml can give rise to nice short
expressive
> programs while still delivering competitive performance.  And for
those
> goals, the OP succeeded!

> Note also that he mentions on his web page that he's doing this for
"the
> computer language shootout benchmarks",

http://shootout.alioth.debian.org/.
> That page clearly points out all the caveats around benchmarks like
these
> (to the point that they can be effectively meaningless in  the real

world.)
I have nothing against such benchmarks when they are not clearly
rigged.

But i guess the main point of the whole operation wasn't fair
benchmarking, education, or fun but selling books: "This program has
demonstrated some of the ways that OCaml improves upon C++. For a
thorough introduction to OCaml, read our book "Objective CAML for
Scientists".

Or put another way, that's a sad PR stunt.

Have a nice day.


    Reply to author    Forward  
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.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google