direct compute: first binary64 arithmetic slice (v_add_f64, v_mul_f64, v_fma_f64)? (scope question) #3518

Open
opened 2026-11-29 21:15:48 +00:00 by legacy-code-archaeologist · 2 comments
legacy-code-archaeologist commented 2026-11-29 21:15:48 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-29T21:15:48Z.


Part of #2935. A per-opcode probe of the VOP3 names in src/gfx1013_isa_tables.inl on main ff9dcef0 (the same probe as #2985) shows that the binary64 VALU family is the largest group the direct compute path still refuses with direct DXIL lowering for <name>:

  • v_add_f64, v_mul_f64, v_fma_f64, v_min_f64, v_max_f64, v_ldexp_f64;
  • the division helpers v_div_scale_f64, v_div_fmas_f64, v_div_fixup_f64, and v_trig_preop_f64.

The binary64 conversions are already in (#3367, #3369, #3371 by @R0D4X). They use pure 32-bit integer arithmetic and avoid both DoublePrecisionFloatShaderOps and Int64ShaderOps.

Question

Which approach would you accept for a first arithmetic slice? It would cover v_add_f64, v_mul_f64 and v_fma_f64 on VGPR/SGPR pairs, with no constants, literals, clamp, omod, DPP or SDWA.

  1. DXIL double operations. Use fadd double, fmul double and dx.op.tertiary.f64 Fma (opcode 47), with the double-precision shader flags set. Reading and writing the pairs uses MakeDouble/SplitDouble, so no i64 is needed. The hardware check would report a capability skip (77) on an adapter without double support. Three things would be stated as host assumptions and measured on a GPU:
    • correctly rounded results;
    • kept denormals;
    • NaN propagation by class only.
  2. Integer-only, like the conversions. This is an exact software binary64 add/mul/fma in 32-bit integer IR. It needs no capability and has no host rounding question, but it is a much larger lowering per op.

Both approaches would accept the ops only under the default MODE contract for the f16/f64 fields (round [3:2] RNE, denorm [7:6] keep). They reuse the existing half_binary MODE tracking, because gfx10 shares those fields between binary16 and binary64. Each case would get bit-exact readback references (signed zeros, denormal inputs and results, round-to-even ties, overflow, Inf/NaN) and fused-vs-unfused and flush mutants.

@R0D4X, if you are already working on binary64 arithmetic, please say so and I will stay out of it.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6684252541 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3518). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-29T21:15:48Z. --- Part of #2935. A per-opcode probe of the VOP3 names in `src/gfx1013_isa_tables.inl` on `main` `ff9dcef0` (the same probe as #2985) shows that the binary64 VALU family is the largest group the direct compute path still refuses with `direct DXIL lowering for <name>`: - `v_add_f64`, `v_mul_f64`, `v_fma_f64`, `v_min_f64`, `v_max_f64`, `v_ldexp_f64`; - the division helpers `v_div_scale_f64`, `v_div_fmas_f64`, `v_div_fixup_f64`, and `v_trig_preop_f64`. The binary64 conversions are already in (#3367, #3369, #3371 by @R0D4X). They use pure 32-bit integer arithmetic and avoid both DoublePrecisionFloatShaderOps and Int64ShaderOps. ### Question Which approach would you accept for a first arithmetic slice? It would cover `v_add_f64`, `v_mul_f64` and `v_fma_f64` on VGPR/SGPR pairs, with no constants, literals, clamp, omod, DPP or SDWA. 1. **DXIL double operations.** Use `fadd double`, `fmul double` and `dx.op.tertiary.f64` Fma (opcode 47), with the double-precision shader flags set. Reading and writing the pairs uses `MakeDouble`/`SplitDouble`, so no i64 is needed. The `hardware` check would report a capability skip (77) on an adapter without double support. Three things would be stated as host assumptions and measured on a GPU: - correctly rounded results; - kept denormals; - NaN propagation by class only. 2. **Integer-only, like the conversions.** This is an exact software binary64 add/mul/fma in 32-bit integer IR. It needs no capability and has no host rounding question, but it is a much larger lowering per op. Both approaches would accept the ops only under the default MODE contract for the f16/f64 fields (`round [3:2]` RNE, `denorm [7:6]` keep). They reuse the existing `half_binary` MODE tracking, because gfx10 shares those fields between binary16 and binary64. Each case would get bit-exact readback references (signed zeros, denormal inputs and results, round-to-even ties, overflow, Inf/NaN) and fused-vs-unfused and flush mutants. @R0D4X, if you are already working on binary64 arithmetic, please say so and I will stay out of it. AI-assisted.
KelboLive commented 2026-11-29 22:54:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-29T22:54:54Z.


Partial answer to the capability half of option 1, measured rather than assumed.

A minimal D3D12 program enumerated the hardware adapter and WARP, created a device at
D3D_FEATURE_LEVEL_11_0, and queried D3D12_FEATURE_D3D12_OPTIONS (the double flag) and
D3D12_FEATURE_D3D12_OPTIONS1 (int64 and wave ops). No shader involved.

adapter 0: NVIDIA GeForce RTX 4070 Ti SUPER
hw[0]    sm=0x60 double=yes int64=yes wave_ops=yes
warp: Microsoft Basic Render Driver
warp     sm=0x60 double=yes int64=yes wave_ops=yes
  • Windows 10.0.26100, in-box runtime, in-box WARP.
  • sm=0x60 is D3D_SHADER_MODEL_6_0, the highest this host reports.

So on this host option 1 needs no capability skip: both the GPU and WARP advertise
DoublePrecisionFloatShaderOps. If that holds generally, the capability skip you listed for the hardware
check would only fire on older adapters — worth knowing before the skip is written into the fixture as if
it were the common case.

Not measured here, and still the deciding part:

  • whether fadd double / fmul double / dx.op.tertiary.f64 actually return correctly rounded
    results, keep denormals and propagate NaN by class only on these two backends;
  • the same on the Agility WARP 1.0.22 (out/build/warp-agility), which is a different d3d10warp.dll
    and could disagree with the in-box one;
  • Int64ShaderOps is also yes on both, which weakens one argument for the integer-only route — but
    your existing conversions avoid both flags on purpose, so that is presumably a portability choice
    rather than a local limitation.

If the maintainers are leaning to option 1, I can extend this into the rounding/denormal/NaN measurement
for those three ops on hardware and both WARP builds. I have the host and the Agility tree set up, so that
would be a measurement-only change.

I am not starting on either implementation.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7264048272 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3518#issuecomment-7264048272). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-29T22:54:54Z. --- Partial answer to the capability half of option 1, measured rather than assumed. A minimal D3D12 program enumerated the hardware adapter and WARP, created a device at `D3D_FEATURE_LEVEL_11_0`, and queried `D3D12_FEATURE_D3D12_OPTIONS` (the double flag) and `D3D12_FEATURE_D3D12_OPTIONS1` (int64 and wave ops). No shader involved. ``` adapter 0: NVIDIA GeForce RTX 4070 Ti SUPER hw[0] sm=0x60 double=yes int64=yes wave_ops=yes warp: Microsoft Basic Render Driver warp sm=0x60 double=yes int64=yes wave_ops=yes ``` - Windows 10.0.26100, in-box runtime, in-box WARP. - `sm=0x60` is `D3D_SHADER_MODEL_6_0`, the highest this host reports. So on this host option 1 needs **no capability skip**: both the GPU and WARP advertise `DoublePrecisionFloatShaderOps`. If that holds generally, the capability skip you listed for the `hardware` check would only fire on older adapters — worth knowing before the skip is written into the fixture as if it were the common case. Not measured here, and still the deciding part: - whether `fadd double` / `fmul double` / `dx.op.tertiary.f64` actually return correctly rounded results, keep denormals and propagate NaN by class only on these two backends; - the same on the Agility WARP 1.0.22 (`out/build/warp-agility`), which is a different `d3d10warp.dll` and could disagree with the in-box one; - `Int64ShaderOps` is also `yes` on both, which weakens one argument for the integer-only route — but your existing conversions avoid both flags on purpose, so that is presumably a portability choice rather than a local limitation. If the maintainers are leaning to option 1, I can extend this into the rounding/denormal/NaN measurement for those three ops on hardware and both WARP builds. I have the host and the Agility tree set up, so that would be a measurement-only change. I am not starting on either implementation.
legacy-code-archaeologist commented 2026-11-29 23:34:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-29T23:34:24Z.


Thanks @KelboLive for the capability measurement. While this question is open, I put up the two binary64 ops that need neither approach: #3529 (v_ldexp_f64) and #3530 (v_min_f64/v_max_f64). Both use 32-bit integer operations only, like the conversions, and both have an ir mode checked bit for bit against exact references. v_add_f64/v_mul_f64/v_fma_f64 stay local until an approach is chosen here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7264562293 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3518#issuecomment-7264562293). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-29T23:34:24Z. --- Thanks @KelboLive for the capability measurement. While this question is open, I put up the two binary64 ops that need neither approach: #3529 (`v_ldexp_f64`) and #3530 (`v_min_f64`/`v_max_f64`). Both use 32-bit integer operations only, like the conversions, and both have an `ir` mode checked bit for bit against exact references. `v_add_f64`/`v_mul_f64`/`v_fma_f64` stay local until an approach is chosen here. AI-assisted.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#3518
No description provided.