Skip to content

Use GPUToolbox's shared throw overrides, including for throw_domerr_powbysq - #781

Merged
maleadt merged 4 commits into
mainfrom
tb/powbysq
Nov 25, 2026
Merged

maleadt merged 4 commits into
mainfrom
tb/powbysq

Conversation

@maleadt

@maleadt maleadt commented Nov 25, 2026

Copy link
Copy Markdown
Member

Requires GPUToolbox 3.7 (JuliaRegistries/General#177697). Supersedes #764, whose two commits are rebased here onto the throw-site reporting of #768.

oneAPI overlaid Base.throw_domerr_powbysq three times, for ::Any, ::Integer and ::AbstractMatrix bases, with identical bodies. When Julia 1.12 or 1.13 loads a package image, it only trusts a kernel's edge to an overlay method that no more specific method of the same table intersects, and verifies other edges against the global method table, which doesn't have the overlay. The narrower overlays shadowed the ::Any one, so every kernel computing an integer power was dropped from the image and compiled again in each session. JuliaLang/julia#64727 fixes that upstream; JuliaGPU/GPUToolbox.jl#46 adds a single shared override to GPUToolbox.Overlays.throw_overrides, like the other back-ends use.

This PR:

  • stacks throw_overrides below oneAPI's own tables (with and without Float64 support), which also makes Rational arithmetic compile on Julia 1.10 and 1.11, where Base formats some of its error messages at run time;
  • implements GPUToolbox.Overlays.device_throw with @gputhrow, so that the shared overrides' exceptions report their type and reason like oneAPI's own quirks;
  • drops oneAPI's three throw_domerr_powbysq overlays in favor of the shared one.

Checked on macOS by compiling kernels through GPUCompiler with a device-independent config (both SPIR-V back-ends, with and without Float64): with debug_level=1, a[1]^p registers a DomainError site with reason "Cannot raise an integer to a negative power" on Julia 1.10, 1.12 and 1.13, and on Julia 1.10 the Rational kernels register the shared overrides' ArgumentError and OverflowError. On Julia 1.12 and 1.13, no method of oneAPI's or SPIRVIntrinsics' method table has interferences. The new tests in test/execution.jl passed on an Iris Xe with Julia 1.10 and 1.12.

Julia 1.10 formats the message of the error that `Rational` throws for a
typemin denominator, and Julia 1.10 and 1.11 that of negating a typemin
numerator, which fails to compile for the device. That breaks every
kernel that constructs a rational with a negative denominator or negates
one. GPUToolbox 3.6's `throw_overrides` throw these errors with a
constant message instead.
GPUToolbox's shared overrides throw through `Overlays.device_throw`, with
a constant exception type and message. Report them with `@gputhrow`, so
that these exceptions report their type and message like oneAPI's own
quirks, instead of as an exception of unknown type.
oneAPI overlaid `throw_domerr_powbysq` for `::Any`, `::Integer` and
`::AbstractMatrix` bases. When Julia 1.12+ loads a package image, it only
trusts a kernel's edge to an overlay that no more specific method of the
same table intersects, and verifies the others against the global method
table, which doesn't have the overlay. The narrower overlays shadowed the
`::Any` one, so every kernel computing an integer power was dropped from
the image and compiled again in each session (fixed upstream by
JuliaLang/julia#64727).

GPUToolbox 3.7's `throw_overrides` has a single override, which reports
the same exception through `device_throw`, so drop oneAPI's.
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.01%. Comparing base (3c96106) to head (7ebb6a6).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/compiler/compilation.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main     #781    +/-   ##
========================================
  Coverage   86.00%   86.01%            
========================================
  Files          55       55            
  Lines        5475     5084   -391     
========================================
- Hits         4709     4373   -336     
+ Misses        766      711    -55     

☔ 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 b914ea6 into main Nov 25, 2026
2 of 3 checks passed
@maleadt
maleadt deleted the tb/powbysq branch November 25, 2026 17:58
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