# compile options, fast-math on gcc

**URL:** <https://discourse.radiance-online.org/t/compile-options-fast-math-on-gcc/3231>\
**Category:** radiance-general\
**Created:** [April 16, 2008, 9:12pm UTC](https://discourse.radiance-online.org/t/compile-options-fast-math-on-gcc/3231 "2008-04-16T21:12:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Grobe](https://discourse.radiance-online.org/user_avatar/discourse.radiance-online.org/lars_grobe/32/469_2.png) [@Lars\_Grobe](https://discourse.radiance-online.org/u/Lars_Grobe)\
**Post date:** [April 16, 2008, 9:12pm UTC](https://discourse.radiance-online.org/t/compile-options-fast-math-on-gcc/3231/1 "2008-04-16T21:12:14Z")

</div>

Hi,

as (according to Mark's benchmarks) more and more people start to use the fast-math switch when compiling using gcc, I want to share my experience that this option, while improving performance, may lead to the mysterious "zero ray direction in localhit" errors. I have experienced those a lot when using this kind of "optimization", which led me to many many restarts of interrupted renderings, and solved the problem using a new compile with more standard-friendly parameters.

Just a hint... CU Lars.

---

<div class="post-metadata">

**Author:** ![Mark\_Stock](https://discourse.radiance-online.org/user_avatar/discourse.radiance-online.org/mark_stock/32/1561_2.png) [@Mark\_Stock](https://discourse.radiance-online.org/u/Mark_Stock)\
**Post date:** [April 16, 2008, 9:17pm UTC](https://discourse.radiance-online.org/t/compile-options-fast-math-on-gcc/3231/2 "2008-04-16T21:17:58Z")

</div>

I am ashamed to admit that I just comment out line 516 in raytrace.c to avoid that error.

&nbsp;&nbsp;&nbsp;//error(CONSISTENCY, "zero ray direction in localhit");

But then, nobody questions the numerical accuracy of my lighting, so I feel somewhat free to experiment.

Mark

> **···**
>
> On Thu, 17 Apr 2008, Lars O. Grobe wrote:
> 
> > Hi,
> > 
> > as (according to Mark's benchmarks) more and more people start to use the fast-math switch when compiling using gcc, I want to share my experience that this option, while improving performance, may lead to the mysterious "zero ray direction in localhit" errors. I have experienced those a lot when using this kind of "optimization", which led me to many many restarts of interrupted renderings, and solved the problem using a new compile with more standard-friendly parameters.
> > 
> > Just a hint... CU Lars.

---

<div class="post-metadata">

**Author:** ![Daniel\_Reetz](https://discourse.radiance-online.org/letter_avatar_proxy/v4/letter/d/a88e57/32.png) [@Daniel\_Reetz](https://discourse.radiance-online.org/u/Daniel_Reetz)\
**Post date:** [April 16, 2008, 9:31pm UTC](https://discourse.radiance-online.org/t/compile-options-fast-math-on-gcc/3231/3 "2008-04-16T21:31:55Z")

</div>

This reminds me of one of my favorite hardware fixes. My laptop DAC  
makes a hideous buzzing sound when plugged into PA amps at electronic  
music venues. Of course, this is due to a ground-loop, but isolators  
don't totally eliminate the buzz.

The solution? Cut the ground plug off my AC adapter.

(Sorry for running off-topic... and thanks for the hint, Lars)  
DR

> **···**
>
> On Wed, Apr 16, 2008 at 4:17 PM, Mark Stock \<mstock@umich.edu\> wrote:
> 
> > I am ashamed to admit that I just comment out line 516 in raytrace.c to  
> > avoid that error.
> > 
> > &nbsp;&nbsp;//error(CONSISTENCY, "zero ray direction in localhit");
> > 
> > But then, nobody questions the numerical accuracy of my lighting, so I feel  
> > somewhat free to experiment.
> > 
> > Mark
> > 
> > On Thu, 17 Apr 2008, Lars O. Grobe wrote:
> > 
> > \> Hi,  
> > \>  
> > \> as (according to Mark's benchmarks) more and more people start to use the  
> > fast-math switch when compiling using gcc, I want to share my experience  
> > that this option, while improving performance, may lead to the mysterious  
> > "zero ray direction in localhit" errors. I have experienced those a lot when  
> > using this kind of "optimization", which led me to many many restarts of  
> > interrupted renderings, and solved the problem using a new compile with more  
> > standard-friendly parameters.  
> > \>  
> > \> Just a hint... CU Lars.  
> > \>  
> > \>
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Radiance-general mailing list  
> > Radiance-general@radiance-online.org  
> > [http://www.radiance-online.org/mailman/listinfo/radiance-general](http://www.radiance-online.org/mailman/listinfo/radiance-general)

---

<div class="post-metadata">

**Author:** ![Rob\_Guglielmetti2](https://discourse.radiance-online.org/user_avatar/discourse.radiance-online.org/rob_guglielmetti2/32/468_2.png) [@Rob\_Guglielmetti2](https://discourse.radiance-online.org/u/Rob_Guglielmetti2)\
**Post date:** [April 16, 2008, 9:33pm UTC](https://discourse.radiance-online.org/t/compile-options-fast-math-on-gcc/3231/4 "2008-04-16T21:33:47Z")

</div>

Mark Stock wrote:

> I am ashamed to admit that I just comment out line 516 in raytrace.c to avoid that error.
> 
> &nbsp;&nbsp;//error(CONSISTENCY, "zero ray direction in localhit");

Haha! Don't worry Mark, the Bush Administration is doing similar things to the Constitution.

-Rob

---

<div class="post-metadata">

**Author:** ![Axel\_Jacobs2](https://discourse.radiance-online.org/letter_avatar_proxy/v4/letter/a/46a35a/32.png) [@Axel\_Jacobs2](https://discourse.radiance-online.org/u/Axel_Jacobs2)\
**Post date:** [April 16, 2008, 10:35pm UTC](https://discourse.radiance-online.org/t/compile-options-fast-math-on-gcc/3231/5 "2008-04-16T22:35:24Z")

</div>

The newer versions of GCC actually do a pretty decent job with just  
the -O3 optimisation:  
[http://www.luxal.eu/resources/radiance/benchmark.shtml](http://www.luxal.eu/resources/radiance/benchmark.shtml)

While I have to honestly admit that I don't know the 'perfect' compile  
switches for my CPU (I borrowed them from Mark's benchmark page, from  
what appeared to be a processor similar to mine), the benchmark shows  
that setting too many exotic compiler options might actually decrease  
the speed a little.

Axel
