Repository navigation
shader: lower v_sin_f16 and v_cos_f16 in direct Compute DXIL - #3300
Open
legacy-code-archaeologist wants to merge 1 commit into
Open
legacy-code-archaeologist wants to merge 1 commit into
legacy-code-archaeologist wants to merge 1 commit into
Conversation
Adds v_sin_f16 and v_cos_f16 to binary16_unary() and shares a DirectCompute::trig_turns() helper with v_sin_f32/v_cos_f32, rounding via packed_half_rne() while preserving D[31:16], -0.0 on v_sin_f16, exact quarter/half-turn zeros, and Inf/NaN -> 0x7e00. Fixes R0Y00#3298. Refs R0Y00#2935. AI-assisted.
Collaborator
|
I reviewed the diff (not run). Three notes:
AI-assisted. |
Collaborator
|
Thanks for the PR. I built it at 475a232 (clang-cl cross build, run under Wine, no GPU). The
This comment was AI-assisted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lowers VOP1 (
0x60/0x61), VOP3 (0x1e0/0x1e1), and SDWAv_sin_f16andv_cos_f16in the direct Compute DXIL path viabinary16_unary()and a sharedDirectCompute::trig_turns()helper.Fixes #3298. Refs #2935.
Changes
src/gfx1013_compute_native.cpp(binary16_unary()): Addv_sin_f16andv_cos_f16, enabling direct binary16 unary decode/SDWA subword handling,MODEchecking, and DPP form refusal.src/gfx1013_direct_compute.inl(trig_turns(),float_alu()):trig_turns(bool cosine, const string &a)shared byv_sin_f32/v_cos_f32andv_sin_f16/v_cos_f16: reduces in turns (part = a - trunc(a)with signed zero preserved) before converting to radians (* 2*pi), and forces exact+0.0at exact half/quarter turns (|part| == 0.5for sine;0.25and0.75for cosine).v_sin_f16/v_cos_f16throughtrig_turns()+packed_half_rne(), mapping±InfandNaN(|source| >= 0x7c00) to0x7e00, preserving-0.0(0x8000) onv_sin_f16, and keeping destinationD[31:16]unchanged on VOP1/VOP3 (or applying SDWAPRESERVE/PAD).tests/native_sin_cos_f16_check.py,tests/cmake/native_sin_cos_f16.cmake,docs/experiments/native-sin-cos-f16.md: Addir,controls, andhardwarechecks covering 34 cases (VOP1, VOP3abs/neg, SDWAWORD_0/WORD_1PRESERVE/PAD, inline float/int, literal, SGPR, VGPR overlap,±0,±0.25,±0.5,±0.75,-1.75,2048.0,65504.0,±Inf,qNaN,sNaN, subnormals, general angles) and 8 negative refusal cases.Verification
All tests ran on both
devandreleasepresets:ctest --preset dev --no-tests=error --output-on-failure -j 1 -V -R '^native_sin_cos_f16_':native_sin_cos_f16_ir: Passed (0.38s,34cases matched,8refusals verified)native_sin_cos_f16_controls: Passed (1.03s,34cases compiled to DXIL,8refusals verified)native_sin_cos_f16_hardware: Skipped (77) on localIntel(R) HD Graphics 530(driver=31.0.101.2111,requires shader model 6.6 with wave32; hardware execution unmeasured locally)ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^(native_f16_alu_|native_sdwa_f16_|native_direct_container$)':native_direct_container(23.64s),native_f16_alu_ir,native_sdwa_f16_ir, andnative_sdwa_f16_scalar_irPassed;3hardware tests Skipped (77).ctest --preset release --no-tests=error --output-on-failure -j 1 -R '^(native_sin_cos_f16_|native_f16_alu_|native_sdwa_f16_|native_direct_container$)':6non-hardware tests Passed (45.85s),4hardware tests Skipped (77).python -B tests/docs_links_check.py: Passed (146Markdown files,665links).dev(native_sin_cos_f16_ir):cos/sinDXIL opcodes (12/13): killed atsin_pos_zero/cos_pos_zero/sin_qtr_pos(0xabcd3c00 != 0x0)trig_turns(): killed atcos_qtr_pos,cos_qtr_neg,sin_half_pos,sin_half_neg(0xabcd8001 != 0x0)-0.0preservation onv_sin_f16: killed atsin_neg_zero(0xabcd0000 != 0x8000)(
src/gfx1013_direct_compute.inlrestored cleanly andnative_sin_cos_f16_irre-passed.)AI-assisted.