-
-
Notifications
You must be signed in to change notification settings - Fork 38
Add OpenCL.jl backend for CPU-based GPU debugging #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OpenCL.jl backend for CPU-based GPU debugging #377
Conversation
This adds support for OpenCL.jl with pocl as a CPU-based backend for debugging GPU issues without requiring actual GPU hardware. This is particularly useful for debugging issues like SciML#375 where complex nested types fail with GPU kernels. Changes: - Add OpenCL to weakdeps and extensions in Project.toml - Create OpenCLExt extension with CLBackend support - Add OpenCL backend to test/utils.jl - Add OpenCL test group to GitHub Actions CI - Update README to document OpenCL backend The OpenCL backend uses pocl_jll as a CPU target that behaves like GPU targets, allowing developers to reproduce and debug GPU-specific issues in CI or on systems without GPU hardware. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
They should only be in weakdeps and extras, not in the main deps section.
The correct backend type name in OpenCL.jl is OpenCLBackend, not CLBackend.
- Update compat to allow OpenCL v0.9 and v0.10 - Add OpenCL back to weakdeps (it was accidentally removed) - Tested with OpenCL v0.10.6 which includes OpenCLBackend type - OpenCLExt now compiles and works correctly with OpenCL v0.10
Update: OpenCL v0.10 SupportI've updated the PR to support OpenCL.jl v0.10, which was released in January 2025 with KernelAbstractions backend support. Changes:
Testing:✅ OpenCLExt compiles successfully with OpenCL v0.10.6 The implementation now works with the latest OpenCL.jl which includes proper KernelAbstractions backend support as mentioned by @tbesard. |
- Add pocl_jll to extras for testing - Update test/utils.jl to load pocl_jll when GROUP=OpenCL - OpenCL backend requires pocl_jll to provide CPU-based OpenCL drivers - Without pocl_jll, OpenCL has no platforms/devices available
CI tests need pocl_jll in the test environment dependencies.
|
Fixed CI failure by adding The test environment needs pocl_jll as a dependency for OpenCL tests to work. |
|
Merging to continue the fix elsewhere, just want to have the OpenCL setup and tests around. |
Summary
This PR adds support for OpenCL.jl as a CPU-based backend for debugging GPU kernel issues without requiring actual GPU hardware. This addresses the need discussed in #375 where GPU-specific issues (like complex nested types failing with CUDA kernels) are difficult to debug without GPU access.
Background
As mentioned by @tbesard in Zulip, OpenCL.jl with pocl_jll provides a CPU target that behaves like GPU targets, making it possible to reproduce GPU-specific issues in CI or on development machines without GPU hardware. This is particularly valuable for:
EnsembleGPUKernelfails with MTK generated problems #375)Changes
maxthreads()andmaybe_prefer_blocks()for CLBackendTesting
The implementation follows the same pattern as other backends (AMDGPU, Metal, oneAPI, JLArrays). The OpenCL backend will be tested in CI alongside CPU and JLArrays backends.
Note: Full testing requires OpenCL.jl with pocl_jll, which provides the CPU-based OpenCL implementation. Based on @tbesard's comment that OpenCL.jl was recently revived to support KernelAbstractions, this backend enables experimenting with this new functionality.
Future Work
EnsembleGPUKernelfails with MTK generated problems #375🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com