Skip to content

DLDFScan and OneSweep declare their buffers once; UniformStruct slots - #83

Merged
jowens merged 3 commits into
mainfrom
declared-bindings-sorts
Oct 24, 2026
Merged

jowens merged 3 commits into
mainfrom
declared-bindings-sorts

Conversation

@jowens

@jowens jowens commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #82, which is stacked on #81. This finishes moving every Gridwise primitive to declared buffers and UniformStruct.

  • DLDFScan: ScanParameters is a UniformStruct, and its six buffers are declared with buffers. The output type is array<vec4<T>> for a scan and array<T> for a reduce.
  • Core, UniformStruct slots: OneSweep gives each kernel its own parameters, packed into one uniform buffer at aligned offsets. That's now a core capability:
    • allocateSlots(label, valuesList, alignment) packs the sets;
    • slot(label, i, alignment) is the binding for set i.
  • OneSweep:
    • SortParameters is a UniformStruct with one slot per kernel.
    • Its buffers are declared with buffers, in two bind groups. Keys and payloads swap roles on odd passes.
    • The long layout comments for hist and passHist moved along with the declarations.
    • The last use of WriteGPUBuffer in a primitive is gone. It's still tested by test_wgsl_functions.mjs.

Checked

  • WGSL, layout and bindings compared with main:
    • DLDFScan, 4 configurations (including emulated subgroups): identical apart from where the declarations sit.

    • OneSweep, 26 kernels over 4 configurations (keys u32, key-value i32 descending, u64, KEY_BITS 12): identical apart from three things:

      • where the declarations sit;
      • the struct's padding fields;
      • each slot's binding now having an explicit size (32 bytes) instead of running to the end of the buffer.

      The offsets (0, 256, 512, …) are unchanged.

  • Simulated RDNA4 (gfx1201): 83 of 83 tests pass, including all sorts, both scans, permutations, histograms and the new core test.

With this, no Gridwise primitive declares a binding by hand any more.


Generated by Claude Code

ScanParameters is a UniformStruct; the kernel's six buffers are declared with
`buffers` (the output is array<vec4<T>> for a scan, array<T> for a reduce).
The kernel is unchanged apart from where the declarations sit (4
configurations compared with main, including emulated subgroups).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kfNC6id65zEHzuAAH4jtJ
…l parameters

- UniformStruct.allocateSlots(label, valuesList, alignment) packs one set of
  values per kernel into one uniform buffer at aligned offsets, and
  slot(label, i, alignment) is the binding of set i ({ buffer, offset, size }).
- OneSweep: SortParameters is a UniformStruct with one slot per kernel
  (global_hist, onesweep_scan, each onesweep_pass); its buffers are declared
  with `buffers` (two bind groups; keys and payloads swap on odd passes). The
  layout comments for hist and passHist moved with the declarations.
- Its 26 kernels (4 configurations) are unchanged apart from where the
  declarations sit, the struct's padding, and each slot's binding now having
  an explicit size (32 bytes) rather than running to the end of the buffer;
  offsets are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kfNC6id65zEHzuAAH4jtJ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kfNC6id65zEHzuAAH4jtJ
Base automatically changed from declared-bindings-scan to main October 24, 2026 15:03
@jowens
jowens merged commit 35f5139 into main Oct 24, 2026
4 checks passed
@jowens
jowens deleted the declared-bindings-sorts branch October 24, 2026 15:10
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.

2 participants