PrecisionNote::NativeHalfQuantize: a zero may round to the other zero
What: the note's text (its doc comment and the docs/API.md catalogue)
says what may differ: where a half rounding's input is a zero or too
small for a normal half, the result may be either zero, so a negative
zero may come out positive; and what a program sees of it: a
reciprocal's or atan2's sign, the bits written to a half target or
buffer. The catalogue names the form not taken (copying the input's
sign bit into the result by integer operations, about 4 instructions
per half rounding on every device without shaderFloat16) and its cost.
No code changes; the planner ruled the note (11-21).
Why: the 11-21 round at ce998742d7 read the RX 550 (RADV, Polaris)
answering +0 for a -0 float attribute rounded to a half parameter
(vertex-format cases), where Metal answers -0. The SPIR-V specification
defines OpQuantizeToF16 so: "If the magnitude of Value is too small to
represent as a normalized 16-bit floating-point value, the result must
be either +0 or -0." A zero's magnitude is in that range. So the answer
is the quantize's own, documented, and rule 1 gives it a static note.
The note already covered a denormal rounding to a zero of either sign,
but its text did not name a zero's own sign. SignedZeroInfNanPreserve
is not the fix: it only restrains optimizations ("does not perform
optimizations on floating-point instructions that do not preserve sign
of a zero") and does not narrow what the instruction may answer.
How verified: a text change only. The RX 550's vertex-format rows go to
the ledger under native-half-quantize with the per-card rows.
This commit is contained in:
1 parent
0bb8804321
commit
895b3f845a
2 files changed
+14
-4
No files matched your search
+7
-1
@@ -2434,7 +2434,13 @@ bound.
|
||||
`half` operation's, a function's, a conversion from `float`'s, a texel's) by the device's
|
||||
`OpQuantizeToF16` alone, on every device without `shaderFloat16`, its quantize measured or not: a
|
||||
value below the smallest normal `half` may round to a zero where Metal answers the half denormal
|
||||
(or `2^-14`, from just below it). An integer's `half` rounds exactly instead.
|
||||
(or `2^-14`, from just below it). Where the rounding's input is a zero or too small for a normal
|
||||
`half`, the result may be either zero, so a negative zero may come out positive, as the SPIR-V
|
||||
specification lets the quantize answer: a program sees it in a reciprocal's or `atan2`'s sign
|
||||
and in the bits written to a `half` target or buffer. The form not taken, copying the input's
|
||||
sign bit into the result by integer operations, would keep Metal's sign at about 4 instructions
|
||||
per `half` rounding on every device without `shaderFloat16`. An integer's `half` rounds exactly
|
||||
instead.
|
||||
- `metal2vulkan-degrade-native-nan-encoding` (precision). `PrecisionNote::NativeNanEncoding`: Native
|
||||
device maths: a `float` or `half` operation's NaN result is the device's, its sign and payload
|
||||
unselected, where Metal answers a NaN, on every device: a `float`
|
||||
|
||||
Reference in new issue
Block a user