Repository navigation
Indirect dispatch in Kernel; ShunPerm (parallel Fisher-Yates) on Gridwise - #87
Merged
Merged
Conversation
…unPerm on Gridwise Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015kfNC6id65zEHzuAAH4jtJ
… label and datatype like MultisplitPerm Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015kfNC6id65zEHzuAAH4jtJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Indirect dispatch in Gridwise's
Kernel, and Shun et al.'s parallel Fisher–Yates ported onto Gridwise using it. This comes after #84–#86, all merged.Indirect dispatch (core)
Kerneloptionindirect: "args"(or{ buffer, offset }). The kernel then dispatches withdispatchWorkgroupsIndirect, reading the workgroup counts (x, y, z: three u32s) from that buffer when the GPU runs it. An earlier kernel can size a later one without a trip to the CPU. A buffer withoutGPUBufferUsage.INDIRECTis a clear error. Pipelines, bind groups, timing andtrialswork as before.indirectDispatch, used viainclude(). It writes the counts, splitting a 1D count across x and y to stay withinmaxComputeWorkgroupsPerDimension; as far as I know, Dawn silently skips counts above the limit. The dispatched kernel linearizes its workgroup id withcomputeLinearizedGridParametersSplitand skips ids at or past the count. A count of 0 dispatches nothing.BasePrimitive.singleTrialOnly. It's for primitives whose kernels can't be repeated in place, such as a round that appends to a list:execute()refusestrials > 1with a clear message;warmUp()warms such a primitive up with whole executes, sobenchmark()works with it.ShunPerm (
src/shunperm.mjs)Shun, Gu, Blelloch, Fineman and Gibbons, SODA 2015.
atomicMax, then commit the swaps that own both. The output is bit-identical to sequential Fisher–Yates with the same swap targets, on any GPU and in any run.reference()computes it on the CPU.maxRoundsrounds (defaultceil(3 log2 n) + 16) are recorded up front, and before each round a one-invocation kernel sizes that round's indirect dispatch from the number of iterations still pending. There are no CPU round trips, and rounds after the last dispatch no workgroups.roundsUsed()reports how many rounds were needed.UniformStruct,include(),random.mjs. So it also takes the Philox option (rng), as MultisplitPerm does.ShunPerm.sequentialfor 1,000, 2^20 and 100,003 elements. The paper's Shun results therefore carry over.docs/random-permutations.md, and added tomisc/benchmark_node.mjsasshun.Tests
maxComputeWorkgroupsPerDimension + 3(which needs a second dimension), and the indirectly dispatched kernel checks how many workgroups ran and the largest id.reference()for 2, 1,000 and 100,003 elements and Philox-7 at 16,384, finished withinmaxRounds, andtrials: 2refused. Plus 2^20 in the large tests.Checked
Not done here
ShunPermfrom Gridwise instead of its own copy.Kernels, and Gridwise records each as its own compute pass, where the paper's port puts everything in one pass. If that shows up in timings, a later option could let consecutive kernels share a pass.Generated by Claude Code