Repository navigation
POCL: report exceptions by throw site - #982
Conversation
|
Documentation preview: https://juliagpu.github.io/KernelAbstractions.jl/previews/PR982/ |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #982 +/- ##
==========================================
- Coverage 89.73% 89.26% -0.47%
==========================================
Files 33 33
Lines 3077 3010 -67
==========================================
- Hits 2761 2687 -74
- Misses 316 323 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
53ce230 to
ceae1e5
Compare
ceae1e5 to
fb78d15
Compare
Benchmark resultsCompared with 20ca9a8d0, the merge base.
All benchmarks
|
Every bounds check in a kernel carried a copy of the exception reporting code, which PoCL inlines into the work-item loops. Values in that code could get an array over the work-group, so kernels with many bounds checks needed megabytes of stack (#974): with a work-group whose outermost dimension is 2, e.g. 32x32x2, still 8 bytes per bounds check per work-item after #976. Use GPUCompiler's reporting by throw site instead: a throw only records its site's id and work-item, through a single copy of the reporting code per kernel, and the host looks up what was thrown. A kernel with 256 bounds checks now has no stack frame at any work-group shape, instead of up to 4.2 MB, and 6.6 KB of code instead of 83-122 KB. `KernelException` now names the exception, the work-item and the reason, and at debug level 2 has a backtrace that reaches the kernel, instead of the kernel printing them. Kernels that launch work-groups of both the full and the bounds-checked variant look the site up in the table of the variant that ran the work-item.
fb78d15 to
fcc8d15
Compare
|
Broke CI on 1.12? |
Follow-up on #974 and #976, from the comment on #976: with a work-group whose outermost dimension is 2 (e.g. 32x32x2, which KA picks for an ndrange of 32x32x10), every bounds check still cost 8 bytes of stack per work-item. PoCL demotes the result of the inlined reporting code to an alloca, its work-item loops make that an array over the work-group, and for a trip count of 2 SROA turns its index into a pointer phi that InstCombine doesn't see through, so the write-only array stays. The underlying problem is that every bounds check carries its own copy of the reporting code, whose values are candidates for such arrays.
This uses GPUCompiler's new reporting by throw site (JuliaGPU/GPUCompiler.jl#1100): a throw records only its site's id and work-item, through one copy of the reporting code per kernel, and the host looks up what was thrown.
With 256 bounds checks:
KernelExceptionnow carries the exception's name, reason and the work-item that threw, and at debug level 2 a backtrace. The kernel no longer prints anything:The backtrace now reaches the kernel, where it used to stop at "multiple call sites". The report only arrives once the launch completes, and names and reasons are no longer printed by the device.
Requires GPUCompiler 2.23, which has that change.