Files
metal2vulkan/crates
Anees Iqbal 2695dca124 Tests: Metal's half simdgroup sums and products are trees of rounded half operations (red)
Metal's simd_sum and simd_product of half operands combine the lanes as a tree. In round d
(1, 2, 4, 8, 16), each aligned block of 2d lanes holds its two halves' results combined and
rounded to half, and a lane that takes no part counts as the identity. Measured on an M3 Max
(macOS 27.0.1, our own MSL, fast math on and off alike):
- sums: potluck job m3-max-80839;
- products: m3-max-80879;
- sums and products over three masks of active lanes: m3-max-80890.
The tree matches every answer. The float result rounded once misses five of the eight sums,
four of the eight products and ten of the 48 masked results. The tree over the active lanes
packed together misses three masked sums.

metal2vulkan-devtools' half_simd_reductions holds two kernels of our own AIR, the operands and
Metal's answers:
- half_simd_reductions: eight simdgroups summing and multiplying their lanes in a uniform block;
- half_simd_reductions_masked: the same in blocks only a mask of lanes executes.

Three tests run them:
- engine_simd: the Direct tier at 32 lanes and the Cluster32 tier at 64, on the CPU
  interpreter. Red: those tiers fold the f32-held values with OpGroupNonUniformFAdd or FMul
  and round once.
- engine_simd_emulated: the emulated tier's pairwise tree at every width, on lavapipe's and
  the floor's profiles. Its rounded combine is Metal's tree, so this test is expected green.
- the runtime's half_simd_reductions: under a device cfg, every device of the cfg's kind. It
  prints the kernel subgroup sizes and each pipeline's precision notes.

Verified: none of these tests has run yet; their jobs follow. cargo fmt only on this host.
2026-12-02 22:40:48 -08:00
..