Skip to content

POCL: copy small arrays from the host in copyto! - #935

Merged
maleadt merged 1 commit into
mainfrom
tb/pocl-copyto-host
Oct 27, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/pocl-copyto-host

Conversation

@maleadt

@maleadt maleadt commented Oct 27, 2026

Copy link
Copy Markdown
Member

KI.copyto! between two arrays always launched a kernel, which takes 2.5 µs for 64 Float32s that the host copies in 10 ns (the performance/pocl/parallel/util/copyto-small benchmark).

Like zeros and ones since #927, this copies with a kernel only from 1 MiB, where it spreads the destination's pages over PoCL's threads (and their memory domains); smaller copies and copies of bits-union arrays use Base.copyto!. Overlapping arrays are copied from the host too, which handles the overlap, instead of throwing "Arrays may not alias".

Measured on an M3 Pro only, where the host copy is faster at every size; the 1 MiB threshold is kept for the many-core and NUMA machines that #927 and #928 were about.

Copying between two arrays always launched a kernel, which takes 2.5 µs
for 64 elements that the host copies in 10 ns. Copy with a kernel only
from the size at which `zeros` and `ones` fill with one (1 MiB), for
the same reason: spreading the destination's pages over PoCL's threads.

Overlapping arrays are copied from the host too, which handles the
overlap, rather than throwing an error.
@maleadt maleadt added the pocl The PoCL-based CPU back-end. label Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark results

Compared with d2ada37c6, the latest measured ancestor of the merge base (1 commit before it).
The environment differs from the baseline's: Parsers 3.0.1 → 3.0.2.

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 −20.7% 0 0 32
Latency +0.2% 0 0 13
Applications +10.8% 0 0 5

No unusual changes.

All benchmarks
Benchmark Baseline This PR Change
Performance
julia/serial/arithmetic/muladd-reference 655 µs 655 µs −0.0% noise unknown
julia/serial/math/exp-f64-reference 284 µs 286 µs +0.7% noise unknown
julia/serial/narrow/masked-reference 702 µs 726 µs +3.4% noise unknown
pocl/parallel/atomics/histogram 5.16 ms 5.15 ms −0.1% noise unknown
pocl/parallel/groupreduce/add-f64 1.66 ms 1.65 ms −0.5% noise unknown
pocl/parallel/groupreduce/fallback 18.1 ms 18.9 ms +4.5% noise unknown
pocl/parallel/groupscan/add-i32 2.53 ms 2.53 ms −0.0% noise unknown
pocl/parallel/indexing/cartesian3d 84.8 µs 79.5 µs −6.3% noise unknown
pocl/parallel/indexing/linear3d 84.4 µs 78.5 µs −7.0% noise unknown
pocl/parallel/indexing/ntuple3d 81.4 µs 84.1 µs +3.4% noise unknown
pocl/parallel/indexing/ntuple4d 164 µs 168 µs +2.6% noise unknown
pocl/parallel/localmem/transpose-naive 459 µs 453 µs −1.3% noise unknown
pocl/parallel/localmem/transpose-tiled 101 µs 104 µs +3.0% noise unknown
pocl/parallel/private/across-barrier 164 µs 165 µs +0.8% noise unknown
pocl/parallel/scheduling/default 181 µs 181 µs −0.3% noise unknown
pocl/parallel/scheduling/explicit 181 µs 181 µs −0.0% noise unknown
pocl/parallel/stream/copy/cache 6.06 µs 686 ns −88.7% noise unknown
pocl/parallel/stream/copy/dram 6.32 ms 6.26 ms −0.9% noise unknown
pocl/parallel/stream/triad/cache 6.90 µs 6.96 µs +0.9% noise unknown
pocl/parallel/stream/triad/dram 8.94 ms 9.41 ms +5.2% noise unknown
pocl/parallel/util/copyto-small 4.59 µs 24.0 ns −99.5% noise unknown
pocl/parallel/util/zeros-large 998 µs 1.01 ms +1.4% noise unknown
pocl/parallel/util/zeros-small 665 ns 635 ns −4.5% noise unknown
pocl/serial/arithmetic/contract 1.91 ms 1.91 ms +0.1% noise unknown
pocl/serial/arithmetic/muladd 759 µs 771 µs +1.5% noise unknown
pocl/serial/const/marked 728 µs 722 µs −0.8% noise unknown
pocl/serial/const/unmarked 915 µs 915 µs −0.1% noise unknown
pocl/serial/math/exp-f64 147 µs 147 µs −0.2% noise unknown
pocl/serial/math/sin-f64 202 µs 194 µs −4.2% noise unknown
pocl/serial/narrow/masked 854 µs 819 µs −4.0% noise unknown
pocl/serial/narrow/unmasked 765 µs 798 µs +4.3% noise unknown
pocl/serial/stream/triad/dram 8.63 ms 8.62 ms −0.2% noise unknown
Latency
host/import/ka 506 ms 505 ms −0.2% noise unknown
host/precompile/ka 44.9 s 44.4 s −0.9% noise unknown
host/startup 133 ms 131 ms −2.0% noise unknown
pocl/parallel/launch/dynamic-default 4.39 µs 4.45 µs +1.3% noise unknown
pocl/parallel/launch/groupreduce-f64 18.5 µs 18.4 µs −0.5% noise unknown
pocl/parallel/launch/many-args 12.0 µs 12.0 µs −0.3% noise unknown
pocl/parallel/launch/partial-workgroup 4.18 µs 4.42 µs +5.6% noise unknown
pocl/serial/compile/groupreduce 2.06 s 2.08 s +1.1% noise unknown
pocl/serial/compile/localmem-barrier 808 ms 802 ms −0.8% noise unknown
pocl/serial/compile/new-kernel 118 ms 119 ms +0.5% noise unknown
pocl/serial/compile/new-workgroupsize 13.6 ms 13.6 ms +0.7% noise unknown
pocl/serial/first-kernel/cold-cache 2.02 s 2.01 s −0.3% noise unknown
pocl/serial/first-kernel/warm-cache 360 ms 356 ms −0.9% noise unknown
Applications
pocl/parallel/dgsem/fluxdiff-node 291 µs 291 µs +0.1% noise unknown
pocl/parallel/dgsem/weak-element 160 µs 198 µs +24.2% noise unknown
pocl/parallel/dgsem/weak-node-localmem 118 µs 147 µs +24.5% noise unknown
pocl/parallel/stencil/timestep 7.91 ms 7.86 ms −0.6% noise unknown
pocl/serial/stencil/timestep 11.3 ms 12.2 ms +8.7% noise unknown

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

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.27%. Comparing base (d2ada37) to head (d20ab13).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #935      +/-   ##
==========================================
+ Coverage   82.87%   83.27%   +0.39%     
==========================================
  Files          31       31              
  Lines        2564     2565       +1     
==========================================
+ Hits         2125     2136      +11     
+ Misses        439      429      -10     

☔ 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 bf8ebef into main Oct 27, 2026
69 checks passed
@maleadt
maleadt deleted the tb/pocl-copyto-host branch October 27, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pocl The PoCL-based CPU back-end.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant