Repository navigation
GPU: a warp's builtins (shuffles, ballot, all/any, lane, warp size) - #1101
Closed
ASDAlexander77 wants to merge 2 commits into
Closed
ASDAlexander77 wants to merge 2 commits into
ASDAlexander77 wants to merge 2 commits into
Conversation
… gpuBallot, gpuAll, gpuAny Stubs lowered per GPU: NVIDIA shfl.sync/vote.sync over activemask, AMD ds_bpermute and ballot (wave32 from gfx10; gpuBallot refused on wave64), Intel OpSubgroupShuffleINTEL (SPV_INTEL_subgroups, given to the SPIR-V backend through its -spirv-ext option) and sub-group reduce/all/any. A kernel that uses them runs as a barrier kernel (every thread; writes past n dropped); its votes leave out the threads past n. Its block must be whole warps (a multiple of 32), gpuReduce refuses it, and a CPU call is an error. gpu_warp.ts and gpu_scan.ts (a prefix sum of shuffles and shared memory) pass on the RTX 5080, JIT and exe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…x (WSL) too Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
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.
A warp's builtins
Threads that run together in a warp can now read each other's values directly:
gpuWarpSize(),gpuLaneIndex()gpuShuffle(v, lane),gpuShuffleDown(v, d),gpuShuffleUp(v, d),gpuShuffleXor(v, m):va number of 4 or 8 bytesgpuBallot(p)(anintmask),gpuAll(p),gpuAny(p)How they work on each GPU
shfl.sync.idxoveractivemaskds_bpermuteOpSubgroupShuffleINTEL(SPV_INTEL_subgroups)vote.sync.ballotamdgcn.ballot(wave32; refused on wave64, e.g. gfx906)1 << lanevote.sync.all/anyOpGroupAll/AnyRules
gpuBarrierkernel: every thread runs and array writes past n are guarded. Its votes leave out threads past n, and in a shuffle such a thread gives its own value.gpuReducerefuses such a kernel, and calling it on the CPU is an error.-spirv-extcommand-line option, so tslang sets that option itself, once per process.Tested
gpu_warp.tschecks every builtin with n = 1000, arrays longer than n, and a shuffle inside anif.gpu_scan.tscomputes a prefix sum of 100,000 values fromgpuShuffleUp, shared memory and a second launch.gpuReduceis unchanged. It already runs close to the cost of a launch, and moving it to shuffles would change the order in which float sums are added.🤖 Generated with Claude Code