After 10.000001 articles in the floating-point series this may be the last one. A draft of “Exceptional Floating Point” has been posted at:
http://www.altdevblogaday.com/?p=25527&shareadraft=baba25527_4f8bc2320f5b0
It’s about the value that you can get from enabling a few types of floating-point exceptions in order to find bugs. And it comes with sample code. I haven’t prettified the code in the post, but I’ve attached a .zip file containing the sample code, and it is linked from the post as well.
Feedback? Experience with similar techniques? Typo reports (I intentionally left two (2) typos in the post to ensure that typo hunters will not be bored).
Maybe the more practical usage pattern these days is spot-enabling of FPU exceptions rather than global enable with spot-disable. The effectiveness of using them will vary a lot between products. I’ll be giving them a try this week on my current product in order to track down an errant NaN.
Good point about the SIMD instructions. I may have to mention that. Thanks.
-----Original Message-----
From: altdev...@googlegroups.com [mailto:altdev...@googlegroups.com]
On Behalf Of rskorski
Sent: Monday, April 16, 2012 7:38 PM
To: AltDevAuthors
Subject: Re: Final? floating-point article
FWIW, I just had need of floating-point exceptions today. I needed to track down an errant NaN that has been bugging me for weeks. I was able to spot enable them in just the particle system, spot disable them in one function that couldn’t handle them, and then start fixing bugs. A few of the bugs were probably not critical, but one was the source of the NaNs and I don’t know how I would have tracked it down otherwise, given that I was working on ancient code written by somebody else.
I just updated the post to include this last minute update.
From: altdev...@googlegroups.com [mailto:altdev...@googlegroups.com] On Behalf Of Jonathan Blow
Sent: Monday, April 16, 2012 7:43 AM
To: altdev...@googlegroups.com
Subject: Re: Final? floating-point article
I used to be big on fp exceptions but they are very hard to use because of everyone else's shitty code. As you allude to in the article, D3D can't handle having them enabled; I've also had Windows mysteriously bluescreen pretty often (that was back in the 2004 timeframe, dunno about now).
Wait, I’m confused. First of all, whose paragraph is that second one?
Second of all, it seems to contradict itself:
If you load SNAN, and you have exceptions turned on, then the fld instruction does not alter the FP stack.
If you load SNAN and you have exceptions turned on, doesn’t that trigger an exception, thus crashing the program?
So the rest of the code keeps on trucking
That’s the part that confuses me. Shouldn’t it have crashed?
It’s easy enough to write test code to verify this, but given the move away from x87 I don’t think I will.
Why didn't you get a linker error for a missing symbol?
What missing symbol?
From: altdev...@googlegroups.com [mailto:altdev...@googlegroups.com] On Behalf Of Rich Skorski
Sent: Sunday, April 29, 2012 12:06 PM
To: altdev...@googlegroups.com
Subject: Re: Final? floating-point article
That is nasty. How could the calling code not realize it? Why didn't you get a linker error for a missing symbol? Do I smell another FP post?
Oh wait – I thought you were top-posting (top paragraph replying to the second one), but you’re not. Unfortunately I can’t be certain what message you are replying to. I guess it’s my last one, but I’m not sure which part goes with which.
From: Bruce Dawson [mailto:bruce...@cygnus-software.com]
Sent: Sunday, April 29, 2012 3:23 PM
To: 'altdev...@googlegroups.com'
Subject: RE: Final? floating-point article
Wait, I’m confused. First of all, whose paragraph is that second one?
Second of all, it seems to contradict itself:
If you load SNAN, and you have exceptions turned on, then the fld instruction does not alter the FP stack.
If you load SNAN and you have exceptions turned on, doesn’t that trigger an exception, thus crashing the program?
So the rest of the code keeps on trucking
That’s the part that confuses me. Shouldn’t it have crashed?
It’s easy enough to write test code to verify this, but given the move away from x87 I don’t think I will.
Why didn't you get a linker error for a missing symbol?
What missing symbol?
From: altdev...@googlegroups.com [mailto:altdev...@googlegroups.com] On Behalf Of Rich Skorski
Sent: Sunday, April 29, 2012 12:06 PM
To: altdev...@googlegroups.com
Subject: Re: Final? floating-point article
That is nasty. How could the calling code not realize it? Why didn't you get a linker error for a missing symbol? Do I smell another FP post?