Skip to content

24 gpu 04 gpu gpu public path launch pool emit entry - #25

Merged
K-T0BIAS merged 4 commits into
4-native-gpu-support-cthreads-for-vulkanspir-vfrom
24-gpu-04-gpu-gpu-public-path-launch-pool-emit-entry_
Sep 16, 2026
Merged

K-T0BIAS merged 4 commits into
4-native-gpu-support-cthreads-for-vulkanspir-vfrom
24-gpu-04-gpu-gpu-public-path-launch-pool-emit-entry_

Conversation

@K-T0BIAS

Copy link
Copy Markdown
Owner

Summary

Lands the public Vulkan @Gpu / gpu() path (GPU-04) on top of the existing
context, GpuPack, ShaderCache, and LaunchEngine work. Users can decorate kernels,
prepare() / compile(), launch with gpu(...).join(), and get in-place list
writeback. Includes codegen->SPIR-V, broad tests

Features

  • @Gpu decorator: validate annotations (int/float/bool, list[...]),
    attach kernel meta, register for compile; requires CTHREADS_GPU + device
  • prepare() / compile() / gpu() / GpuJob: emit SPIR-V, register in
    ShaderCache, launch, fence-wait, write lists back; shutdown() clears the
    prepared flag so the next prepare re-registers shaders
  • GLSL codegen: Signature preamble (optional scalar SSBO + per-list SSBOs);
    Syntax lowering (assign/flow/ops/indexes); GlobalIdx / ThreadIdx / etc.;
    math.sqrt -> GLSL sqrt; assemble #version + main
  • SPIR-V: in-process glslang (compile_glsl); glslc CLI fallback; clearer
    compile errors (reserved GLSL identifier hint)
  • Binding convention: binding_count = (scalars ? 1 : 0) + lists; lists
    start at binding 0 when there are no scalars (C++ launch + descriptors match)
  • list[bool]: std430 4-byte 0/1 upload + writeback (same as scalar bool)
  • Dispatch sizing: ceil(n / local_size_x) with default workgroup size 64
  • Follow-ups (todo.md): resident marshal / multi-dispatch perf; workgroup
    __sync_threads (not grid-wide)

Modules / layout

Python (cthreads.gpu)

  • runtime.py: prepare, compile, gpu, GpuJob (not named prepare.py,
    so the callable does not shadow a submodule)
  • _ext_gpu_api.py: bridge to cthreads._ext.gpu
  • frontend/: @Gpu, indexes, errors, available / init / shutdown
  • gpu_kernel_meta.py / gpu_marshal.py: launch meta + arg / group_count helpers
  • compiler/translation/: Glsl, Signature, context, result, assemble, spirv,
    translate; syntax/ (Name, Index, Op, Assign, Flow, Syntax); plugins/
    (indexes, math_calls)
  • compiler/orchestrator/: GpuCompileSession, GpuUnit (emit + register)
  • third_party_notices/: glslang notices; root LICENSE updated

C++ (src/cthreads/cpp/gpu, CTHREADS_GPU=ON)

  • compile_glsl.cpp: vendored glslang linked into _ext
  • module.cpp / descriptors.cpp: lists-only bindings; list[bool] marshal
  • bindings: compile_glsl, register_shader, launch path updates
  • CMake FetchContent glslang 15.1.0 when GPU is on

Tests

  • Modular: glsl, signature, syntax, assemble, indexes, marshal, translate, spirv,
    kernel_meta, errors, decorator, reserved names, prepare
  • Live/pipeline: saxpy sizes, bool list, lists-only, ThreadIdx, multi-kernel, etc.
  • Helpers: tests/helpers_gpu.py

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.
@K-T0BIAS K-T0BIAS self-assigned this Sep 14, 2026
@K-T0BIAS

Copy link
Copy Markdown
Owner Author

DEVELOPER NOTE: Testing the gpu features does NOT work on github. Any changes must be tested locally and (ideally) be verified on > 2 devices.

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.
@K-T0BIAS
K-T0BIAS merged commit 4748d8f into 4-native-gpu-support-cthreads-for-vulkanspir-v Sep 16, 2026
2 checks passed
@K-T0BIAS
K-T0BIAS deleted the 24-gpu-04-gpu-gpu-public-path-launch-pool-emit-entry_ branch September 16, 2026 19:54
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