Skip to content

Operations on a BitArray fail without an explicit backend #143

Description

@maleadt

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.

Activity

  1. christiangnrd commented on Oct 1, 2026

    @christiangnrd
    Member

    I could see this get_backend definition getting a backport into the 0.9 branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions