Skip to content

Add floating point execution rules - #1743

Merged
dneto0 merged 3 commits into
gpuweb:mainfrom
alan-baker:floating-point-accuracy
May 27, 2021
Merged

dneto0 merged 3 commits into
gpuweb:mainfrom
alan-baker:floating-point-accuracy

Conversation

@alan-baker

Copy link
Copy Markdown
Contributor

Fixes #1716

  • Describes deviations from IEEE 754
  • Adds tables defining accuracy of operations

Fixes gpuweb#1716

* Describes deviations from IEEE 754
* Adds tables defining accuracy of operations
@alan-baker alan-baker added the wgsl WebGPU Shading Language Issues label May 18, 2021
@alan-baker
alan-baker requested review from dneto0, kvark and litherum May 18, 2021 19:57

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.
Thanks for doing this. It's important work.

Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
* improve note about no nans or infinities
* changed units of least precision to units in the last place
* removed bullets about min/max of zeroes
* clarified reassociation
Comment thread wgsl/index.bs Outdated
The rounding mode is unspecified for [SHORTNAME].
If the result, `x`, is exactly representable in floating point, then `x` must be
returned.
Otherwise, a floating point value closest to `x`, either no less than `x`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the "either not less or no greater than". Does it have a specific meaning here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Right, that phrase seems to provide no value.

I checked the IEEE 754 wording and it's pretty straightforward. Mostly it deals with the different prescribed rounding modes, but WGSL doesn't specify rounding mode or a way to set it.
So I think this sentence can be simplified.

Otherwise, the result is a floating point value closest to x.

and maybe:

Note: When two floating point values are equally close to x, the result can be either.

Comment thread wgsl/index.bs
or no greater than `x` must be returned.

The units in the last place, <dfn noexport>ULP</dfn>, for a floating point
number `x` is the minimum distance between two non-equal floating point numbers

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The units ... is the minimum". Should this be singular "The unit"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Could be.

Comment thread wgsl/index.bs Outdated
<tr><td>`distance(x, y)`<td>Inherited from `length(x - y)`
<tr><td>`exp(x)`<td>3 + 2 * |x| ULP
<tr><td>`exp2(x)`<td>3 + 2 * |x| ULP
<tr><td class="nowrap">`faceForward(x, y, z)`<td>Inherited from `dot(z, y) < 0.0 ? x : -x`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we don't have ternary operators in WGSL

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there.

Comment thread wgsl/index.bs Outdated
The rounding mode is unspecified for [SHORTNAME].
If the result, `x`, is exactly representable in floating point, then `x` must be
returned.
Otherwise, a floating point value closest to `x`, either no less than `x`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Right, that phrase seems to provide no value.

I checked the IEEE 754 wording and it's pretty straightforward. Mostly it deals with the different prescribed rounding modes, but WGSL doesn't specify rounding mode or a way to set it.
So I think this sentence can be simplified.

Otherwise, the result is a floating point value closest to x.

and maybe:

Note: When two floating point values are equally close to x, the result can be either.

* Clarify returned value for correctly rounded
* Replace use of ternary operator with select builtin function
@dneto0
dneto0 merged commit 7578481 into gpuweb:main May 27, 2021
github-actions Bot added a commit that referenced this pull request May 27, 2021
SHA: 7578481
Reason: push, by @dneto0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request May 27, 2021
SHA: 7578481
Reason: push, by @dneto0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request May 27, 2021
SHA: 7578481
Reason: push, by @dneto0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@kdashg

kdashg commented Jun 1, 2021

Copy link
Copy Markdown
Contributor
WGSL meeting minutes 2021-05-25
  • (probably fine. One day for people to double-check)

@alan-baker
alan-baker deleted the floating-point-accuracy branch August 23, 2021 19:30
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
This PR adds beginComputePass.spec.ts file, then add
compute_pass_descriptor_location test in order to test
the validation of beginComputePass and its GPUComputePassDescriptor
as a parameter.

Issue: gpuweb#1743
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
* Add a query_set_type test to beginComputePass tests

This PR adds a `timestampWrites,query_set_type` test to
beginComputePass.spec.ts in order to check if a validation
error is generated when all query types are not timestamp.

Additionally, this PR adds tryComputePass utility method to
avoid using duplicated validation checks.

Issue: gpuweb#1743

* Add a query_index_count test to beginComputePass tests

This PR adds a timestampWrites,query_index_count test to
beginComputePass.spec.ts in order to check if a validation
error is generated when querySet.count is not greater than
timestampWrite.queryIndex.

Issue: gpuweb#1743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wgsl WebGPU Shading Language Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[proposal] Numerical compliance

4 participants