Skip to content

KernelInterface: make the events test robust to a shared device - #1005

Open
maleadt wants to merge 1 commit into
mainfrom
tb/ki-events-contention
Open

maleadt wants to merge 1 commit into
mainfrom
tb/ki-events-contention

Conversation

@maleadt

@maleadt maleadt commented Nov 30, 2026

Copy link
Copy Markdown
Member

The ordered across tasks events test compares the time a task that waits on an event takes with a drain time measured beforehand, and requires at least a third of it. When other work shares the device, one drain can take several times as long as the next. On Metal.jl's CI, whose test suite runs four workers on one GPU, the reference drain of 20 launches of about 10 ms took 2.07 s, and the wait 0.59 s, which failed the check (https://buildkite.com/julialang/metal-dot-jl/builds/4125).

The wait is now timed three times, and the longest of those is compared with the shortest drain, timed both before and after. A missing wait still returns in milliseconds every time: with wait_event replaced by a no-op on an M1, the waits took 10 ms against a threshold of 71 ms, and the test fails as before. The test takes about 4 s longer.

I couldn't reproduce the failure locally, even with another process loading the GPU in bursts, so the change rests on the CI numbers above. Bumps KernelInterface to 0.4.8, since back ends run this test suite from the released package.

The test compares the time a task waiting on an event takes with a drain
time measured beforehand. When other work shares the device, such as the
parallel workers of Metal.jl's test suite, one drain can take several
times as long as the next: on Metal.jl CI, the reference drain took
2.07 s and the wait 0.59 s, failing the check against a third of it.

Time the wait three times and compare the longest with the shortest
drain, measured both before and after. A missing wait still returns in
milliseconds every time (10 ms against a 71 ms threshold on an M1).
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark results

Compared with a585449d8, the merge base.
The environment differs from the baseline's: OS Linux 6.8.0-124-generic → Linux 6.8.0-151-generic, CompilerCaching 0.5.4 → 0.6.0, GPUCompiler 2.24.0 → 2.25.0, GPUToolbox 3.6.0 → 3.7.0, KernelInterface 0.4.7 → 0.4.8, LLVM 10.7.0 → 10.8.1, LLVMExtra_jll 0.0.60+0 → 0.0.61+0, MacroTools 0.5.16 → 0.5.17, SPIRV_LLVM_Backend_jll 23.1.4+5 → 23.1.4+6, XML2_jll 2.15.5 → 2.15.6.

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.2% 0 0 32
Latency +1.3% 1 0 13
Applications +1.7% 0 0 5
Benchmark Baseline This PR Change
Latency
pocl/serial/compile/new-kernel 127 ms 137 ms +7.9% 🔴 slower
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 285 µs +0.5%
julia/serial/narrow/masked-reference 715 µs 712 µs −0.4%
pocl/parallel/atomics/histogram 5.21 ms 5.26 ms +0.9%
pocl/parallel/groupreduce/add-f64 1.09 ms 1.09 ms +0.2%
pocl/parallel/groupreduce/fallback 4.38 ms 4.39 ms +0.2%
pocl/parallel/groupscan/add-i32 393 µs 393 µs +0.1%
pocl/parallel/indexing/cartesian3d 39.5 µs 39.7 µs +0.4%
pocl/parallel/indexing/linear3d 39.9 µs 40.9 µs +2.5%
pocl/parallel/indexing/ntuple3d 40.5 µs 40.3 µs −0.6%
pocl/parallel/indexing/ntuple4d 127 µs 127 µs −0.5%
pocl/parallel/localmem/transpose-naive 433 µs 431 µs −0.4%
pocl/parallel/localmem/transpose-tiled 65.9 µs 67.8 µs +2.9%
pocl/parallel/private/across-barrier 42.5 µs 42.3 µs −0.4%
pocl/parallel/scheduling/default 117 µs 117 µs −0.0%
pocl/parallel/scheduling/explicit 117 µs 117 µs −0.0%
pocl/parallel/stream/copy/cache 663 ns 663 ns +0.0%
pocl/parallel/stream/copy/dram 6.50 ms 6.39 ms −1.8%
pocl/parallel/stream/triad/cache 1.29 µs 1.20 µs −7.3%
pocl/parallel/stream/triad/dram 9.54 ms 9.66 ms +1.3%
pocl/parallel/util/copyto-small 25.0 ns 24.0 ns −4.0%
pocl/parallel/util/zeros-large 941 µs 905 µs −3.8%
pocl/parallel/util/zeros-small 627 ns 651 ns +3.8%
pocl/serial/arithmetic/contract 1.85 ms 1.85 ms +0.0%
pocl/serial/arithmetic/muladd 705 µs 705 µs −0.0%
pocl/serial/const/marked 668 µs 668 µs −0.0%
pocl/serial/const/unmarked 860 µs 859 µs −0.1%
pocl/serial/math/exp-f64 123 µs 123 µs −0.2%
pocl/serial/math/sin-f64 167 µs 172 µs +3.4%
pocl/serial/narrow/masked 635 µs 634 µs −0.2%
pocl/serial/narrow/unmasked 635 µs 634 µs −0.3%
pocl/serial/stream/triad/dram 8.62 ms 8.55 ms −0.9%
Latency
host/import/ka 764 ms 767 ms +0.3%
host/precompile/ka 27.1 s 27.3 s +0.4%
host/startup 130 ms 128 ms −0.8%
pocl/parallel/launch/dynamic-default 165 ns 166 ns +0.6%
pocl/parallel/launch/groupreduce-f64 770 ns 771 ns +0.1%
pocl/parallel/launch/many-args 662 ns 698 ns +5.4%
pocl/parallel/launch/partial-workgroup 234 ns 235 ns +0.4%
pocl/serial/compile/groupreduce 1.51 s 1.49 s −1.2%
pocl/serial/compile/localmem-barrier 674 ms 683 ms +1.4%
pocl/serial/compile/new-kernel 127 ms 137 ms +7.9% 🔴 slower
pocl/serial/compile/new-workgroupsize 8.73 ms 8.88 ms +1.7%
pocl/serial/first-kernel/cold-cache 395 ms 398 ms +0.8%
pocl/serial/first-kernel/warm-cache 321 ms 320 ms −0.3%
Applications
pocl/parallel/dgsem/fluxdiff-node 246 µs 245 µs −0.4%
pocl/parallel/dgsem/weak-element 90.7 µs 90.1 µs −0.6%
pocl/parallel/dgsem/weak-node-localmem 93.1 µs 93.6 µs +0.5%
pocl/parallel/stencil/timestep 7.29 ms 7.55 ms +3.7%
pocl/serial/stencil/timestep 10.1 ms 10.6 ms +5.5%

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

@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.21%. Comparing base (a585449) to head (1c6ff6a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1005      +/-   ##
==========================================
- Coverage   90.79%   89.21%   -1.59%     
==========================================
  Files          33       33              
  Lines        3293     3005     -288     
==========================================
- Hits         2990     2681     -309     
- Misses        303      324      +21     

☔ 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