From e60bffbd92bb556788b9db1d2e062a50dc59cb5e Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Tue, 3 Nov 2026 01:04:06 -0800 Subject: [PATCH] Expect the precise division's NativeDivision on MoltenVK in native_maths The kernel's `a / b` is an `fdiv` without `arcp`, Metal's precise division, which since 4817f3bdfe is the device's `OpFDiv` on every device, with `PrecisionNote::NativeDivision` recorded everywhere (`lower::arith::float_binop_notes`). The test still expected no NativeDivision on MoltenVK. It now expects that note on every device and its announcement; the other kinds stay as they were. Verified: runtime_lane::native_maths::native_maths_answers_within_its_recorded_bounds passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu). (cherry picked from commit 3207d05c7a4981aed08240b3af95118af6925d66) (cherry picked from commit 56153d587b49b5a01ef6416d9db3b441a96ba346) --- .../src/runtime_lane/native_maths.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/native_maths.rs b/crates/metal2vulkan-validation/src/runtime_lane/native_maths.rs index afffe378f..7313792f9 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/native_maths.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/native_maths.rs @@ -336,10 +336,13 @@ fn to_half(x: f64) -> f64 { /// `NativeTranscendentals` (`fast::sqrt`), and `NativeMinMax` where the device is not measured to /// answer Metal's operand; and `NativeNanEncoding` wherever the device is not measured to answer /// Metal's canonical NaN (on one measured to, it records the note where the kernel computes another -/// of Metal's NaNs). The pipeline state announces each native kind of its stage once, and every -/// thread's answers are within the bounds their kinds record. On MoltenVK, whose functions and -/// minimum and maximum are Metal's own, the stage records none of their kinds and announces none. -/// The device announces `float-tininess-after-rounding` as it is made, exactly off MoltenVK. +/// of Metal's NaNs). The kernel's `a / b`, an `fdiv` without `arcp`, is Metal's precise division, +/// which is the device's `OpFDiv` on every device (`lower::arith::float_binop_notes`): its +/// `NativeDivision` is recorded on every device. The pipeline state announces each native kind of +/// its stage once, and every thread's answers are within the bounds their kinds record. On +/// MoltenVK, whose functions and minimum and maximum are Metal's own, the stage records none of +/// their kinds but the precise division's and announces that one alone. The device announces +/// `float-tininess-after-rounding` as it is made, exactly off MoltenVK. #[test] fn native_maths_answers_within_its_recorded_bounds() { let bitcode = llvm_assemble_text(&kernel()).unwrap(); @@ -374,7 +377,8 @@ fn answers_under(device: &Device, messages: &Messages, bitcode: &[u8]) { ); for (note, native) in [ (PrecisionNote::NativeTranscendentals, !metals), - (PrecisionNote::NativeDivision, !metals), + // The precise division (`a / b` without `arcp`) on every device. + (PrecisionNote::NativeDivision, true), (PrecisionNote::NativeDot, !metals), (PrecisionNote::NativeMix, !metals), (