Skip to content

Commit

Permalink
clarify the required accuracy for OpFMod and OpFRem
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbaug committed Jan 16, 2023
1 parent 9474eb9 commit ed97470
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions OpenCL_Env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ include::config/opencl.asciidoc[]
// Formatting and links for API functions and enums.
include::env/dictionary.asciidoc[]

// External Footnotes
include::env/footnotes.asciidoc[]

<<<

include::copyrights.txt[]

<<<
Expand Down
16 changes: 16 additions & 0 deletions env/footnotes.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2023 The Khronos Group. This work is licensed under a
// Creative Commons Attribution 4.0 International License; see
// http://creativecommons.org/licenses/by/4.0/

// Please keep footnotes in alphabetical order!

// Note: Follows the suggested syntax from:
// https://github.com/asciidoctor/asciidoctor-pdf/issues/1397

:fn-opfrem-opfmod: pass:n[ \
The *OpFRem* and *OpFMod* instructions use cheap approximations of remainder, and the error can be large due to the discontinuity in *trunc*() and *floor*(). This can produce mathematically unexpected results in some cases, such as *OpFMod*(x,x) computing x rather than 0, and can also cause the result to have a different sign than the infinitely precise result. \
]

:fn-type-min: pass:n[ \
Here `TYPE_MIN` and `TYPE_MIN_EXP` should be substituted by constants appropriate to the floating-point type under consideration, such as `FLT_MIN` and `FLT_MIN_EXP` for float. \
]
14 changes: 11 additions & 3 deletions env/numerical_compliance.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ devices given as ULP values.
| \<= 2.5 ulp
| Correctly rounded

| *OpFRem*(x, y)
| Derived from x - y * *trunc*(x/y) footnote:opfrem-opfmod[{fn-opfrem-opfmod}]
| Derived from x - y * *trunc*(x/y) footnote:opfrem-opfmod[]
| Derived from x - y * *trunc*(x/y) footnote:opfrem-opfmod[]

| *OpFMod*(x, y)
| Derived from x - y * *floor*(x/y) footnote:opfrem-opfmod[]
| Derived from x - y * *floor*(x/y) footnote:opfrem-opfmod[]
| Derived from x - y * *floor*(x/y) footnote:opfrem-opfmod[]

| *OpExtInst* *acos*
| \<= 4 ulp
| \<= 4 ulp
Expand Down Expand Up @@ -1782,6 +1792,4 @@ representable numbers in the range 0 < x < TYPE_MIN and -TYPE_MIN < x < -0.
They do not include {plusmn}0.
A non-zero number is said to be sub-normal before rounding if, after
normalization, its radix-2 exponent is less than (TYPE_MIN_EXP - 1).
footnote:[Here `TYPE_MIN` and `TYPE_MIN_EXP` should be substituted by
constants appropriate to the floating-point type under consideration, such
as `FLT_MIN` and `FLT_MIN_EXP` for float.]
footnote:[{fn-type-min}]

0 comments on commit ed97470

Please sign in to comment.