[PR #2171] translator: active runs under --wave64-emulate too (TRANSLATOR-W64-EMULATE-ACTIVE-RUNS) #2174

Open
opened 2026-11-26 21:20:18 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2171
Author: @kawaii-shakal
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: translator-w64-emulate-active-runs


📝 Commits (3)

  • 1c5b64d translator: active runs under --wave64-emulate too (TRANSLATOR-W64-EMULATE-ACTIVE-RUNS)
  • 033b1c9 translator: say active runs hold under --wave64-emulate in design.md; name the run check an internal invariant
  • 3a0a26b Merge remote-tracking branch 'upstream/main' into translator-w64-emulate-active-runs

📊 Changes

3 files changed (+91 additions, -5 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/semantic/test_active_runs.py (+80 -1)
📝 tools/rdna2spirv.py (+10 -3)

📄 Description

Claimed in the coordination issue as TRANSLATOR-W64-EMULATE-ACTIVE-RUNS: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7179737707

Problem

184d78905 puts a run of lane-local VALU instructions under one if (active) instead of an OpSelect per VGPR write, but only outside --wave64-emulate. The comment gave the reason as emulated rounds splitting blocks at instruction boundaries. They don't: a round ends a segment only at x_split, which the translator calls for a cross-lane exchange, a barrier or a memory-ordering point. A lane-local instruction is none of these, so a run always sits inside one segment.

Change

  • Gen.insns no longer excludes self.emulate from runs.
  • While translating a run it checks that x_marks did not grow. An x_split inside a run raises an AssertionError instead of cutting the if in two, the same way a wrongly lane-local instruction already stops the translation.
  • The docstring says why runs are safe under emulation.

On the new test's shader the module goes from 49 to 40 OpSelects.

Tested

  • New test: tests/semantic/test_active_runs.py gets EmulatedWave64ActiveRuns, an emulated compute if/else over EXEC with runs on both sides and a cross-half buffer_load (an exchange round) between them. At 64 and 128 threads, in both scheduling orders, it checks with run_emulated_workgroup that the module has its runs and stores the values worked out lane by lane, the same as the per-write translation (MIN_ACTIVE_RUN out of reach). It fails on main ("0 not greater than or equal to 3").
  • Semantic suite: python -I scripts/run_semantic_tests.py tests/semantic passes, 495 files and 6,334 tests.
  • Emulate tests: the other tests that use --wave64-emulate pass: test_mesh_compute, test_translate and test_wave64_halves_fixtures under pytest, plus the standalone ones.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2171 **Author:** [@kawaii-shakal](https://github.com/kawaii-shakal) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `translator-w64-emulate-active-runs` --- ### 📝 Commits (3) - [`1c5b64d`](https://github.com/ubiquitarianism/leonida/commit/1c5b64defb10b366a644093087179dc0fd803e80) translator: active runs under --wave64-emulate too (TRANSLATOR-W64-EMULATE-ACTIVE-RUNS) - [`033b1c9`](https://github.com/ubiquitarianism/leonida/commit/033b1c9461169acfbbc94362e6c34dc7eabbfa97) translator: say active runs hold under --wave64-emulate in design.md; name the run check an internal invariant - [`3a0a26b`](https://github.com/ubiquitarianism/leonida/commit/3a0a26b778c48afb97fef54fee51b5c076b7db42) Merge remote-tracking branch 'upstream/main' into translator-w64-emulate-active-runs ### 📊 Changes **3 files changed** (+91 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/semantic/test_active_runs.py` (+80 -1) 📝 `tools/rdna2spirv.py` (+10 -3) </details> ### 📄 Description Claimed in the coordination issue as TRANSLATOR-W64-EMULATE-ACTIVE-RUNS: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7179737707 ### Problem 184d78905 puts a run of lane-local VALU instructions under one `if (active)` instead of an `OpSelect` per VGPR write, but only outside `--wave64-emulate`. The comment gave the reason as emulated rounds splitting blocks at instruction boundaries. They don't: a round ends a segment only at `x_split`, which the translator calls for a cross-lane exchange, a barrier or a memory-ordering point. A lane-local instruction is none of these, so a run always sits inside one segment. ### Change - `Gen.insns` no longer excludes `self.emulate` from runs. - While translating a run it checks that `x_marks` did not grow. An `x_split` inside a run raises an `AssertionError` instead of cutting the `if` in two, the same way a wrongly lane-local instruction already stops the translation. - The docstring says why runs are safe under emulation. On the new test's shader the module goes from 49 to 40 `OpSelect`s. ### Tested - **New test:** `tests/semantic/test_active_runs.py` gets `EmulatedWave64ActiveRuns`, an emulated compute if/else over EXEC with runs on both sides and a cross-half `buffer_load` (an exchange round) between them. At 64 and 128 threads, in both scheduling orders, it checks with `run_emulated_workgroup` that the module has its runs and stores the values worked out lane by lane, the same as the per-write translation (`MIN_ACTIVE_RUN` out of reach). It fails on main ("0 not greater than or equal to 3"). - **Semantic suite:** `python -I scripts/run_semantic_tests.py tests/semantic` passes, 495 files and 6,334 tests. - **Emulate tests:** the other tests that use `--wave64-emulate` pass: `test_mesh_compute`, `test_translate` and `test_wave64_halves_fixtures` under pytest, plus the standalone ones. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2174
No description provided.