Build `@opencl` on top of `clcall`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Read lib/cl/kernel.jl and src/compiler/execution.jl, then compare their conversion, locking, ownership, and launch paths with the cited CUDA.jl and Metal.jl implementations. Trace how clcall, launch_tuple, and KernelState pass arguments and kernel state. Done means @opencl uses a shared clcall_tuple conversion and ownership path, with kernel-specific exception handling retained and launch latency and host compile time unchanged.
Written by the indexing model from the issue text.
Description
In CUDA.jl and AMDGPU.jl, @cuda/@roc launches are built on the public low-level launch function: launch_converted prepends the KernelState and calls cudacall_tuple (roccall) with the kernel's compiled signature. Metal.jl is doing the same with its new metalcall (JuliaGPU/Metal.jl#1084). OpenCL.jl has two launch paths instead:
clcall(lib/cl/kernel.jl) converts its arguments withclconvert/unsafe_clconvert, locks the arrays throughargument_lock, and callscl.call;@opencl(launch_tupleinsrc/compiler/execution.jl) converts withkernel_convert/KernelAdaptor, which collects the indirect memory and theManagedallocations, locks them withlock_managed, migrates their ownership withtake_ownership!, and callscl.callthroughlaunch_with_exception_mailbox.
So argument conversion, locking and the ownership of allocations are implemented twice, and they already differ: clcall only handles arrays passed as pointer arguments, converting everything else with Base.cconvert, so arrays nested in other arguments are neither converted to device arrays, nor locked, owned or registered as indirect memory (the caller has to pass indirect_memory itself). Building @opencl on clcall would leave one implementation of these, used and tested by every launch, and make clcall handle arguments like a launch from Julia code does.
That probably means:
- adding a
clcall_tuplethat@openclcalls withTuple{KernelState, F, TT...}, withCore.kwcallforwarding the arguments as a tuple, likecudacalldoes since JuliaGPU/CUDA.jl#3309 (clcallis a varargs method with keyword arguments, which splats them); - moving the
KernelAdaptorconversion and the ownership transaction intoclcall's conversion, so that non-pointer arguments are converted with it and their indirect memory and allocations are collected; - keeping the parts that only depend on the kernel object, like the exception mailbox, in the
@opencllayer.
Launch latency and the host compile time of new kernel signatures should stay the same; for Metal.jl, the shared path didn't change either (JuliaGPU/Metal.jl#1085).
- Dominant language
- Julia
- Stars
- 313
- Forks
- 50
- Avg merge
- 22h 18m
- Merged PRs (30d)
- 40
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaGPU/OpenCL.jl
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
performance runtime
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Intel CPU runtime: reports half-precision atomic addition but lacks the atomic_add builtin for halfOpenIntel CPU kernels upstream
Difficulty 4/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Intel CPU kernels upstream
Difficulty 4/5 3-5 days Newbie friendliness 43/100
JuliaGPU/OpenCL.jl#559 · 1 comment ·
Maintainers usually reply within 1 day
-
Intel CPU kernels upstream
Difficulty 4/5 3-5 days Newbie friendliness 35/100
JuliaGPU/OpenCL.jl#558 · 1 comment ·
Maintainers usually reply within 1 day
All issues in JuliaGPU/OpenCL.jl
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JuliaGeometry/Meshes.jl#1469 ·
Maintainers usually reply within 1 day
-
distributed 🕸️
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CliMA/Oceananigans.jl#6295 · 1 comment ·
Maintainers usually reply within 1 day
-
CI: two jobs fail on the new ubuntu-latest (Ubuntu 26.04) runner imagePossibly taken @bjarthur claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
mojaie/MolecularGraph.jl#151 ·