Skip to content

GPU tests: run wave64 kernels as two wave32 halves on 32-lane GPUs - #71

Closed
gefydev wants to merge 1 commit into
xcl-dev:mainfrom
gefydev:recomp-kernel-tests-wave32
Closed

gefydev wants to merge 1 commit into
xcl-dev:mainfrom
gefydev:recomp-kernel-tests-wave32

Conversation

@gefydev

@gefydev gefydev commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

On an adapter without 64-lane waves (NVIDIA), 41 GPU tests print SKIPPED …: no wave64. Most of them check instruction semantics that don't depend on the wave size: f64, atomics, images, typed buffers, scalar moves. So on NVIDIA the recompiler's output for those instructions is never run at all.

This PR runs the kernels the same way console mesh programs already run there (#39): as two native wave32 halves of one logical wave64.

  • Options::hw_wave = 32 with a wave64 kernel: [WaveSize(32)], [numthreads(64, 1, 1)], xcl_half = gi >> 5, xcl_logical_wave64 = true, and lane_id / the VGPR slot is WaveGetLaneIndex() + 32 * xcl_half. Each half holds only its own word of a lane mask (the other word is 0) and the same uniform SGPRs, so the first lane of each half InterlockedOrs the SGPRs into the result. The result buffer is a fresh committed resource, so it starts zeroed. A mask then gets both words, and a uniform value stays the same.
  • runner::run_code / run_code_with use that when wave64_supported() is false. They refuse a program geometry_wave32_hazards flags ("needs a 64-lane wave (cross-half semantics: …)"), so a test can't pass on a split that changes its meaning.
  • The 22 tests whose programs pass that check now use gpu_ready_wave32. The others keep gpu_ready. Those are the cross-lane tests (DPP, swizzle, readlane, EXEC/VCC branches), the ones that draw, and the arena/mesh ones.
  • New gpu_kernel_halves_merge_lane_masks: v_cmp over 64 lanes gives vcc = (0xFFFFFFFF, 0xFF) with v0 < 40, and a uniform s_movk stays 0x1234.

Adapters with wave64 are unchanged: hw_wave stays 0, the tests run as before.

gpu_frexp_f64_exp_and_mant fails when split, so it keeps gpu_ready here: v_frexp_mant_f64 with NEG on a NaN keeps the sign. The f64 NEG modifier is emitted as -x, which DXIL compiles as fsub -0.0, x, and IEEE doesn't define the sign of a NaN result there. #72 fixes that on top of this one.

Validation

GTX 1650 (Turing, wave32 only), Windows 11, NVIDIA driver 32.0.16.2114, MSVC debug build, DXC from Windows SDK 10.0.26100:

  • cargo test --workspace (lib, e2e with the test title, console_dlls_e2e, gpu_pso_e2e, …): 0 failed, the same as main on this machine. No test that passes on main fails here.
  • cargo test -p xcl --lib gpu:: one at a time: 19 SKIPPED … no wave64 instead of 41. The 22 tests above ran on the GPU and passed, plus the new one.

Before that I checked each test on the same GPU on Linux (Wine + vkd3d-proton 2.14.1). There global_atomic_inc_x2 / dec_x2 hang in gpu_more_atomics_sub_dword_scratch_valu, even with one lane. On Windows they finish in ~60 ms with the right values, so that one is vkd3d's DXIL → SPIR-V, not the HLSL.

@FZNull

FZNull commented Nov 23, 2026

Copy link
Copy Markdown

Validated on native Windows 11 (not Wine/vkd3d-proton): RTX 4060 (Ada, lane range 32..32), MSVC, DXC 1.8.2502.11 from SDK 10.0.26100.

No TDR, no device removal; mesh and e2e tests unaffected. Nothing from a game package was used.

AI-assisted.

On an adapter without 64-lane waves (NVIDIA) every kernel test that
needs wave64 was skipped: 41 of them, most of which check instruction
semantics that do not depend on the wave size (f64, atomics, images,
typed buffers, scalar moves).

Options::hw_wave = 32 now runs a wave64 kernel as two native wave32
halves, as console mesh programs do there: lane_id covers both halves,
each half ORs its SGPRs into the zeroed result, so a lane mask gets
both words and a uniform value stays the same. runner::run_code and
run_code_with use it on such an adapter, and refuse a program that
needs both halves at once (geometry_wave32_hazards). The 22 tests
whose programs pass that check switch to gpu_ready_wave32.
@gefydev
gefydev force-pushed the recomp-kernel-tests-wave32 branch from 927e14c to a81bb28 Compare November 23, 2026 01:13
gefydev added a commit to gefydev/xcl that referenced this pull request Nov 23, 2026
…pute e2e through the PSO hook (not for merge)
@certified-retart

Copy link
Copy Markdown
Contributor

Tested a81bb28 locally on Windows 10 (with D3D12 Agility SDK 1.620.2 / DXC 10.0.26100.0) across both a wave32 NVIDIA GPU and a wave64 AMD GPU:

  • NVIDIA GeForce RTX 5070 (wave32, XCL_ADAPTER=0):
    • cargo test -p xcl --lib gpu::recomp::tests::gpu_ -- --test-threads=1 --nocapture
    • 24 GPU kernel tests executed and passed (0 failures, 3.53s), including gpu_kernel_halves_merge_lane_masks, gpu_atomic_fcmpswap_x2, gpu_atomic_fmin_fmax_*, gpu_bvh_intersect_ray, gpu_f64_class_compare, gpu_rndne_f64, gpu_global_atomics_and_sub_dword_access, gpu_more_atomics_sub_dword_scratch_valu, gpu_images_*, gpu_typed_buffer_loads_and_stores, gpu_valu_*, gpu_v_swaprel_b32, gpu_dword_addtid_per_lane_addresses, etc.
    • 18 genuinely wave64-only tests skipped with no wave64 as expected (plus gpu_retail_vs_blit_gen_amb_cube without XCL_SAMPLE_RPF and ignored gpu_arena_partial_commit_probe).
  • AMD Radeon Graphics (Ryzen 7 9800X3D iGPU, wave64, XCL_ADAPTER=1, XCL_REQUIRE_GPU=wave64):
    • 43 passed, 0 failed, 1 ignored (2.13s) — zero regressions on wave64 hardware.

@Foniass

Foniass commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Same overlap as on #70: #67 also runs the GPU test kernels on 32-lane GPUs (2 tests left SKIPPED on an RTX 5070 Ti, against 18 with this PR), and the two conflict in emit.rs and runner.rs. Side-by-side results: #67 (comment). The f64 fix in #72 applies on top of #67 too, with gpu_ready_wave32 → gpu_ready in its test.

DIMASIK1502 pushed a commit to DIMASIK1502/xcl that referenced this pull request Nov 23, 2026
KickoffX (xcl-dev#93), Wait32/64BitValueX (xcl-dev#71/xcl-dev#72), RSSetDepthBiasX (xcl-dev#94). Conflicts with main resolved (console slots and PC overrides united; ExecuteCommandLists keeps the per-queue title-memory refresh). KickoffX resets the PC list mid-recording: it now also restores what the Reset clears and console code had set (descriptor heaps, topology, viewports, scissors, blend factor, stencil ref, vertex buffers, render targets) - on the console a kickoff leaves the list's state as it was; without the heaps a translated draw after it would read garbage descriptors.
ivall pushed a commit that referenced this pull request Nov 23, 2026
The f64 NEG source modifier was emitted as -x and ABS as abs(x). DXIL
has no fneg: DXC writes -x as fsub -0.0, x, and IEEE leaves the sign
of a NaN result open, so a negated NaN kept its sign on NVIDIA
(v_frexp_mant_f64 with NEG on 0x7FF8000000000001). The hardware
modifiers only flip or clear the sign bit; they are now that, on the
high dword.

Cherry-picked from #72 (ec446ec) without #71, which #67 superseded; the
test gates on gpu_ready (#67: wave64 programs run split on 32-lane GPUs).
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Thanks – closing as superseded by #67 (merged), which runs wave64 kernels / compute / mesh / ES+GS on 32-lane GPUs as two wave32 halves that exchange masks and lane values, so the cross-lane tests run there too (2 skips left on an RTX 5070 Ti vs 18–19 with this approach). The f64 sign-bit fix from #72 is on main (c2887bb).

@ivall ivall closed this Nov 23, 2026
heretic1321 added a commit to heretic1321/xcl that referenced this pull request Nov 23, 2026
…cl-dev#248)

Stacked on xcl-dev#269 (which moves 64 KiB-aligned kept-in-step title textures
onto shared 64 KiB pages in vram::Book).

What remains after xcl-dev#269:
- Overwritten placements stayed registered in title_textures forever,
  continuing to be scanned/uploaded and holding extra tiles / leftover
  pages in vram::Book even when a newer texture replaced their memory.
- real::resource_at (device xcl-dev#70/xcl-dev#71 by-address SRV/UAV creation) stored
  every created ID3D12Resource in MADE forever and never released
  superseded entries (including unaligned committed textures).
- Device / queue release did not clear MADE, title_textures state,
  upload queues, or vram::Pages::waited.
- XCL_ACTIVITY memory lines lacked title-texture active/covered/retired/
  released counters.

This commit adds O(log N + k) overlap retirement in title_textures,
detaches retired entries from vram::Book, cools and releases superseded
entries in real::resource_at (2 s cooling + MADE_MAX cap), cleans up on
device/queue release, and logs title-texture counters on XCL_ACTIVITY.

Assisted-by: Antigravity CLI (Gemini 4 Neon)
vincentes added a commit to vincentes/xcl-wasm that referenced this pull request Nov 24, 2026
The null device becomes `win::d3d12x`, a device that does the memory side
of D3D12.X for real and still renders nothing:

- Unified memory, as on the console: a resource's GPU address is its
  address in the title's address space. Committed resources and heaps get
  graphics memory, placed resources lie in their heap, and
  CreatePlacedResourceX (xcl-dev#44) puts one on memory the title allocated; Map
  returns that address. Read-back buffers up to 64 MiB come from the
  fourth 4 GiB of the region, where XCL's Windows runtime keeps them.
- Command lists record; a queue runs what it is given, in order, at every
  turn of the scheduler (`pump`): buffer copies, the console's memory
  commands (CopyMemoryToMemoryX xcl-dev#60, FillMemoryWith32BitValueX xcl-dev#61,
  Write32 / 64BitValue…X xcl-dev#69 / xcl-dev#70 / xcl-dev#89 with the GPU timestamp) and
  Wait32 / 64BitValueX (xcl-dev#71 / xcl-dev#72), which hold the queue until another
  thread writes the value. KickoffX (xcl-dev#93) starts a list before it is
  closed. A fence moves, and its events are signalled, when the queue
  gets to its Signal.
- The console's layouts: device extensions from slot 44
  (CreateCommandQueueX, CreateCommandListX with the DMA engine's own list
  interface, page pools, pipeline-state creation as objects, …), the
  graphics command list's console slots, AllocateUploadMemory (xcl-dev#148).
- CheckFeatureSupport zeroes the whole structure; a raytracing
  acceleration structure view writes the console's descriptor words.

Draws, pipelines, other views, PresentX and the frame clock do nothing
or are missing. Dev builds optimise `xcl-emu` (the title test: 37 s →
3.3 s).

Measured on macOS (aarch64): the test title passes 40 of its checks (9 of
D3D12.X's 16); the 6 that fail before it aborts in its XG texture check
need HLSL compilation and rendering, the frame clock, or DirectStorage.
`cargo test -p xcl-guest`: 38 passed, 0 failed (the title test now checks
every check by name; the staged tree was built and tested apart from
the working tree). Inside the wasm64 module (1.2 MB, Node 24) the same
run takes 4.4 s: 115 M instructions, most of them the 80 MiB upload check.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
JR-Wiederkehr pushed a commit to JR-Wiederkehr/xcl that referenced this pull request Nov 25, 2026
A retail title gives the GPU only addresses in a GPU view of its memory
(PAGE_NOACCESS on the CPU; with the 16-window layout it lies in the view
windows). The device's views and placed buffers took such an address as
memory nobody has: a constant buffer view was left empty, a buffer placed
there became a committed resource of its own that stayed zero (so its GPU
address, the buffer views of it, indirect arguments, copies and vertex
buffers read zeros), and a view made by address carried the address but
never asked for the tiles behind it, so the shader read zeros there too.

Each now asks for the tiles of exactly the range it covers
(view_want::want): views by address (device xcl-dev#70 / xcl-dev#71, the range
buffer_words_at computes), constant buffer views, views of buffer
resources, the acceleration-structure view (from the root on; its size is
not known) and a Map read of a buffer in the view. A constant buffer view
and an acceleration-structure view in a view window carry the address. A
buffer placed in a GPU view goes over the view window's tiles through
sparse::place_buffer, as one in a sparse window does, and may run on into
the next view windows; when that is refused it is a resource of its own
as before, logged once. A Map read of such a buffer reads back what the
GPU wrote into its CPU view, and its release does not wait as one over
CPU pages does.

Without the 16-window layout no address is in a view window and nothing
changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 25, 2026
…uffer in

The line that announces a depth UAV twin says which PC state the buffer
was made in, and the first run with the twins on reads it to learn that
state. It gave the state of the object the UAV was made on. A UAV made
by address (device xcl-dev#71) is made on XCL's own object for that memory,
which resource_at creates in COMMON, so the line read 0x0 for a buffer
the title made in another state.

resource_at now marks the objects it makes (depth_uav::by_address). A
Cell keeps the PC state of the first object a title's creation call
made, and the line gives that one; when the title made no object at
that address, it gives the state of the UAV's own object as before.
The copies that come later take the state of the DSV's object and are
not affected.

Tested: depth_uav::tests::the_state_a_buffer_was_made_in_is_that_of_the_titles_object
(new, no GPU).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 25, 2026
…tch off

The tests of depth UAV twins made their buffer with CreateCommittedResource,
which on WARP gave a committed PC resource with no title address. The
path a console depth buffer most likely takes was not covered:
CreatePlacedResourceX at a title address (the registration hooks in
device_x::create_placed_resource_x, the key by vram::canonical_va) and a
stencil UAV made by address (device xcl-dev#71), which is made on XCL's own
object at that memory. Nor was it asserted in the library's process that
with the switch off nothing is registered and a UAV stays a null view.

- gpu_a_stencil_uav_by_address_is_a_view_of_the_placed_buffers_twin (WARP,
  child process): the title places a 16x16 D24S8 buffer with
  ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS at an address in unified
  memory, in DEPTH_WRITE. It is kept under that address with that state;
  a xcl-dev#71 stencil UAV of the same memory, on a second object there, names
  the placed buffer's twin in the shared heap, and the state stays the
  title's. Run on its own, the buffer went to a video-memory arena, the
  view's object aliased it, and twin #1's line gave state 0x10.
- the_switch_decides_whether_a_buffer_is_kept_and_its_uavs_redirected
  (no GPU): note_created keeps the buffer only when the switch is on;
  off, resolve_uav gives a null view with the reason "XCL_DEPTH_UAV_TWIN
  is off".

Tested: the depth_uav tests, 13 passed, 0 failed, no SKIPPED line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
grahamster2 added a commit to grahamster2/xcl that referenced this pull request Nov 26, 2026
resource_at keys the resources it makes for views by address (device xcl-dev#70,
xcl-dev#71) by (address, 0x38-byte resource desc) and cleared only 0x34.. of it.
Bytes 0x04..0x08 are the padding between Dimension and Alignment (the
same for every dimension: the desc is one D3D12_RESOURCE_DESC); the title
leaves stack bytes there, so the same view at the same address made a
second resource whenever they differed. view_resource_key clears both.
On amd-dev's placed SRVs this was 31 % of the entries in a 200 s run.

Test: a_view_by_address_ignores_the_padding_of_its_desc.

Ported from amd-dev c093211 by Greem (the same fix there is in
format_alias.rs prepare_placed_srv_desc / prepare_placed_uav_desc).
grahamster2 added a commit to grahamster2/xcl that referenced this pull request Nov 26, 2026
…o memory first

A tile listed with no video memory (XCL_SPARSE_LAZY=1) got some at the CPU's
first bytes, a buffer placed on it, or a memory operation recorded on a list -
and the last only when memory was not short (materialize without force). On
tiled resources tier 2 a write to a tile with no memory is dropped: a shader's
store, a copy, a fence value the title then waits for. The Series X profile on
a 10 GB card hung (DEVICE_HUNG at 209 s, 38111 tiles listed with no memory).

Now every route xcl sees a GPU write take asks for the tiles (sparse::gpu_write,
taken by the next submit, before the list runs, forced like a placed buffer):
- memory operations on a list (immediates, Write32/64, fills, CopyMemoryToMemory,
  timestamps), as before but forced;
- buffer UAVs and their counters (CreateUnorderedAccessView, the view by
  address xcl-dev#71 with its counter at +0x30);
- root UAVs (SetCompute/GraphicsRootUnorderedAccessView, the console lists' xcl-dev#45),
  from the address as far as the tiles are committed (4 MiB at most);
- copies and query resolves into a console buffer (note_copy_into);
- dispatches and draws whose console shaders may store to memory
  (gpu::effects::may_write_memory; unknown: may): their root views and the 64-bit
  addresses among their root constants (bind_abi, two-pass stages, console lists).
A thread asks once for tiles it asked for lately, until tiles are listed again.
Bytes the CPU owed a tile (starved) go up at the submit that gives it memory.

The sparse windows' line counts "N tiles made resident for GPU writes (M found
none)"; the first of each route that met a tile with no memory is logged, and a
GPU write that found none is warned of.

Tests (sparse::tests, real GPU): a UAV on a lazy range makes it resident (a root
UAV too); a copy destination does; a read-only SRV does not, nor a root SRV of
shaders that store nothing; effects::may_write_memory tells stores from loads.
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.

5 participants