Repository navigation
[JLArrays] Support KA 0.10 - #826
christiangnrd wants to merge 7 commits into
Conversation
6c081b4 to
cbe82c2
Compare
|
I bumped CI timeout to 90 minutes since the POCL backend of KA 0.10 increases testsuite runtime and the macOS runners with only 1 job were right on the edge (either side) I cancelled the latest Buildkite run since the GHA timeout increase was the only change since the last successful run. |
7dd9c6b to
0266f3c
Compare
784d123 to
764ad56
Compare
|
Not sure this is the best approach but Claude redesigned the JLArrays storage to support bits union. |
|
Did you rebase out my changes? Looking at your force push, you went from https://github.com/JuliaGPU/GPUArrays.jl/commits/784d123d40e549406b292c57a61bfb1fe6c1d5ed/ to https://github.com/JuliaGPU/GPUArrays.jl/commits/764ad56eba1db4cf6a617083edf2ccaaea145ede/, which lacks the result of my rework last week (as reflected by the edited top post). |
|
I think I might have I missed the rework. The commit is probably still on my laptop I’ll revert my changes in a few hours. |
|
No worries. Maybe just have your Claude session incorporate those changes? It cleaned-up the implementation a bit, too. |
With KernelAbstractions 0.10, JLArray kernels run on its POCL back-end. Drop the KA 0.9 code paths, including JLDeviceArray, and convert JLArrays to POCL device arrays. Leave `Ref`s to POCL's conversion after converting their contents, so that `Ref`s of types, as passed by `convert.(T, A)`, are handled too. POCL's SPIR-V back-end cannot lower 128-bit integers, so stop testing Int128 with JLArrays.
Make JLBackend a KernelInterface back-end, like the GPU back-ends that moved to KernelAbstractions 0.10: it converts arguments to POCL's and forwards compilation, launches and device queries to the POCL back-end. Run the KernelAbstractions and KernelInterface testsuites on it, skipping the dense-to-sparse test, which JLArrays don't support, and the tests that only exercise KernelAbstractions' own CPU back-end. KA 0.10's CPU back-end has no static scheduling anymore, so this removes the `static` option of JLBackend.
KernelAbstractions narrows `@index` computations to Int32 on every back-end but POCL, because on POCL the narrowing keeps LLVM from vectorizing the loops over work-items. JLArray kernels run on POCL, but JLBackend isn't a POCLBackend, so they got Int32 indices. Using Int speeds up a 2048x2048 element-wise kernel by about 7%.
A JLArray was converted to a POCL device array by wrapping its memory in an Array and adapting that with a fresh KernelAdaptor, allocating both on every conversion, which happens several times per argument per launch. Construct the device array from the JLArray's pointer instead. This reduces the allocations of `c .= a .+ b` from 1344 to 480 bytes. Keep rejecting isbits-union element types, which the wrapping used to reject: POCL's device arrays read their type tags after the data, where JLArrays don't store any.
An `Array` can't wrap the storage of isbits unions, so the host storage used by reductions
couldn't be built from the untyped byte buffer, and kernels rejected arrays of isbits unions
as JLArrays kept no selector bytes after the data. Allocating a `Vector{T}` instead lets
`typed_data` return an `Array` (or, for derived arrays of isbits unions, a view of the
buffer), with Julia keeping the selector bytes. Kernel arguments are still constructed
directly from the array's pointer, and for isbits unions now point POCL at the selector
bytes. This drops the `tagoffset` bookkeeping, and the reductions no longer special-case
isbits unions.
Arrays of isbits unions are offset by element, as their elements can take no bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a4f65cf to
52517b8
Compare
|
Ok I had Claude recover your changes, rebase, and then reincorporate the storage backing I'm unsure about. Tests should pass once KA cpu backend has bitsunion support |
JLArrays, the CPU reference back-end used to test GPUArrays and downstream packages without a GPU, still targets KernelAbstractions 0.9. The vendor back-ends (CUDA, AMDGPU, Metal, oneAPI, OpenCL) have moved to KernelAbstractions 0.10, which builds on KernelInterface, so a test environment using JLArrays can't move along with them.
This ports JLArrays to KernelAbstractions 0.10 and drops 0.9.
JLBackendbecomes a KernelInterface back-end in the same shape as the vendor ports: it converts arguments to POCL device arrays and forwards compilation, launches and device queries to KernelAbstractions' POCL back-end, which is what runs KA 0.10 kernels on the CPU. The KernelAbstractions and KernelInterface testsuites now run on JLArrays, skipping the same POCL-only tests the vendor back-ends skip.Along the way:
convert.(T, ::JLArray)failed to compile, because JLArrays wrappedRefs before POCL could recognize aRefof a type. JLArrays now converts only what theRefholds.Intlike POCL's own, instead of theInt32KernelAbstractions uses on GPUs, which keeps LLVM from vectorizing over work-items (~7% on a 2048×2048 element-wise kernel).c .= a .+ bgoes from 1344 to 480 bytes).This is breaking, hence JLArrays 0.5:
JLBackend(; static)is gone, since KA 0.10's CPU back-end has no static scheduling, and so isJLDeviceArray(JLArrays are POCLCLDeviceArrays in kernels). POCL's SPIR-V back-end cannot lower 128-bit integers, soInt128is no longer tested with JLArrays.The two testsuites add a few minutes to CI, and the macOS runners, which run tests one at a time, were already close to the 60-minute job limit, so the limit is raised to 90 minutes.
Stacked on #829.
Depends on JuliaGPU/KernelAbstractions.jl#944