Skip to content

[upstream #1857] Fix whole-wave min reduction over a partial wave (WaveActive* recognition) - #283

Open
ufoptg wants to merge 4 commits into
mainfrom
upstream-pr/1857
Open

ufoptg wants to merge 4 commits into
mainfrom
upstream-pr/1857

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Scope

Fixes the whole-wave v_min_u32 reduction returning 0 (instead of the true minimum) when the rasterizer launches only part of a wave, on GPUs with 32-lane waves (and in any partial wave). The reduction idiom is now recognised and WaveActiveMin/WaveActiveMax/WaveActiveBitOr is emitted over the launched lanes; the DPP / permlane / readlane steps are suppressed (they read unlaunched lanes as 0 instead of the identity).

  • Test added: gpu_wave64_ps_partial_wave_min (synthetic, no game data).
  • Branch: wave64-partial-min-test. Commits: cecfa49 (test) → ae53d84 (fix).

Before / after (RTX 5070 Ti, DXC 1.9.2602.17)

  • Before: min=0 (want 2.0) → FAILED.
  • After: min=2.0 → PASS.

Tests

  • gpu_wave64_ps_partial_wave_min: PASS
  • gpu_wave64_ps_whole_wave_reductions: PASS
  • gpu_wave64_ps_spill_slots: PASS
  • gpu_wave64_vs_spill_slots_and_identity: PASS
  • All GPU tests (cargo test -p xcl --lib gpu_): 104 passed, 0 failed, 1 ignored.

Files

  • crates/xcl/src/gpu/recomp/emit.rs (+15)
  • crates/xcl/src/gpu/recomp/mod.rs (+142)

Limitations / risks

  • The recognition matches the specific reduction idiom (seed v_cndmask_b32 + 3× DPP8 xor 1/2/4 + DPP16 row_mirror + v_permlanex16 + v_readlane 32/0). A program using the same instruction sequence for a different purpose would be mis-recognised; not observed in the corpus.
  • Semantics: WaveActive* operates over the launched lanes of the physical wave; the split wave64→2×wave32 exchange is unchanged.
  • Pending: full audit and the complete test suite (862 tests) were not run in this pass; only the GPU tests above.

License

GPL-2.0-only (unchanged).


Mirror of xcl-dev#1857 (auto-synced, do not edit).

llegate26 added 4 commits November 24, 2026 15:57
…duccion min en onda parcial)

Nuevo test que dibuja un triangulo pequeno (3 quads = 6 pixeles, onda parcial) y reduce
V_MIN_U32 sobre los pixeles impares. Reproduce el bug: las lanes no lanzadas se leen como 0
en vez de la identidad -1, y el min devuelve 0 en vez del minimo real (2).
…veActive*

La reduccion de onda (seed v_cndmask_b32 + DPP8 xor 1/2/4 + DPP16 row_mirror +
v_permlanex16 + v_readlane 32/0) se reconoce en translate() y el seed se reduce con
WaveActiveMin/Max/BitOr sobre las lanes lanzadas; los pasos DPP/readlane se suprimen
(leian las lanes no lanzadas como 0 en vez de la identidad, rompiendo min).

Antes: gpu_wave64_ps_partial_wave_min daba min=0 (want 2.0).
Despues: da 2.0. Regresion: gpu_wave64_ps_whole_wave_reductions,
gpu_wave64_ps_spill_slots y 104 tests GPU pasan.
…s (v_readlane 32 + op)

El reconocedor ahora suprime solo la reduccion dentro de cada mitad (3x DPP8 + DPP16 +
v_permlanex16 + op) y CONSERVA v_readlane lane32 + op + v_readlane lane0, que combinan las
dos mitades wave32 en la reduccion wave64 global. Antes (skip de 8) suprimia el readlane32 y
la reduccion quedaba por-mitad (WaveActive* solo cubre la wave fisica de 32 lanes).

Regresion: gpu_wave64_ps_partial_wave_min, gpu_wave64_ps_whole_wave_reductions,
gpu_wave64_ps_spill_slots y 104 tests GPU pasan.
…/2/4, DPP16 row_mirror y lanes de readlane 32/0

Los campos DPP se leen de la codificacion de extension (emit::ext_encoding), no de d.enc.
Ahora el reconocedor solo acepta la secuencia exacta de reduccion de onda (DPP8 xor 1/2/4,
DPP16 row_mirror ctrl 0x140, v_readlane lane 32 y 0), reduciendo falsos positivos (riesgos A/B).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant