Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

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:

Changes

  • Project.toml: Added OpenCL to weakdeps, extensions, and compat entries
  • ext/OpenCLExt.jl: New extension providing maxthreads() and maybe_prefer_blocks() for CLBackend
  • test/utils.jl: Added OpenCL backend initialization for GROUP=OpenCL
  • .github/workflows/CI.yml: Added OpenCL to the test matrix for CPU-based CI testing
  • README.md: Documented OpenCL as a CPU backend option for debugging

Testing

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

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

ChrisRackauckas and others added 2 commits October 24, 2025 09:42
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.
ChrisRackauckas and others added 5 commits October 24, 2025 09:54
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
@ChrisRackauckas-Claude
Copy link
Author

Update: OpenCL v0.10 Support

I've updated the PR to support OpenCL.jl v0.10, which was released in January 2025 with KernelAbstractions backend support.

Changes:

  • Fixed backend type: → (the correct type name in OpenCL v0.10)
  • Updated compat to support both v0.9 and v0.10: OpenCL = "0.9, 0.10"
  • Added OpenCL to weakdeps (was accidentally removed during cleanup)

Testing:

✅ OpenCLExt compiles successfully with OpenCL v0.10.6
DiffEqGPU.maxthreads(OpenCLBackend()) works correctly
✅ Backend is recognized in test suite

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.
@ChrisRackauckas-Claude
Copy link
Author

Fixed CI failure by adding pocl_jll to test/Project.toml.

The test environment needs pocl_jll as a dependency for OpenCL tests to work.

@ChrisRackauckas
Copy link
Member

Merging to continue the fix elsewhere, just want to have the OpenCL setup and tests around.

@ChrisRackauckas ChrisRackauckas merged commit a802496 into SciML:master Oct 25, 2025
7 of 23 checks passed
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