Skip to content

Remove isNormal()? #2309

Closed
Closed

Description

@litherum

In #2270, we resolved to remove isInf() and isNan() because they return bogus information in many (all?) situations.

It seems like isNormal will also return bogus information in many (all?) situations. We should determine if we should apply that resolution to isNormal() too.

Activity

  1. added
    wgsl
    on Nov 16, 2021
  2. added this to the V1.0 milestone on Nov 16, 2021
  3. dneto0 commented on Nov 16, 2021

    @dneto0
    Contributor

    isNormal is a non-trivial testable function, even with fast math variations.

    Normal numbers are any floating point number which is:

    • not infinity
    • not NaN
    • Not zero
    • Not subnormal.

    Another way to write it is that the exponent is neither the largest nor smallest exponent for the format.

    I've written a draft CTS test for it

    An implementation that cuts the most permissible corners can:

    • assume NaNs or infinities don't occur
    • can flush denormals to zero, but only on certain operations

    § 12.5 Floating Point Evaluation says:

    Implementations may flush denormalized value on the input and/or output of any operation listed in § 12.5.1 Floating Point Accuracy.

    • Other operations are required to preserve denormalized numbers.

    As @alan-baker says, this is a distillation of common functionality in underlying platforms.

    Altogether, I think isNormal should stay.

  4. dneto0 commented on Nov 16, 2021

    @dneto0
    Contributor

    WGSL also has isFinite. That could be removed, by the same argument as removing isNan or isInfinite. #2270

    That is, an implementation that cuts as many corners as possible (assumes no infinities and Nans) can reduce it to just returning "true".


    edit: That last word should be "true". Thanks @alan-baker

  5. alan-baker commented on Nov 16, 2021

    @alan-baker
    Contributor

    WGSL also has isFinite. That could be removed, by the same argument as removing isNan or isInfinite. #2270

    That is, an implementation that cuts as many corners as possible (assumes no infinities and Nans) can reduce it to just returning "false".

    True you mean.

  6. dneto0 commented on Nov 18, 2021

    @dneto0
    Contributor

    Reviewing support:

    Language isFinite isInfinite isNan isNormal
    HLSL Y Y Y N
    MSL Y Y Y Y
    GLSL N Y Y N
    SPIR-V (in Kernel, not Shader) Y Y (in Kernel, not Shader)
    DXIL Y Y Y Y

    Looking at this table, isNormal does not seem critical. It would probably be weird / not very useful to have only isNormal and none of the other three.

  7. added a commit that references this issue on Nov 18, 2021
    d8da820
  8. added a commit that references this issue on Nov 19, 2021
    652f6a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgsl

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions