In a compute pipeline of OpenCL mode (LowerInputs::open_cl_mode, set
from ComputePipelineDescriptor::open_cl_mode_enabled) Metal honors the
rounding Apple's OpenCL compiler spells after a conversion's types.
Measured over OpenCL C of our own, one work-item per operand, probe jobs
m3-max-15651 (Radeon Pro 5300M) and m3-max-15652 (UHD Graphics 630),
macOS 26.7.1: both round an integer of 8 to 64 bits to float by rtz,
rtp and rtn, and a float to an integer of 8 to 64 bits by rte, rtp and
rtn (then saturate), exactly; neither creates an OpenCL-mode pipeline
for a conversion with a half side. Outside OpenCL mode the Macs answer
most of these as the plain conversion (docs/API.md), so honoring there
would leave every Mac's answer: the translator keeps the plain
conversion outside OpenCL mode.
The device has no directed conversion, so each is built exactly:
- float to integer: RoundEven, Ceil or Floor before the existing
clamp-and-truncate (the NaN test still reads the operand);
- integer to f32 by rtz/rtp/rtn: the device's conversion (correctly
rounded in a direction of its own), converted back exactly and
compared with the integer (2^k told by a float compare), then moved
one unit in the last place in the bits where it lies on the wrong side.
Both on native integers and on the wide pairs (no shaderInt64).
`arith::honored` decides per form; a half side, rte to float and rtz to
an integer stay the plain conversion.
SEMANTICS_VERSION 2030: an OpenCL-mode module holding such a conversion
changes. The function compile key already appends open_cl_mode; its
coverage test now asserts it.
Tests:
- arith/tests/convert_suffix.rs and wide.rs: every directed rounding of
i16/i32/i64 (and wide i40/i64) to f32, signed and unsigned, and every
integral rounding of f32 to 8..64-bit integers (both NaN tests), on
the interpreter against exact references, around 2^24, 2^25, 2^31,
2^32, 2^63, 2^64 and ties; the brief's oracle words; selection per
mode (only_a_pipeline_of_opencl_mode_honors_a_suffix).
- tests::engine_convert_rounding: each measured form, compiled in
OpenCL mode on lavapipe and moltenvk-m3 without shaderInt64, passes L3
and answers the 5300M's and the 630's words on the interpreter, and
the same kernel outside OpenCL mode answers the plain conversion.