GPU 0.2.0: @Gpu path, GpuArena, workgroup barriers, docs, and cthreads[gpu] wheels - #28
Merged
Merged
Conversation
Dynamic loader init, _ext.gpu bindings, cthreads.gpu API/errors, and pytest coverage that skips when no GPU is available.
Add Vulkan GPU context probe (Issue GPU-01 #9) behind CTHREADS_GPU.
Device-local SSBOs with staging via a Context-owned transfer engine, option-5 GpuPack, typed GPU errors, and test-only _ext.gpu.testing round-trips.
…-substrate 20 gou 02 memory gpupack marshal substrate
Shader cache and descriptors, launch_gpu_kernel submit with fence, join list writeback into kept Python args, and saxpy smoke under _ext.gpu.testing.
Add GPU launch path and SpawnedGpuKernel join (#22).
Process-lifetime launch command pool with per-job CB and fence checkout/return under mutex; stop creating a command pool per launch.
Complete the Vulkan GPU user path on top of LaunchEngine: vendored glslang SPIR-V, Signature/codegen, ShaderCache register, resident-aware prepare after shutdown, lists-only bindings, list[bool] marshal, and broad unit/pipeline coverage.
Introduce process-wide GpuState and Python GpuArena so bound lists stay on device across launches. Support join(download=False), borrow resident buffers in launch, and skip GLSL compile tests on GitHub Actions.
…unch-pool-emit-entry_ 24 gpu 04 gpu gpu public path launch pool emit entry
…ait. Lower both call forms to the same GLSL barrier and memoryBarrierShared through a CallPlugin, wire Call expr-stmts on the GPU path, and export a sync stub.
Add GPU workgroup barrier via __sync_threads and Barrier.arrive_and_w…
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.
Summary
Merges the public Vulkan compute path into
mainfor the 0.2.0 line:@Gpu/gpu()/GpuJob, list writeback,GpuArenaresidency, workgroup barriers(
__sync_threads/Barrier.arrive_and_wait()), full user docs, and optionalGPU wheels via
pip install "cthreads[gpu]"(cthreads-gpuon PyPI).CPU
@Threadis unchanged. GPU is a separate backend in the same process.Shared memory is not in this merge (planned 0.2.1).
How it works (short)
@Gpu(scalars +listof scalars only).GlobalIdx.x(dispatch is rounded up to workgroup size 64;always
if i >= n: return).gpu(fn, *args)compiles registered kernels to SPIR-V (cached), uploadsbuffers, dispatches on Vulkan, returns a started
GpuJob.join()waits on the fence and, by default, downloads list args into thesame Python list objects. Scalars are inputs only;
result()is alwaysNone.GpuArena.bind(...)once, thenjoin(download=False)andarena.sync()when Python must read results.Global phases use multiple
gpu()launches withjoinbetween them.There is no mid-run Python observe on GPU (unlike CPU
__sync_state).Product rules and reading order:
docs/guide/gpu/README.md.Features
Kernels and launch
@Gpu/@Gpu(log=True): validate, register, attach launch metaprepare/compile/gpu(fn, *args)/GpuJob.join(download=...)GlobalIdx,ThreadIdx,BlockIdx,BlockDim,GridDimsqrt/floor/int(...)(andmath.*forms)gpu.available(),device_name(), typed GPU errorsResidency
GpuArena: bind Python lists into processGpuStatejoin(download=False)skips host writeback;arena.sync()downloads on demandSync
from cthreads.sync import Barrier, __sync_threads@Gpu:__sync_threads()andBarrier.arrive_and_wait()lower to thesame GLSL workgroup barrier;
Barrier(...)construction is rejected on GPUBarrier(parties)unchangedDocs
User guides (no prior GPU experience assumed):
GlobalIdxgpu()/GpuJobAlso wired from docs/index.md, install.md,
API.md, and the package README.
Packaging / CI
cthreadswheels: CPU (CTHREADS_GPU=OFF)cthreads-gpuwheels: GPU ON (retarget viascripts/retarget_gpu_wheel.py)gpu = ["cthreads-gpu==<version>"](must matchproject.version)test-gpucompile smoke; release builds both wheel setsExample: element-wise kernel
Example: resident multi-pass loop
Example: workgroup barrier call shape
Barriers are workgroup-local. For grid-wide phases, launch twice and
joinbetween kernels (guide/gpu/sync.md).
Install (after release)
Editable GPU build (contributors):
CMAKE_ARGS=-DCTHREADS_GPU=ON pip install -e ".[test]".Out of scope (follow-ups)
@Threadlaunching@Gpu(gpu_future_cpu_to_gpu.md)