Repository navigation
GPU: arrays of tuples and object types as kernel arguments (+ boolean[]/byte[]) - #1103
Merged
Merged
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>
…: number }[], [number, int][] Their elements are structs held by value, one after another, laid out alike on the CPU and every GPU: the launch passes each element's size (gpuElementSize: numbers, integers, floats, booleans and nested tuples, each at its alignment), and gpuReduce, GpuArray and gpuBatch take them as they take numbers. A barrier kernel's guard sees through a field's GEP to the element. A tuple with a string, an array or a class in it is refused. gpu_structs.ts (particles, padded fields, nested, whole elements, GpuArray, gpuReduce, a barrier kernel past n) passes on the RTX 5080, JIT and exe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k no longer refuses them; docs for struct arrays Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Arrays of tuples and object types as kernel arguments
Stacked on #1101 (warp builtins): merge that first. After it merges, I'll rebase this branch onto
mainso only the last two commits remain.{ x: number, y: number }[]and[number, int][]already hold their elements by value as naturally aligned LLVM structs, which is also what a GPU wants. A kernel can read and write fields (ps[i].x), nested fields (bodies[i].pos.x) and whole elements (ps[i] = { x, y }).gpuElementSizecomputes an element's size with LLVM's natural layout: numbers, integers, floats, booleans and nested tuples, each at its alignment. The launch,gpuReduce,gpuBatchandGpuArrayall use it.gpuBarrier, the bounds guard now looks through field GEPs, sops[i].y = ...from a thread pastnis dropped.boolean[],byte[]) were refused. The check meant for plain scalars also caught any array whose elements were 1 byte.Tested
gpu_structs.tsruns on the RTX 5080 under the JIT and as an executable, on Windows and on Linux (WSL). It covers:GpuArray,gpuReduce, and a barrier kernel with an array longer thann;boolean[]andbyte[].compile/structs.tsfor NVIDIA, AMD and Intel, checking the element sizes 32 (with padding), 16 (read-only) and 24, plusspirv-val;🤖 Generated with Claude Code