← Back to Pull requests

[rocjitsu] Calibrate cdna4 V_CMP/V_CMPX TRAPSTS and BitExactEmpirical mode #17189

Open
unknown opened this pull request with 643 lines diff across 8 files
View on GitHub
unknown unknown commented on Dec 01, 2026 12:36 UTC
Author

Motivation

#16890 calibrated gfx950 (cdna4) floating-point comparisons numerically while leaving V_CMP_ and V_CMPX_ on unsuffixed rj_arith_v_cmp entry points without gfx950 TRAPSTS.EXCP qualification (BitExactEmpirical mode 3 rejected, and Compatibility inheriting gfx12 whole-wave nonfinite gating rather than MI350X's MODE.DX10_CLAMP contract).

Replaying 48 V_CMP__F{16,32,64} operations across 6 MODE configurations (ieee1_dx0_rne_allow 0x2f0, ieee1_dx0_rne_flush 0x200, ieee0_dx0_rne_allow 0x0f0, ieee1_dx0_rtz_allow, ieee1_dx0_rne_ovfl1, and ieee1_dx1_rne_allow 0x3f0; 294,912 Wave64 lanes) plus V_CMP_EQ_F32 and V_CMP_LT_F16 SDWA sweeps (24,576 lanes) on physical MI350X (AMD Instinct MI350X OAM, gfx950, ROCm 7.2.4 / HIP 7.2.53211; 319,488 total lanes) establishes one uniform hardware TRAPSTS.EXCP rule with 0 / 319,488 mismatches:

  • MODE.DX10_CLAMP == 1 (!(flags & RJ_ARITH_FP_DX10_CLAMP_OFF)): Suppresses all V_CMP / V_CMPX TRAPSTS.EXCP bits (0x00), regardless of CLAMP, MODE.IEEE, sNaNs, or subnormals.

  • MODE.DX10_CLAMP == 0 (flags & RJ_ARITH_FP_DX10_CLAMP_OFF): Every active lane across all 16 predicates — including constant V_CMP_F_F / V_CMP_TRU_F (V_CMPX_F_F / V_CMPX_TRU_F) — evaluates float_compare_exceptions<Bits>:

  • - sNaN raises INVALID (0x01); CLAMP = 1 promotes qNaN to raise INVALID (0x01).
    - Unflushed finite subnormal pairs raise INPUT_DENORM (0x02); pairing a subnormal with ±Inf or NaN suppresses INPUT_DENORM for that lane.

    In addition, two shared execution-bridge helpers (execute_packed_fma32 / execute_packed_binary32 in rj_arith_packed_f32_exec.h and execute_fmac64 / execute_literal_fma64 in rj_arith_fma64_variants_exec.h) previously passed nullptr for trapsts or discarded the returned state bits instead of publishing them on success.

    Technical Details

  • rj-arith (lib/arith/include/rj_arith/detail/rj_arith_compare.h, lib/arith/src/compare/float_compare_gfx950.cpp, lib/arith/COVERAGE.md):

  • - Add 192 rj_arith_v_cmp{,x}_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,t}_f{16,32,64}_w{32,64}_gfx950 entry points resolving Compatibility to BitExactEmpirical (mode 3), gating TRAPSTS accumulation on RJ_ARITH_FP_DX10_CLAMP_OFF (downgrading to fast AVX2/AVX-512 numeric dispatch when DX10_CLAMP == 1), and evaluating float_compare_exceptions across all 16 predicates when DX10_CLAMP == 0.
  • AMDISA codegen & execution bridge (rj_arith_compare.py, rj_arith_compare_exec.h, regenerated cdna4/{vopc,vop3}_exec.cpp, rj_arith_packed_f32_exec.h, rj_arith_fma64_variants_exec.h):

  • - Route cdna4 V_CMP_ / V_CMPX_ FP16/FP32/FP64 encodings to _gfx950 with RJ_ARITH_FP_DX10_CLAMP_OFF and gfx950_constant_compare_reads_inputs(...) so constant F/TRU predicates observe operands when reporting with DX10_CLAMP == 0.
    - Pass &causes in execute_packed_fma32 / execute_packed_binary32 and commit TRAPSTS / ALU causes on successful write_vector64_result across rj_arith_packed_f32_exec.h and rj_arith_fma64_variants_exec.h.

    Issue Tracking

    Follow-up to #16890, #16740, and #13670 (rj-arith).

    Test Plan

  • rj-arith unit tests (lib/arith/tests/compare/float_gfx950_test.cpp):

  • - Add 192 per-entry-point CompareCmpGfx950.Arithmetic tests covering all CPU levels, all 5 semantics modes, DX10_CLAMP, CLAMP, input flush, nonfinite INPUT_DENORM suppression, source/destination aliasing, and DPP8/DPP16.
  • amdisa codegen tests (lib/python/amdisa/tests/test_rj_arith_compare_codegen.py):

  • - Verify cdna4 _gfx950 bindings, RJ_ARITH_FP_DX10_CLAMP_OFF wiring, and gfx950_constant_compare_reads_inputs gating.
  • Decoded VM bridge tests (tests/gfx950_compare_test.cpp):

  • - Add Gfx950ComparisonTest.MasksDx10ClampTrapstsAndBitExactEmpirical (VOPC, VOP3 CLAMP/op_sel, CMPX, and SDWA across MODE states covering IEEE, DX10_CLAMP, and denormal preserve/flush across all 5 ArithmeticSemantics) and Gfx950ComparisonTest.PackedF32BridgeCommitsCausesAndRejectsCleanly.

    Test Result

    Verified on Linux x86-64 Zen 4 (AMD EPYC 9B14, rj_arith_cpuinfo = 0x3 (x86-64-zen4)):

  • ctest --test-dir build-arith-dbg/lib/arith -R baseline_linkage: 2 / 2 passed (1.70s)

  • ctest --test-dir build-rj/lib/arith (Release, -fno-exceptions, -DRJ_ENABLE_EXPENSIVE_CHECKS=ON): 3,831 / 3,831 passed (100%, 32.92s, including 192 new CompareCmpGfx950.Arithmetic tests)

  • ctest --test-dir build-rj (Release, -fno-exceptions, -DRJ_ENABLE_EXPENSIVE_CHECKS=ON): 19,626 / 19,626 host-runnable tests passed (100%, including Gfx950ComparisonTest.MasksDx10ClampTrapstsAndBitExactEmpirical and Gfx950ComparisonTest.PackedF32BridgeCommitsCausesAndRejectsCleanly in 0.11s each)

  • pytest lib/python/amdisa/tests: 6,361 passed, 41 skipped (40.01s)
  • Submission Checklist

  • Look over the contributing guidelines at https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.
  • Diff: 643 lines (+482 / -161) across 8 files Reviewer: kuhar Review duration: 2723m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.57) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 643 lines diff across 8 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.387
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #17189"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57.0% (MEDIUM) · Higher = larger blast radius
    57.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30.3% · Safe to merge
    30.3%