Skip to content

Raise a clear error when passing CPU arrays to kernels - #723

Merged
maleadt merged 1 commit into
mainfrom
tb/cpu-array-error
Oct 20, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/cpu-array-error

Conversation

@maleadt

@maleadt maleadt commented Oct 19, 2026

Copy link
Copy Markdown
Member

Mixing a oneArray with an Array in a broadcast (oneArray(x) .+ y), or passing an Array to @oneapi, used to fail in GPUCompiler's argument validation, which prints the whole Broadcasted type and walks its non-isbits fields. Arrays are now rejected while converting kernel arguments, before compilation:

ERROR: ArgumentError: cannot use a CPU array (Vector{Float32}) in a oneAPI kernel.
Convert it to a GPU array first, e.g. using `oneArray(x)`.

The compiler already rejected every non-isbits argument, used or not, so this only changes the error. Adapt recurses into wrappers, so views, adjoints, Refs and captured arrays get the same message.

Port of JuliaGPU/Metal.jl#1077 (JuliaGPU/Metal.jl#212).

Mixing a oneArray with an Array in a broadcast, or passing an Array to
`@oneapi`, only failed in the compiler's argument validation, which dumps
the full argument type and its non-isbits fields. Reject Arrays during
argument conversion instead, with a message pointing at `oneArray`.
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.48%. Comparing base (a0adaa1) to head (dd2e41f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #723      +/-   ##
==========================================
+ Coverage   83.13%   83.48%   +0.35%     
==========================================
  Files          52       51       -1     
  Lines        4376     4264     -112     
==========================================
- Hits         3638     3560      -78     
+ Misses        738      704      -34     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt
maleadt merged commit 88eff97 into main Oct 20, 2026
3 of 4 checks passed
@maleadt
maleadt deleted the tb/cpu-array-error branch October 20, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant