Skip to content

CLArray reject an empty Float16 matrix on NVIDIA GPU backend #640

Backlog

Description

@apiqwe

Description

Constructing a CLArray from an empty 3×0 Float16 host matrix succeeds on PoCL and raises a Float16 support error on NVIDIA GPU backend.
The example only constructs the device array and copies it back to check its shape and element type.

Reproduction

Run in a Julia project with the packages below and both OpenCL devices available. The loop selects each platform explicitly.

using pocl_jll, OpenCL, GPUArrays

GPUArrays.allowscalar(false)

host = reshape(Float16[], 3, 0)

for (backend, vendor, kind) in (("PoCL CPU", "pocl", :cpu), ("NVIDIA GPU", "NVIDIA", :gpu))
    platform = first(p for p in cl.platforms() if occursin(vendor, p.vendor))
    cl.device!(first(cl.devices(platform, kind)))
    try
        result = CLArray(host)
        OpenCL.synchronize()
        value = Array(result)
        println(backend, ": ", typeof(value), " ", repr(value))
    catch err
        println(backend, ": ", first(eachsplit(sprint(showerror, err), '\n')))
    end
end

Observed output

PoCL CPU: Matrix{Float16} Matrix{Float16}(undef, 3, 0)
NVIDIA GPU: Float16 is not supported on this device

Expected behavior or clarification

Is FP16 support required for every Float16 CLArray, including zero-element arrays? If the requirement is intentional, documenting that it applies at construction time would clarify the result. If empty arrays are supported independently of FP16 arithmetic, I would expect the constructor to preserve the (3, 0) shape and Float16 element type on both devices.

Additional context

  • The PoCL CPU device advertises cl_khr_fp16; the NVIDIA OpenCL device does not advertise it with this driver. An empty Float32 matrix of the same shape was accepted on both devices.
  • In OpenCL.jl 1.0.0, check_eltype in src/array.jl checks the active device’s extensions for Float16 element types. Its argument is the element type, so the check does not distinguish an empty allocation from a nonempty one.

Environment

  • Julia 1.13.4, OpenCL.jl 1.0.0, GPUArrays.jl 12.3.0, pocl_jll 7.2.2+21
  • Debian GNU/Linux 13, x86_64, Docker
  • PoCL CPU on Intel Core i7-11700, driver 7.2~julia-6335e42d3abe
  • NVIDIA OpenCL on GeForce RTX 4090, driver 595.99.02

Activity

  1. christiangnrd commented on Dec 2, 2026

    @christiangnrd
    Member

    This seems to be expected behaviour. What do you want an array of an unsupported type for?

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