Repository navigation
Backlog
Description
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
endObserved 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 emptyFloat32matrix of the same shape was accepted on both devices. - In OpenCL.jl 1.0.0,
check_eltypeinsrc/array.jlchecks the active device’s extensions forFloat16element 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
Metadata
Metadata
Assignees
Labels
No labels
Activity
christiangnrd commentedon Dec 2, 2026
This seems to be expected behaviour. What do you want an array of an unsupported type for?