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.
Without an explicit
backend, every operation on aBitArraythrows:count,any,sort!,findallandcumsumfail the same way. Withbackend=AK.get_backend([])they all work (AK.sum(v; backend=AK.get_backend([]))is2).AK takes the backend from its arguments with
KernelAbstractions.get_backend. KernelAbstractions only defines that forArrayon 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. ABitArrayis the obvious case, and it's whatA .> 0returns on the host.There are two possible fixes:
_backend_voteinsrc/algorithms.jl) could treatBitArray, and possibly other Base host array types, as host arrays.get_backend(::BitArray)next toget_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.