kernelx: skip coherent UMA fallback for physical pages on sparse layouts #2157

Manually merged
github merged 1 commit from gh-pr/2157/head into gh-pr/2157/base 2026-11-26 05:21:04 +00:00
Owner

@⁠O5-7 on GitHub · 2026-11-25 06:30 UTC · original
O5-7:kernelx/physical-home-skip-coherent → main · +61 −9 · 1 files · 1 commits · merged 2026-11-25 10:51 UTC

When sparse UMA windows are full on a runtime layout, AllocateTitlePhysicalPages currently falls back to u.alloc in the committed coherent window before falling back to MEM_RESERVE plain memory. Unlike VirtualAlloc (which reserves 96 MiB KEEP headroom for XCL's own readback/internal allocations), that fallback can consume the remaining coherent headroom and yields a home where lazy_home(home) is false (already committed and never decommitted when moved away).

This skips the coherent u.alloc fallback when u.has_sparse() is true, sending sparse-layout overflow straight to MEM_RESERVE plain memory while preserving u.alloc for coherent-only layouts without sparse windows. Part of #1566.

What is in it

  • alloc_physical_home & AllocateTitlePhysicalPages: skip u.alloc when u.has_sparse() is true (crates/xcl/src/hle/kernelx.rs)
  • Synthetic unit tests covering both sparse-UMA overflow (coherent window untouched, plain home reserved) and coherent-only UMA (crates/xcl/src/hle/kernelx.rs)

Tested

  • Hardware / OS / Rust: NVIDIA GeForce RTX 5080 (driver 32.0.15.9579), AMD Ryzen 7 9700X, Windows 11 10.0.26100, Rust 1.100.0 MSVC, debug (cargo test) + release (smoke.ps1)
  • cargo test -p xcl --lib hle::kernelx::tests: 38 passed, 0 failed, 1 ignored (scatter_timing)
  • cargo test --workspace -- --test-threads=4 (with XCL_DXC_DIR=D:\Windows Kits\10\bin\10.0.26100.0\x64): 1156 passed, 0 failed, 46 ignored (24 SKIPPED GPU sub-checks on RTX 5080 wave32: 20 no wave64, 3 DIFFERS_ON_1426 f16/V_CVT_F16_F32 per-lane refusals, 1 no heap windows)

Regression run

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1686 (PresentX 1686)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14083 MB
xcl-smoke v1
commit: 3e1eab296b4d43218ce66a24723cdaecdffa94f6
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1687 (PresentX 1687)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14081 MB

Not tested

  • AMD or Intel GPUs, native wave64 GPUs, Linux / Wine
  • Retail world loading past the initial menus: the 60 s smoke run stayed within the 12 GiB sparse aperture (sparse 7445 MB), so sparse overflow was exercised by the synthetic unit test rather than the retail run (with XCL_DXC_DIR on D:\ before #2101 lands, host DXC lookup is also intercepted by the D: mount in both the main and PR smoke runs)

AI use

  • Antigravity (Gemini 4 Neon): inspected kernelx.rs / uma.rs, wrote the fix and unit tests, ran the test suite and smoke runs, and drafted this PR description.
**@⁠O5-7** on GitHub · 2026-11-25 06:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/2157) `O5-7:kernelx/physical-home-skip-coherent` → `main` · +61 −9 · 1 files · 1 commits · merged 2026-11-25 10:51 UTC When sparse UMA windows are full on a runtime layout, `AllocateTitlePhysicalPages` currently falls back to `u.alloc` in the committed coherent window before falling back to `MEM_RESERVE` plain memory. Unlike `VirtualAlloc` (which reserves 96 MiB `KEEP` headroom for XCL's own readback/internal allocations), that fallback can consume the remaining coherent headroom and yields a home where `lazy_home(home)` is `false` (already committed and never decommitted when moved away). This skips the coherent `u.alloc` fallback when `u.has_sparse()` is true, sending sparse-layout overflow straight to `MEM_RESERVE` plain memory while preserving `u.alloc` for coherent-only layouts without sparse windows. Part of #1566. **What is in it** - `alloc_physical_home` & `AllocateTitlePhysicalPages`: skip `u.alloc` when `u.has_sparse()` is true (`crates/xcl/src/hle/kernelx.rs`) - Synthetic unit tests covering both sparse-UMA overflow (coherent window untouched, plain home reserved) and coherent-only UMA (`crates/xcl/src/hle/kernelx.rs`) **Tested** - Hardware / OS / Rust: NVIDIA GeForce RTX 5080 (driver 32.0.15.9579), AMD Ryzen 7 9700X, Windows 11 10.0.26100, Rust 1.100.0 MSVC, debug (`cargo test`) + release (`smoke.ps1`) - `cargo test -p xcl --lib hle::kernelx::tests`: 38 passed, 0 failed, 1 ignored (`scatter_timing`) - `cargo test --workspace -- --test-threads=4` (with `XCL_DXC_DIR=D:\Windows Kits\10\bin\10.0.26100.0\x64`): 1156 passed, 0 failed, 46 ignored (24 `SKIPPED` GPU sub-checks on RTX 5080 wave32: 20 `no wave64`, 3 `DIFFERS_ON_1426` f16/V_CVT_F16_F32 per-lane refusals, 1 `no heap windows`) **Regression run** ``` xcl-smoke v1 commit: cbc296ab65a2661a61e3e2da109134bcd5319f60 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1686 (PresentX 1686) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14083 MB ``` ``` xcl-smoke v1 commit: 3e1eab296b4d43218ce66a24723cdaecdffa94f6 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1687 (PresentX 1687) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14081 MB ``` **Not tested** - AMD or Intel GPUs, native wave64 GPUs, Linux / Wine - Retail world loading past the initial menus: the 60 s smoke run stayed within the 12 GiB sparse aperture (`sparse 7445 MB`), so sparse overflow was exercised by the synthetic unit test rather than the retail run (with `XCL_DXC_DIR` on `D:\` before #2101 lands, host DXC lookup is also intercepted by the `D:` mount in both the `main` and PR smoke runs) **AI use** - Antigravity (Gemini 4 Neon): inspected `kernelx.rs` / `uma.rs`, wrote the fix and unit tests, ran the test suite and smoke runs, and drafted this PR description.
When sparse UMA is exhausted, AllocateTitlePhysicalPages fell back to
u.alloc in the committed coherent window without respecting the 96 MiB
KEEP headroom in VirtualAlloc, and created non-lazy homes that cannot be
decommitted when mapped elsewhere.

Skip the coherent u.alloc fallback when u.has_sparse() is true so
overflow goes straight to MEM_RESERVE plain memory (keeping u.alloc
only for coherent-only layouts), and add synthetic unit tests.

Part of #1566
Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:21:02 +00:00
github manually merged commit 3e1eab296b into gh-pr/2157/base 2026-11-26 05:21:04 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 07:04 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 07:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2157#issuecomment-7155466994) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 07:05 UTC · original

Independent Windows x64 test report on commit 3e1eab296b4d43218ce66a24723cdaecdffa94f6.

Environment

  • OS: Windows 11 Enterprise Evaluation x64 (build 26200.9974, Session 0)
  • CPU: AMD Ryzen 7 3800X
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) (debug build)
  • Note: CPU-only targeted run (XCL_ADAPTER=NONE_CPU_ONLY)

Command

xcl-97fdf2b9ff8e1482.exe hle::kernelx::tests::physical_home_ --nocapture --test-threads=1

Results

  • Passed: 2, Failed: 0, Ignored: 0, Skipped: 0 (0.02s, exit code 0)
  • hle::kernelx::tests::physical_home_overflow_with_sparse_windows_skips_coherent_window: ok
  • hle::kernelx::tests::physical_home_without_sparse_windows_uses_coherent_window: ok

Not tested

  • Full workspace suite, GPU tests, and game smoke run.

AI use

  • Verified and published with T3 Code / Antigravity (gemini-4-neon).
**@⁠JJAutoCompare** on GitHub · 2026-11-25 07:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2157#issuecomment-7155470685) Independent Windows x64 test report on commit `3e1eab296b4d43218ce66a24723cdaecdffa94f6`. **Environment** - OS: Windows 11 Enterprise Evaluation x64 (build 26200.9974, Session 0) - CPU: AMD Ryzen 7 3800X - Toolchain: `rustc 1.100.0 (0ef1bc386 2026-11-09)` (debug build) - Note: CPU-only targeted run (`XCL_ADAPTER=NONE_CPU_ONLY`) **Command** ```powershell xcl-97fdf2b9ff8e1482.exe hle::kernelx::tests::physical_home_ --nocapture --test-threads=1 ``` **Results** - Passed: 2, Failed: 0, Ignored: 0, Skipped: 0 (0.02s, exit code 0) - `hle::kernelx::tests::physical_home_overflow_with_sparse_windows_skips_coherent_window`: ok - `hle::kernelx::tests::physical_home_without_sparse_windows_uses_coherent_window`: ok **Not tested** - Full workspace suite, GPU tests, and game smoke run. **AI use** - Verified and published with T3 Code / Antigravity (`gemini-4-neon`).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-25 07:04 UTC · original · edited 2026-11-25 07:09 UTC

Full-suite run, since this PR has no test report yet. Tested exact head 3e1eab2 (on its base cbc296a).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1144 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: physical_home_overflow_with_sparse_windows_skips_coherent_window, physical_home_without_sparse_windows_uses_coherent_window.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1155 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 568e7db too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-25 07:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2157#issuecomment-7155461554) · edited 2026-11-25 07:09 UTC Full-suite run, since this PR has no test report yet. Tested exact head `3e1eab2` (on its base `cbc296a`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests`: **1144 passed, 0 failed, 44 ignored**. SKIPPED (no wave64): `a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu`, `a_per_lane_2d_or_3d_group_runs_on_the_gpu`, `coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu`, `cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, `the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu`. - The new tests ran and passed: `physical_home_overflow_with_sparse_windows_skips_coherent_window`, `physical_home_without_sparse_windows_uses_coherent_window`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`: **1155 passed, 0 failed, 46 ignored**. SKIPPED: `f16_programs_on_the_gpu` (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `--skip` leaves out tests that fail on main `568e7db` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651), the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests, `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` and `mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu` ([follow-up on #1651](https://git.gtahub.st/github/xcl-dev--xcl/issues/1651)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, and `gpu::dxil::fuzz_tests` seeds 70, 545, 1019 and 1507 fail `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card (drivers 616.64 and 621.40). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). The AMD run does not set `XCL_REQUIRE_GPU`. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 10:45 UTC · original

Code review on 3e1eab2:

  • Extracting alloc_physical_home in crates/xcl/src/hle/kernelx.rs so !u.has_sparse() gates coherent UMA fallback cleanly protects coherent UMA KEEP headroom when sparse windows are present, with dedicated unit coverage for both paths.
  • Note overlap with #2135 (8a3e42c), which addresses the same AllocateTitlePhysicalPages coherent-UMA fallback behavior.
  • Diff audited and CI workflow approved (running).

Remaining before merge: Build and test finishing green plus dual-vendor (AMD + NVIDIA) verification on 3e1eab2.

**@⁠raylitebull** on GitHub · 2026-11-25 10:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2157#issuecomment-7160120889) Code review on `3e1eab2`: - Extracting `alloc_physical_home` in `crates/xcl/src/hle/kernelx.rs` so `!u.has_sparse()` gates coherent UMA fallback cleanly protects coherent UMA `KEEP` headroom when sparse windows are present, with dedicated unit coverage for both paths. - Note overlap with `#2135` (`8a3e42c`), which addresses the same `AllocateTitlePhysicalPages` coherent-UMA fallback behavior. - Diff audited and CI workflow approved (running). **Remaining before merge:** `Build and test` finishing green plus dual-vendor (**AMD** + **NVIDIA**) verification on `3e1eab2`.
This discussion has been locked. Commenting is limited to contributors.
No description provided.