POV-Ray : Newsgroups : povray.beta-test : master branch issue 29 linux compilation errors : Re: master branch issue 29 linux compilation errors Server Time
15 May 2024 05:51:26 EDT (-0400)
  Re: master branch issue 29 linux compilation errors  
From: Thorsten Froehlich
Date: 6 Jul 2014 08:00:01
Message: <web.53b939edf234d99f95bf23070@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 02.07.2014 18:44, schrieb Le_Forgeron:
>
> > Rendering benchmark gives the attached pictures (the icpc seems ok,
> > within usual time, but gcc is bogus and too fast, far too fast)
>
> I finally found out what's going on here.
>
> The implementation of adaptive area lights uses an N*M cache for
> "lightlet" data it has already computed. Previously, yet-uncomputed data
> was flagged by setting the respective colour's red channel to -1. I had
> changed this to use a NaN ("Not-a-Number") value instead, to avoid
> problems when a user deliberately sets a light source's colour to
> negative red.
>
> Now of course this NaN value has to be tested for; according to IEEE
> standard, a NaN value has the property that it is non-equal to anything,
> even itself. So I wrote the test: "if (red != red)...".
>
> Well, it turns out that the g++ compiler optimizes this comparison away
> when in "-ffast_math" mode.

Use std::isnan - it works because IEEE 754 and C++ floats are not exactly the
same, and for most practical purposes NaNs will have a valid and identical
storage in memory. Be aware that NaNs and Infinites may raise exceptions
regardless though.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.