Repository navigation
Report exceptions by throw site - #768
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #768 +/- ##
==========================================
- Coverage 87.34% 86.78% -0.56%
==========================================
Files 56 55 -1
Lines 5263 5094 -169
==========================================
- Hits 4597 4421 -176
- Misses 666 673 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
maleadt
force-pushed
the
tb/exception-sites
branch
from
November 18, 2026 06:55
e38be61 to
90d1a46
Compare
maleadt
marked this pull request as ready for review
November 18, 2026 06:55
Contributor
|
Documentation preview: https://juliagpu.github.io/oneAPI.jl/previews/PR768/ |
Every bounds check carried its own calls to the reporting functions, which were kept out of line as inlining them made kernels slower still. Any call left in the SPIR-V makes IGC compile the kernel at SIMD8 rather than SIMD32, so a kernel with 256 bounds-checked reads ran 5.6x slower than with `@inbounds` on an Iris Xe, and one with 64 reads 2.8x. Use GPUCompiler's reporting by throw site instead: a throw only records the id of its site, the kernel and the position of the work-item, through a single inlined copy of the reporting code per kernel, and the host looks the site up in the table that compilation returned for that kernel, of those launched on the stream since it was last checked. The SPIR-V of such kernels has no calls left, so IGC compiles them at SIMD32, and the kernels with 256 and 64 checked reads now run 3.1x and 1.8x slower than with `@inbounds`. The names, reasons and backtraces now live on the host, so they are no longer read back from the device after a kernel threw. `KernelException` also has the position of the work-item that threw at every debug level, rather than only at -g2.
maleadt
force-pushed
the
tb/exception-sites
branch
from
November 19, 2026 06:00
90d1a46 to
d4ffbf3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kernels now report exceptions through GPUCompiler's reporting by throw site (JuliaGPU/GPUCompiler.jl#1100). A throw only records which site threw, in which kernel, and which work-item did. The host then looks the site up in the table that compilation returned for that kernel. The device no longer passes along string pointers and backtrace frames.
This mostly matters for performance. Each bounds check used to carry its own out-of-line calls to the reporting functions, and any call left in the SPIR-V makes IGC compile the whole kernel at SIMD8 instead of SIMD32. Now all throw sites of a kernel branch to a single inlined copy of the reporting code, so the SPIR-V has no
OpFunctionCallleft and IGC goes back to SIMD32.Micro-benchmark on an Iris Xe (sagittarius): 2^22 work-items, each doing N bounds-checked reads, compared with
@inbounds. Best of 20 runs. The host was also running CI jobs, so absolute times are somewhat noisy.Neither version needs spill or private memory.
What users see:
KernelExceptionkeeps its fields (name,reason,work_item,work_group,backtrace). The position of the work-item that threw is now recorded at every debug level, not only at-g2:At
-g2the hint is replaced by the backtrace, which reaches the kernel. Names and backtraces are no longer truncated or read back from device memory: the code that copied strings from the device after a throw, and validated their addresses, is gone.Implementation notes:
oneAPIResults, so it is cached with theCodeInstanceand in package images. It is also attached to the linkedZeKernel.ZeKernelinKernelState. The stream keeps the kernels launched since it last checked its report, and the host only accepts a reported kernel and site that match one of those. A corrupted report therefore yields an anonymousKernelException, never a crash.@gputhrowis now GPUCompiler's.