Nvidia, Floating Point Blending and 'Errors'

Discussion in 'Architecture and Products' started by pocketmoon66, Jun 30, 2004.

  1. Xmas

    Xmas Porous
    Veteran Subscriber

    Joined:
    Feb 6, 2002
    Messages:
    3,344
    Likes Received:
    176
    Location:
    On the path to wisdom
    I don't see why you should use MAX_FLOAT instead of INF. At least if INF * 0 = 0.
    I agree with darkblu on that point.
     
  2. radar1200gs

    Regular

    Joined:
    Nov 30, 2002
    Messages:
    900
    Likes Received:
    0
    Lots of standards ar old standards. That does not make them any less useful though.

    Microsoft wants IEEE compliance for GPU's (if nothing else it helps system wide hardware abstraction by ensuring all processors use a common, widely accepted format).

    As for division by zero, anyone who has done any programming at all knows very well that this is something that simply should not be done in the first instance.
     
  3. dominikbehr

    Newcomer

    Joined:
    Apr 19, 2002
    Messages:
    72
    Likes Received:
    0
    Location:
    Sunnyvale, CA
    this should be some help
    http://msdn.microsoft.com/library/d...ore98/HTML/_crt__control87.2c_._controlfp.asp
     
  4. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Anyone who has done any real programming knows what a pain in the ass it is to take care of this special case every time you perform a division. The only problem is that division by zero is undefined in the science of math. That however doesn't mean we can't define it to something useful in programming tasks, rather than spending cycles having to take care of a rare special case.
     
  5. ERP

    ERP
    Veteran

    Joined:
    Feb 11, 2002
    Messages:
    3,669
    Likes Received:
    49
    Location:
    Redmond, WA
    We did this later in development after we discovered that we could.
     
  6. nutball

    Veteran Subscriber

    Joined:
    Jan 10, 2003
    Messages:
    2,492
    Likes Received:
    979
    Location:
    en.gb.uk
    One mans general case is another mans special case.

    Some of the compilers I've worked with have had quite sophisticated support for dealing with FP exceptions, configurable behaviour for value replacement when FP ops generate Inf/NaN, etc, or have flags to auto-detect division-by-zero, etc.
     
  7. pocketmoon66

    Newcomer

    Joined:
    Mar 31, 2004
    Messages:
    163
    Likes Received:
    9

    Humus flying his flag ;)

    In 'real' programming can you imagine how hard it would be to debug an application if it didn't trap fp exceptions such as div0 but rather just set the result to 'something useful' ?
     
  8. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,563
    Likes Received:
    171
    Location:
    In the Island of Sodor, where the steam trains lie
    But Humus, what if HW vendor X's decision on what to do with division by zero is not one you want? AFAICS it's up to the programmer to put in the handling that they want. Personally I think the IEEE behaviour is fairly sensible in this respect. I'm not that keen on its denormalised numbers but that's a different issue.
     
  9. Drak

    Newcomer

    Joined:
    May 16, 2004
    Messages:
    71
    Likes Received:
    0
    If you don't want to deal with division by zeros, you can condition your division by adding epsilon to your divisor. If you do want to deal with them, you can let the Infs/NaNs propagate and trace them back.

    It would be nice if we had fast functions to set NaNs/Infs in the framebuffer/rendertextures to some specified value such a 0.
     
  10. Rasmoo

    Newcomer

    Joined:
    Feb 6, 2002
    Messages:
    42
    Likes Received:
    1
    Yikes! It begins to sound worse than handling the special cases.

    Wouldn't it be much better to have some sort of cheap exception handling rather than polluting your code?
     
  11. nutball

    Veteran Subscriber

    Joined:
    Jan 10, 2003
    Messages:
    2,492
    Likes Received:
    979
    Location:
    en.gb.uk
    This works fine until you try this with a denominator that happens to be -epsilon.
     
  12. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,563
    Likes Received:
    171
    Location:
    In the Island of Sodor, where the steam trains lie
    But in terms of graphics algorithms, where are you going to have division by zero?

    Projection? That's handled by doing clipping against the frustum and is generally hardwired in so is a non-issue.

    Lighting calcs where the light gets too close? Since that's computing a distance, the value will always be positive and so the epsilon trick should be ok. (In fact, it's probably necessary for realistic modelling since you wouldn't have an infinitely bright light anyway... it would have set fire to the material :) )

    Vector normalisation where the vector is zero? Same sort of situation.

    I think that, in general, it should be ok.
     
  13. pocketmoon66

    Newcomer

    Joined:
    Mar 31, 2004
    Messages:
    163
    Likes Received:
    9
    Wel the NV devs were talking about HDR at the time...
     
  14. Drak

    Newcomer

    Joined:
    May 16, 2004
    Messages:
    71
    Likes Received:
    0
    I have to admit that I don't usually deal with negative denominators when I'm normalising. Anyway, if that's your cup of tea, take the sign off your denominator, then multiply the end result of the division by the sign.
     
  15. Drak

    Newcomer

    Joined:
    May 16, 2004
    Messages:
    71
    Likes Received:
    0
    Even dividing by very small fractions may result in huge numbers that may not be very useful depending on what you're computing/modelling.
     
  16. nutball

    Veteran Subscriber

    Joined:
    Jan 10, 2003
    Messages:
    2,492
    Likes Received:
    979
    Location:
    en.gb.uk
    Who said anything about normalising?
     
  17. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,563
    Likes Received:
    171
    Location:
    In the Island of Sodor, where the steam trains lie
    Oh I agree completely. I certainly made sure Elan/Naomi2 had lighting parameters that could guard against nasty cases.
     
  18. Drak

    Newcomer

    Joined:
    May 16, 2004
    Messages:
    71
    Likes Received:
    0
    I was sharing my personal experience. I usually have to deal with divide by zero when I'm normalising/rescaling. :lol:

    Dividing by negative numbers with the epsilon trick is not a biggie. :lol:
     
  19. Drak

    Newcomer

    Joined:
    May 16, 2004
    Messages:
    71
    Likes Received:
    0
    Ooops. Double post.
     
  20. suicuique

    Newcomer

    Joined:
    Mar 16, 2004
    Messages:
    30
    Likes Received:
    0
    The division by zero is not a "problem" per se in maths.
    That it is undefined is a requirement, not an annoyance,

    If you want it to be defined you are begging for *real* problems, as you are throwing the consistency of simple arithmetics out of the window.

    If you are dividing by zero you already got your problem. Just setting the result to your liking wont help you there.

    Say you set something like real/0 = +-MaxNum (with respect to the signs of real and 0).

    How do you trace such an "error"?
    What about scientific computing on the GPUs?

    IMHO it would be of grave error to throw exception handling of Div/0 out of the window, just because it seems convenient.

    regards, alex
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...