Skip to content

POCL: reinterpret of a device array refers to undefined _reinterpret_exception #869

Closed

Description

@maleadt

Calling reinterpret on a device array inside a kernel fails to compile on the POCL back-end (and therefore on CPU()):

using KernelAbstractions

@kernel function reint!(A, B)
    i = @index(Global)
    C = reinterpret(Int32, B)
    @inbounds A[i] = C[i]
end

B = KernelAbstractions.ones(CPU(), Float32, 4)
A = KernelAbstractions.zeros(CPU(), Int32, 4)
reint!(CPU())(A, B; ndrange=4)
ERROR: InvalidIRError: compiling MethodInstance for gpu_reint!(...) resulted in invalid LLVM IR
Reason: unsupported use of an undefined name (use of 'KernelAbstractions.POCL._reinterpret_exception')
Stacktrace:
 [1] reinterpret
   @ src/pocl/device/array.jl:273

src/pocl/device/array.jl was copied from OpenCL.jl in #556, where the check is GPUArrays._reinterpret_exception(T, a). KernelAbstractions doesn't depend on GPUArrays, so the call was left pointing at a function that doesn't exist. The fix is to carry the check (GPUArrays' src/host/base.jl) along with the device array code, and to test reinterpret in a kernel.

Found on main (1c2be35) while looking into #867.

Activity

  1. added a commit that references this issue on Oct 11, 2026
    e2b918e
  2. added a commit that references this issue on Oct 11, 2026
    f34a52b
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