Skip to content

Accept Memory as a kernel argument on the POCL backend - #957

Open
sasmith-14 wants to merge 1 commit into
JuliaGPU:mainfrom
sasmith-14:memory-kernel-args
Open

sasmith-14 wants to merge 1 commit into
JuliaGPU:mainfrom
sasmith-14:memory-kernel-args

Conversation

@sasmith-14

Copy link
Copy Markdown
Contributor

follow-up to #948: get_backend(::Memory) now returns the POCL backend, but a Memory still can't be passed to a kernel:

@kernel f!(A) = (A[@index(Global)] = 1)
f!(POCLBackend())(Memory{Int}(undef, 4); ndrange = 4)
# ERROR: KernelError: passing non-bitstype argument

only Array gets converted to a device array, so this wraps the Memory in an Array (no copy) and reuses that conversion. views and bits-union eltypes work too. added a "POCL Memory arguments" testset that errors without the change, and the full test suite passes locally.

Claude helped me find this and run the tests; I reviewed the changes.

`get_backend(::Memory)` returns the POCL backend, but only `Array`s were converted to device arrays, so passing a `Memory` (or a view of one) to a kernel failed with "passing non-bitstype argument". Wrap it in an `Array`, which does not copy, and reuse that conversion.
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Benchmark results

Compared with 8a985320e, the merge base.
Times are the minimum time of every benchmark. A change is unusual when it exceeds both three times the benchmark's typical change between consecutive runs on the default branch and a minimum per category (performance 3%, latency 5%, applications 3%, other 3%). A benchmark that starts or stops allocating is listed however few the allocations. A single run can still be a fluke, so rerun before drawing conclusions.

Geometric mean Unusual: slower Unusual: faster Compared
Performance +0.1% 2 0 32
Latency −1.8% 0 0 13
Applications +0.5% 0 1 5
Benchmark Baseline This PR Change
Performance
pocl/parallel/groupscan/add-i32 300 µs 424 µs +41.6% 🔴 slower
pocl/parallel/scheduling/explicit 154 µs 181 µs +17.9% 🔴 slower
Applications
pocl/parallel/dgsem/weak-node-localmem 146 µs 116 µs −20.5% 🟢 faster
All benchmarks
Benchmark Baseline This PR Change
Performance
julia/serial/arithmetic/muladd-reference 655 µs 655 µs +0.0%
julia/serial/math/exp-f64-reference 284 µs 284 µs +0.0%
julia/serial/narrow/masked-reference 736 µs 711 µs −3.4%
pocl/parallel/atomics/histogram 5.16 ms 5.15 ms −0.2%
pocl/parallel/groupreduce/add-f64 1.17 ms 1.17 ms +0.1%
pocl/parallel/groupreduce/fallback 4.42 ms 4.42 ms +0.0%
pocl/parallel/groupscan/add-i32 300 µs 424 µs +41.6% 🔴 slower
pocl/parallel/indexing/cartesian3d 83.7 µs 80.2 µs −4.1%
pocl/parallel/indexing/linear3d 72.4 µs 77.5 µs +6.9%
pocl/parallel/indexing/ntuple3d 82.6 µs 80.4 µs −2.7%
pocl/parallel/indexing/ntuple4d 168 µs 164 µs −2.7%
pocl/parallel/localmem/transpose-naive 457 µs 453 µs −0.8%
pocl/parallel/localmem/transpose-tiled 110 µs 97.3 µs −11.2%
pocl/parallel/private/across-barrier 84.1 µs 83.3 µs −1.0%
pocl/parallel/scheduling/default 181 µs 181 µs +0.0%
pocl/parallel/scheduling/explicit 154 µs 181 µs +17.9% 🔴 slower
pocl/parallel/stream/copy/cache 677 ns 670 ns −1.0%
pocl/parallel/stream/copy/dram 6.52 ms 6.30 ms −3.3%
pocl/parallel/stream/triad/cache 7.50 µs 7.16 µs −4.6%
pocl/parallel/stream/triad/dram 9.47 ms 9.40 ms −0.8%
pocl/parallel/util/copyto-small 26.0 ns 24.0 ns −7.7%
pocl/parallel/util/zeros-large 996 µs 996 µs +0.0%
pocl/parallel/util/zeros-small 643 ns 655 ns +1.9%
pocl/serial/arithmetic/contract 1.90 ms 1.90 ms +0.1%
pocl/serial/arithmetic/muladd 765 µs 768 µs +0.3%
pocl/serial/const/marked 714 µs 733 µs +2.6%
pocl/serial/const/unmarked 914 µs 914 µs +0.0%
pocl/serial/math/exp-f64 139 µs 138 µs −0.2%
pocl/serial/math/sin-f64 210 µs 192 µs −8.3%
pocl/serial/narrow/masked 797 µs 788 µs −1.1%
pocl/serial/narrow/unmasked 781 µs 757 µs −3.0%
pocl/serial/stream/triad/dram 8.67 ms 8.61 ms −0.7%
Latency
host/import/ka 501 ms 503 ms +0.3%
host/precompile/ka 39.7 s 39.7 s +0.1%
host/startup 131 ms 131 ms −0.0%
pocl/parallel/launch/dynamic-default 4.48 µs 4.44 µs −0.9%
pocl/parallel/launch/groupreduce-f64 6.53 µs 6.33 µs −3.1%
pocl/parallel/launch/many-args 12.5 µs 10.7 µs −14.3%
pocl/parallel/launch/partial-workgroup 4.25 µs 4.20 µs −1.2%
pocl/serial/compile/groupreduce 1.49 s 1.46 s −1.5%
pocl/serial/compile/localmem-barrier 710 ms 697 ms −1.8%
pocl/serial/compile/new-kernel 121 ms 121 ms −0.4%
pocl/serial/compile/new-workgroupsize 8.79 ms 8.84 ms +0.6%
pocl/serial/first-kernel/cold-cache 353 ms 350 ms −0.9%
pocl/serial/first-kernel/warm-cache 275 ms 275 ms +0.1%
Applications
pocl/parallel/dgsem/fluxdiff-node 289 µs 290 µs +0.2%
pocl/parallel/dgsem/weak-element 161 µs 207 µs +28.8%
pocl/parallel/dgsem/weak-node-localmem 146 µs 116 µs −20.5% 🟢 faster
pocl/parallel/stencil/timestep 8.11 ms 8.08 ms −0.3%
pocl/serial/stencil/timestep 11.5 ms 11.5 ms +0.1%

History: https://juliagpu.org/perf/?pkg=kernelabstractions

@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.19%. Comparing base (8a98532) to head (67d50af).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #957      +/-   ##
==========================================
- Coverage   84.95%   84.19%   -0.76%     
==========================================
  Files          31       31              
  Lines        2612     2563      -49     
==========================================
- Hits         2219     2158      -61     
- Misses        393      405      +12     

☔ 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.

This branch has not been deployed

No deployments
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