Translator: OpenCL mode clamps an integer conversion with .sat
In a compute pipeline of OpenCL mode both measured oracles clamp an integer converted to an integer with .sat to the destination's range (probe jobs m3-max-15651 on a Radeon Pro 5300M and m3-max-15652 on a UHD Graphics 630, macOS 26.7.1, OpenCL C of our own, one work-item per operand): int and uint to char, uchar, short, ushort, int and uint; long and ulong to int and uint; ulong to long, long to ulong, int to ulong; char to uint, uchar to int; and convert_uchar_sat_rte(int). The translator wrapped (convert_uchar_sat(300) was 44 where both answer 255). Outside OpenCL mode it still wraps, as the 5300M and the 630 answer there (docs/API.md). ConvertKind::Int carries the destination's signedness where `.sat` is honored (arith::honored); the conversion first clamps the held source to the destination's range (math::saturation_bounds: a bound the source's own range keeps is skipped), by the source's signedness, on native integers and on the wide pairs, then converts as before. Tests: every source of 8..64 bits (signed and unsigned) into every destination of 8..64 bits (signed and unsigned) around each width's bounds, native (convert_suffix.rs) and wide (wide.rs), on the interpreter against exact references; the measured int-to-int forms join tests::engine_convert_rounding's table (OpenCL mode answers both oracles' words, outside it the wrapped plain answer).
This commit is contained in:
1 parent
9e6a8b8a96
commit
e8ce0d2186
8 files changed
+467
-25
No files matched your search
+1
-2
@@ -4996,12 +4996,11 @@ each item named states the rule in full.
|
||||
|---|---|---|---|
|
||||
| integer of 8 to 64 bits to `float`, `.rtz`, `.rtp`, `.rtn` | rounded as named | rounded as named | rounded as named |
|
||||
| `float` to an integer of 8 to 64 bits, `.rte`, `.rtp`, `.rtn` | rounded as named, then clamped where `.sat` | as the 5300M, but a `uint` of 2^31 or more is `0x7fffffff` and a `uchar` with `.sat` above 127 is 127 | rounded as named, then saturated (the 5300M's answer) |
|
||||
| integer to integer, `.sat` | clamped to the destination's range | clamped to the destination's range | clamped to the destination's range |
|
||||
| a `half` side, any suffix | no pipeline | no pipeline | the conversion its types name |
|
||||
|
||||
An integer to `float` by `.rte`, a `float` to an integer by `.rtz`, and an integer to an integer
|
||||
with a rounding and no `.sat` are the conversion their types name on both, as on the runtime.
|
||||
Both clamp an integer to an integer with `.sat` to the destination's range, where the runtime
|
||||
wraps.
|
||||
Neither creates a pipeline of OpenCL mode for a conversion with a `half` side (its library
|
||||
compiles), so no Metal answer exists for one, and the runtime makes the pipeline. The device has
|
||||
no directed conversion (Vulkan's integer-to-float conversion rounds in a direction of its own,
|
||||
|
||||
Reference in new issue
Block a user