Add Vulkan GPU context probe (Issue GPU-01 #9) behind CTHREADS_GPU. - #19
Merged
K-T0BIAS merged 1 commit intoSep 5, 2026
Conversation
Dynamic loader init, _ext.gpu bindings, cthreads.gpu API/errors, and pytest coverage that skips when no GPU is available.
K-T0BIAS
merged commit Sep 5, 2026
7e677a8
into
4-native-gpu-support-cthreads-for-vulkanspir-v
2 checks passed
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
Closes GPU Issue 1: optional Vulkan context in
_extso we can detect a compute device without linkingvulkan-1(loader isLoadLibrary/dlopenat runtime). Default builds stay CPU-only (CTHREADS_GPU=OFF).CMake / build
option(CTHREADS_GPU OFF); when ON:find_package(Vulkan), compile GPU sources,CTHREADS_WITH_GPU=1, Vulkan headers only (noVulkan::Vulkanlink)CMAKE_ARGS=-DCTHREADS_GPU=ON(cmd/PowerShell) or--config-settings=cmake.define.CTHREADS_GPU=ON; wipebuild/when togglingC++ runtime (
src/cthreads/cpp/gpu/)vkCreateInstance-> pick compute queue (prefer discrete) -> logical deviceinit/shutdown/available/device_name(mutex + double-checked init; failed init cleans up)Bindings
gpu_module.hpp/gpu_module.cpp->cthreads._ext.gpumodule.cppunder#ifdef CTHREADS_WITH_GPUPython
cthreads.gpu: soft-import_ext.gpu;available/device_name/init/shutdownerrors.py:CThreadsGPUError+ mapped types (VulkanNotBuiltError,VulkanLoaderNotFound,VulkanNoDevice,VulkanInitFailed, …)frontend/Gpu/stubs for later@Gpuwork (not functional yet)Tests
tests/unit/test_gpu_context.py: error mapping, not-built soft path, fake_ext.gpu; live Vulkan tests skip when not built or no deviceOther
.clangdfor Vulkan/project includes (local IntelliSense).gitignore: ignore*.gifdemo artifactsTest plan
pip install -e .;from cthreads import gpu;gpu.available()isFalse; import does not crashset CMAKE_ARGS=-DCTHREADS_GPU=ON+pip install -e . -v; log showscthreads GPU: ON (Vulkan)gpu.available()/gpu.device_name()match a real GPU (e.g. vsvulkaninfo)python -m pytest tests/unit/test_gpu_context.py -v -rs, passes; live tests skip or pass depending on hardware