You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Operations on a BitArray fail without an explicit backend #143
Without an explicit backend, every operation on a BitArray throws:
julia>import AcceleratedKernels as AK
julia> v =BitVector([true, false, true]);
julia> AK.sum(v)
ERROR: ArgumentError: Implement `KernelAbstractions.get_backend(::BitVector)`
count, any, sort!, findall and cumsum fail the same way. With backend=AK.get_backend([]) they all work (AK.sum(v; backend=AK.get_backend([])) is 2).
AK takes the backend from its arguments with KernelAbstractions.get_backend. KernelAbstractions only defines that for Array on the host, so any other array type that lives in host memory and has no method of its own fails, even though AK can process it on the host. A BitArray is the obvious case, and it's what A .> 0 returns on the host.
There are two possible fixes:
AK's backend resolution (_backend_vote in src/algorithms.jl) could treat BitArray, and possibly other Base host array types, as host arrays.
KernelAbstractions could define get_backend(::BitArray) next to get_backend(::Array).
The second also helps other KernelAbstractions users, but AK needs the first for KernelAbstractions versions without it.
Found while testing #137. AcceleratedKernels 0.5.0 (052c44b), Julia 1.13.0.
Hi, i'd like to work on this. i'd fix it in AK, by treating BitArray as a host array when picking the backend. i noticed a BitArray can't be passed to a POCL kernel on KA 0.10, so i'm not sure get_backend(::BitArray) in KA helps much outside AK, but happy to add it too if you want.
one question: since a BitArray packs its bits, should ops that write into one stay on a single task?
Activity
christiangnrd commentedon Oct 1, 2026
I could see this
get_backenddefinition getting a backport into the 0.9 branchsasmith-14 commentedon Nov 7, 2026
Hi, i'd like to work on this. i'd fix it in AK, by treating
BitArrayas a host array when picking the backend. i noticed aBitArraycan't be passed to a POCL kernel on KA 0.10, so i'm not sureget_backend(::BitArray)in KA helps much outside AK, but happy to add it too if you want.one question: since a
BitArraypacks its bits, should ops that write into one stay on a single task?Run operations on BitArrays on the host, writing to them on one task
Run operations on BitArrays on the host, writing to them on one task